Skip to content

Use 0 rather than NULL for the empty command queue property set - #60

Merged
galekseev merged 1 commit into
masterfrom
cursor/fix-null-to-integer-conversion-warning-9783
Aug 2, 2026
Merged

Use 0 rather than NULL for the empty command queue property set#60
galekseev merged 1 commit into
masterfrom
cursor/fix-null-to-integer-conversion-warning-9783

Conversation

@galekseev

@galekseev galekseev commented Aug 2, 2026

Copy link
Copy Markdown

Drive-by cleanup noticed while reviewing #58, on the line directly above the one that PR changed.

Problem

cl_command_queue_properties is a cl_bitfield, which is a cl_ulong. It is not a pointer type, so initialising it from NULL depends on the null pointer constant converting to an integer. gcc flags this under -Wall, which Makefile enables for every build:

Dispatcher.cpp:140:41: warning: converting to non-pointer type
'cl_command_queue_properties' {aka 'long unsigned int'} from NULL [-Wconversion-null]

Beyond the noise, NULL here reads as "no properties pointer", which is misleading: p is a bitfield of queue property flags, and the intended value is the empty flag set.

Change

 #ifdef PROFANITY_DEBUG
 	cl_command_queue_properties p = CL_QUEUE_PROFILING_ENABLE;
 #else
-	cl_command_queue_properties p = NULL;
+	cl_command_queue_properties p = 0;
 #endif

This matches the #ifdef branch above it, which already assigns a bitfield constant.

Verification

Linux, OpenCL 3.0 headers, gcc 13, built with the project's own flags (-std=c++11 -Wall -O2 -mcmodel=large).

  • This was the only -Wconversion-null in the project. Both the release and the -DPROFANITY_DEBUG build now report zero, leaving only the unrelated pre-existing -Waligned-new= note on new Dispatcher::Device.
  • The emitted object file is byte-identical before and after (md5 3e19513d758d567d6c1e15acdbfffbb1 either way), so this is a provable no-op at the machine code level.

cl_command_queue_properties is a cl_bitfield (cl_ulong), not a pointer,
so initialising it from NULL relies on the null pointer constant
converting to an integer. gcc flags this under -Wall, which the Makefile
enables:

  Dispatcher.cpp:140:41: warning: converting to non-pointer type
  'cl_command_queue_properties' {aka 'long unsigned int'} from NULL
  [-Wconversion-null]

This was the only -Wconversion-null in the project; both the release and
the PROFANITY_DEBUG build are now clean of it. The emitted object file is
byte-identical, so there is no behavioural change.

Co-authored-by: Gleb Alekseev <alekseev.gleb@gmail.com>
@galekseev
galekseev merged commit 420bed9 into master Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants