Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Wcast-qual warning. #241

Merged
merged 2 commits into from
Sep 26, 2024
Merged

Fix Wcast-qual warning. #241

merged 2 commits into from
Sep 26, 2024

Conversation

haonanya
Copy link

No description provided.

@haonanya
Copy link
Author

@bashbaug, @Kerilk, can you please review it? Thanks very much.

Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one suggestion for improvement.

Which compiler / compiler flags did you use to find these issues? Is this something we could have caught via CI?

@haonanya
Copy link
Author

LGTM, one suggestion for improvement.

Which compiler / compiler flags did you use to find these issues? Is this something we could have caught via CI?

gcc uses -Werror -Wcast-qual build fail:

[haonanya]$ /usr/bin/gcc -DCL_ENABLE_LAYERS -DCL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES -DCL_TARGET_OPENCL_VERSION=300 -DOPENCL_ICD_LOADER_VERSION_MAJOR=3 -DOPENCL_ICD_LOADER_VERSION_MINOR=0 -DOPENCL_ICD_LOADER_VERSION_REV=6 -DOpenCL_EXPORTS -I/export/users/haonanya/OpenCL-CTS/OpenCL-Headers -I/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/build -I/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader -fPIC -std=gnu99 -Werror -Wcast-qual -MD -MT CMakeFiles/OpenCL.dir/loader/linux/icd_linux.c.o -MF CMakeFiles/OpenCL.dir/loader/linux/icd_linux.c.o.d -o CMakeFiles/OpenCL.dir/loader/linux/icd_linux.c.o -c /export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader/linux/icd_linux.c
/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader/linux/icd_linux.c: In function ‘compareDirElem’:
/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader/linux/icd_linux.c:132:21: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
132 | return strcoll(((struct dirElem *)a)->d_name, ((struct dirElem *)b)->d_name);
| ^
/export/users/haonanya/OpenCL-CTS/OpenCL-ICD-Loader/loader/linux/icd_linux.c:132:52: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
132 | return strcoll(((struct dirElem *)a)->d_name, ((struct dirElem *)b)->d_name);
| ^
cc1: all warnings being treated as errors

@haonanya
Copy link
Author

@MathiasMagnus, can you please take a review? I don't know if 1 approval can land the PR, thanks very much.

Copy link
Contributor

@Kerilk Kerilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Kerilk
Copy link
Contributor

Kerilk commented Sep 26, 2024

I agree with @bashbaug, if we don't test for it, we will break it again.

@haonanya
Copy link
Author

Are we ready to land? @bashbaug , @Kerilk , thanks.

@bashbaug
Copy link
Contributor

I created #242 so we don't lose track of the CI improvements. Merging.

@bashbaug bashbaug merged commit 804b6f0 into KhronosGroup:main Sep 26, 2024
33 checks passed
@haonanya haonanya deleted the fix-warning branch September 26, 2024 14:26
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.

4 participants