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 misc gcc warnings #570

Merged
merged 1 commit into from
Feb 20, 2024
Merged

Conversation

derobins
Copy link
Member

  • 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
@derobins derobins added Component - C Library Core C library issues Component - Testing Test code, GitHub workflows Type - Improvement Improvements that don't add a new feature or functionality Priority - 2. Medium ⏹ It would be nice to have this in the next release labels Feb 20, 2024
@@ -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
Copy link
Member Author

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"};
Copy link
Member Author

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);
Copy link
Member Author

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 */
Copy link
Member Author

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,
Copy link
Member Author

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);
Copy link
Member Author

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;
Copy link
Member Author

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));
Copy link
Member Author

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
Copy link
Member Author

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.

@derobins derobins merged commit ed45b86 into HDFGroup:master Feb 20, 2024
38 checks passed
@derobins derobins deleted the feb_20_warning_fixes branch March 3, 2024 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - C Library Core C library issues Component - Testing Test code, GitHub workflows Priority - 2. Medium ⏹ It would be nice to have this in the next release Type - Improvement Improvements that don't add a new feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants