LLNL / GOTCHA

GOTCHA is a library for wrapping function calls in shared libraries
https://gotcha.readthedocs.io/en/latest/
Other
71 stars 21 forks source link

Initialize all function-level variables #159

Open TomTheBear opened 2 months ago

TomTheBear commented 2 months ago

Removes some compiler warnings

hariharan-devarajan commented 1 month ago

Removes some compiler warnings

Thanks for the PR. Can you please add to the description the OS and compiler on which u get the warning.

hariharan-devarajan commented 1 month ago

Also, Can u check the formatting error.

TomTheBear commented 1 month ago

It's an Ubuntu 22.04 system with GCC 11.4.0 but I use a custom Makefile. My cmake knowledge is so limited, I cannot even add -Wall to the configuration.

It is basically just a single compiler warning:

/home/unrz139/Work/GOTCHA.orig/src/libc_wrappers.c: In function ‘gotcha_malloc’:
/home/unrz139/Work/GOTCHA.orig/src/libc_wrappers.c:72:41: warning: ‘best_fit_diff’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   72 |     if (diff >= 0 && (!best_fit || diff < best_fit_diff)) {
      |                                    ~~~~~^~~~~~~~~~~~~~~

But after I started, I checked all occurrences of variables that are not initialized in the beginning of a function. Most of them are set later and do not cause warnings. Makefile.txt