-
-
Notifications
You must be signed in to change notification settings - Fork 26
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 misc gcc warnings #570
Conversation
derobins
commented
Feb 20, 2024
- Remove dead code in hdf/src/mfan.c
- Add const to many constant string initializations
- Fix some integer type mismatch with casts
- Fix logic and parentheses in szip test
- Clarify ambiguous brackets
* Remove dead code in hdf/src/mfan.c * Add const to many constant string initializations * Fix some integer type mismatch with casts * Fix logic and parentheses in szip test * Clarify ambiguous brackets
@@ -6,3 +6,4 @@ | |||
# regarding the library settings string (H4libhdf4_settings). We'll turn | |||
# it off here but leave it on in the developer flags. | |||
-Wno-overlength-strings | |||
-Wno-format-nonliteral |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just noise. We have no plans to rework how the library works in a way that would make these go away.
int16 data_out[3 * Y_LENGTH * X_LENGTH]; | ||
const char *image_name[] = {"Image_NO", "Image_RL", "Image_Sk", "Image_DF"}; | ||
const char *file_name[] = {"ChunkedGR_NO.hdf", "ChunkedGR_RL.hdf", "ChunkedGR_SK.hdf", | ||
"ChunkedGR_DF.hdf"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed most of the complaints about assigning const strings to non-const pointers at initialization
for (uint8 j = 0; j < 128; j++) { | ||
image_buf[i][j][0] = (uint8)(i + j + 1); | ||
image_buf[i][j][1] = (uint8)(i + j + 1); | ||
image_buf[i][j][2] = (uint8)(i + j + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed complaints about integer casts
comp_info *cinfo, char *message) /* Compression parameters */ | ||
static int | ||
make_comp_image(int32 grid, const char *img_name, comp_coder_t comp_type, /* Compression method */ | ||
comp_info *cinfo, char *message) /* Compression parameters */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making img_name const quiets a bunch of warnings
@@ -134,7 +134,7 @@ test_szip_RI8bit() | |||
/********************** End of variable declaration **********************/ | |||
|
|||
HCget_config_info(COMP_CODE_SZIP, &comp_config); | |||
CHECK_VOID((comp_config & COMP_DECODER_ENABLED | COMP_ENCODER_ENABLED), 0, | |||
CHECK_VOID(((comp_config & COMP_DECODER_ENABLED) && (comp_config & COMP_ENCODER_ENABLED)), 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we want both flags set
dimindex = var->assoc->values[i]; | ||
dim = SDIget_dim(handle, dimindex); | ||
if (dim == NULL) | ||
HGOTO_ERROR(DFE_ARGS, FAIL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes a potential NULL pointer dereference
case LANG_NONE: | ||
default: | ||
/* Might want to make this an error */ | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes complaints about unhandled cases
@@ -141,7 +141,7 @@ test_1dim_singlevar() | |||
long start[] = {0}; | |||
long edges[1]; | |||
edges[0] = dimsize; | |||
memset(outdata, 0, DIM0); | |||
memset(outdata, 0, DIM0 * sizeof(short)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memset was only cleaning half the bytes
@@ -615,7 +615,7 @@ test_1dim_multivars() | |||
} | |||
} /* end read data */ | |||
|
|||
#if NOTRUN | |||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be either ifdef NOTRUN or if 0. I went with the latter.