against my const-obsessive and error-code obsessive
instincts. None of these changes were the result of
behavioral program bugs, but are fixes to *minorly*
incorrect code, so that it compiles cleanly.
I've fixed 2 types of warnings that I noticed when I went
and built i7z from source:
1. Format string warnings like:
```
i7z.c:187:34: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘__time_t {aka long int}’ [-Wformat=]
fprintf(fp_log_file_freq,"%d.%.9d\n",value->tv_sec,value->tv_nsec); //n
^
i7z.c:187:34: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘__syscall_slong_t {aka long int}’ [-Wformat=]
```
...where the string specified a basic signed integer with `%d`,
and instead the underlying type was `long int`. I fixed this by
simply changing the format string to `%ld`.
2. Ignored return values, like:
```
helper_functions.c: In function ‘cpufreq_info’:
helper_functions.c:551:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
system
^
helper_functions.c:559:5: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
fgets (tmp_str, 30, tmp_file);
```
...where the function returns an error code that library authors
thought was important to not ignore. For both the `system`
function calls and the `fgets` function calls, I simply log
failure to `stderr` - nothing to fancy or aggressive (like `abort()`).
For the `system` function calls, I tried not to be *too* generic,
and only paid attention to error codes from calls that i7z
*actually* executes, and mention them in a comment.
For `fgets`, I've zero-initialized the output buffer, so that an
`fgets` failure will not result in `atof` reading junk.
I made three other types of small changes:
1. Zero-initializing a few variables that are passed to library
functions. I did this instead of checking return values (or both)
to reduce code churn. This wasn't the result of a warning, but I
did it anyways.
2. Changing a few of the cstring handling functions to their
semi-bounds checked versions. Since we don't have C11 Annex K,
*(thanks Ulrich Drepper!)* I had to use `snprintf` instead of
`sprintf_s` (or `snprintf_s`) - which is practically equivalent.
This is the only behavioral change, and even then it should not
actually change behavior unleess i7z was overrunning a buffer
somewhere as-is. Look carefully at this part please?
I also *considered* changing array arguments with compile-time sizes
as `[static 10]` (where 10 is the array's size) instead of an
unsized pointer. In the cases where I considered this, it's more
expressive, and the compiler would've generated an error if too
small a buffer was passed. This would be simpler (and more
reliable without annotations) than a separate size argument.
Lastly, I put some `FIXME:`s in where the compiler generated
warnings with `-Wall -Wpedantic`. I havent modified the makefile
in this patch, I just did it to test my changes.