Re: [PATCH 1/3] build: Disable some warnings from GCC 8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marce,

On Wednesday, 9 May 2018 14:26:36 CEST Marcel Holtmann wrote:
> Hi Szymon,
> 
> > GCC 8 -Wall -Wextra seem to enable additional checks. Those generates
> > lots of spourious warnings so disable them (at least for time being).
> > ---
> > acinclude.m4 | 3 +++
> > 1 file changed, 3 insertions(+)
> > 
> > diff --git a/acinclude.m4 b/acinclude.m4
> > index bc39c6d73..39a6be44a 100644
> > --- a/acinclude.m4
> > +++ b/acinclude.m4
> > @@ -16,6 +16,9 @@ AC_DEFUN([COMPILER_FLAGS], [
> > 
> > 		with_cflags="$with_cflags -Wall -Werror -Wextra"
> > 		with_cflags="$with_cflags -Wno-unused-parameter"
> > 		with_cflags="$with_cflags -Wno-missing-field-initializers"
> > 
> > +		with_cflags="$with_cflags -Wno-format-truncation"
> > +		with_cflags="$with_cflags -Wno-cast-function-type"
> > +		with_cflags="$with_cflags -Wno-stringop-truncation”
> 
> can you explain these with examples on why we would disable them.

-Wformat-truncation

Than one warns when snprintf could be truncated:
eg 
char a[10];
char b[10];
char c[15];
..
snprintf(c, sizeof(c), "%s%s", a, b);

This sometimes triggers warning also with "sizeof(c) - 1" when c is either 
memset before or last byte being explicitly set to '\0' after snprintf.

Also, sometimes we are fine if resulting string is left unterminated eg
when filling in mgmt commands or struct sockaddr with paths and/or names.
Some could be change to memcpy + strlen (possibly after getting min size from 
both buffers) or we could adjust buffers to make those go away.



-Wstringop-truncation
This is pretty match the same as above but for strncpy and family.
Also here, some could be change to memcpy + strlen. Or even better don't use 
strncpy at all and have own implementation of strlcpy.



-Wcast-function-type
Warn when a function pointer is cast to an incompatible function pointer.
We often cast function pointers with g_slist_foreach or queue call to avoid
need for having wrappers. This seems to be fine as along as casted function
doesn't expect more parameters than type it is casted to. To fix those we 
would have to always wrap eg:

+static void update_adapter_cb(gpointer data,  gpointer user_data)
+{
+	struct hdp_adapter *hdp_adapter = data;
+
+	update_adapter(hdp_adapter);
+}
+
 static void remove_application(struct hdp_application *app)
 {
 	DBG("Application %s deleted", app->path);
 	hdp_application_unref(app);
 
-	g_slist_foreach(adapters, (GFunc) update_adapter, NULL);
+	g_slist_foreach(adapters, update_adapter_cb, NULL);
 }



-- 
pozdrawiam
Szymon Janc


--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux