-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Use local variable in btree2 and print value #4679
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2302,8 +2302,8 @@ main(void) | |
/* Reset library */ | ||
h5_test_init(); | ||
fapl = h5_fileaccess(); | ||
if (TestExpress > 1) | ||
printf("***Express test mode on. Some tests may be skipped\n"); | ||
if (TestExpress > 0) | ||
printf("***Express test mode %d. Some tests may be skipped\n", TestExpress); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to explicitly specify the type of printf value parameters (int here) because there is absolutely no type checking, and a change in the global variable type could cause hard to track down errors. The LocalTestExpress ones aren't as bad since that variable is declared in the function but it wouldn't hurt to add it there too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what you want here, since the variable is just an int? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cast LocalTestExpress to an int: "LocalTestExpress" => "(int)LocalTestExpress" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like a bad idea to cast something that doesn't really need casting since it'll just hide future possible errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the type of the variable ever changes it can produce memory errors. Modern compilers might be able to detect and throw a warning in this case (if the type doesn't match the format string), I'm not sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want the compiler to report the issue and not cover it up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not certain the compiler will report an issue if there's no cast. And it is much more unsafe to pass the wrong type to printf than to cast something to the right type - the only potential problem there is wrap around. printf looks at the format string and reads that many bytes from the input parameters, it does not check if enough data was passed in the parameters, so if the types don't match exactly it's possible for printf to read past the end of the input parameters which is a memory error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like gcc does not warn by default but does if -Wformat is on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we have Wformat on by default for GCC and most of the other compilers. My main concern is that casting to int can hide other problems if the variable ever does change to something else, but it seems unlikely that it will at this point. Absolutely not an important issue though; either way is fine. |
||
|
||
/* Set the filename to use for this test (dependent on fapl) */ | ||
h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g)); | ||
|
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.
Why the change from 1 to 0 here? All the other places in this PR use 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.
Technically, level one could skip tests. The other uses actually skip tests if level 2 or 3.
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 other files.