jhammond / xltop

continuous Lustre load monitor
GNU General Public License v2.0
21 stars 7 forks source link

GCC 4.9 throws an error over argument to ‘sizeof’ in a memset function call #4

Closed mtds closed 8 years ago

mtds commented 8 years ago

Hello.

As stated by the subject I have stumbled again into a GCC error, this time with version 4.9 on Debian Jessie.

The exact error message is the following:

curl_x.c:13:23: error: argument to 'sizeof' in 'memset' call is the same expression as 
the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]

GCC complains about the following memset call (from the curl_x_destroy function in curl_x.c):

memset(cx, 0, sizeof(cx));

According to this document: https://gcc.gnu.org/gcc-4.8/porting_to.html (section: 'New warnings for pointer access') it should be turned into this:

memset(cx, 0, sizeof(*cx));

where the 'cx' (pointer to a struct of type curl_x) is explicitely dereferenced.

With the aforementioned fix the compilation goes ahead.

Best regards, Matteo

jhammond commented 8 years ago

Yep. Would you like to submit a PR?

mtds commented 8 years ago

Sure, I have just submitted it.

jhammond commented 8 years ago

Merged. Thanks!