Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Sep 2009 04:30:17 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Rui Paulo <rpaulo@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r197195 - head/sys/dev/asmc
Message-ID:  <20090915040529.J6194@delplex.bde.org>
In-Reply-To: <200909141616.n8EGG8r3059684@svn.freebsd.org>
References:  <200909141616.n8EGG8r3059684@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 14 Sep 2009, Rui Paulo wrote:

> Log:
>  Fix previous commit. I got it backwards.

It is still unfixed.

>  MFC after:	1 week
>
> Modified:
>  head/sys/dev/asmc/asmc.c
>
> Modified: head/sys/dev/asmc/asmc.c
> ==============================================================================
> --- head/sys/dev/asmc/asmc.c	Mon Sep 14 16:13:12 2009	(r197194)
> +++ head/sys/dev/asmc/asmc.c	Mon Sep 14 16:16:07 2009	(r197195)
> @@ -824,7 +824,7 @@ out:
> 		type[5] = 0;
> 		if (maxlen > sizeof(v)) {
> 			device_printf(dev, "WARNING: cropping maxlen "
> -			    "from %u to %u\n", maxlen, sizeof(v));
> +			    "from %u to %lu\n", maxlen, sizeof(v));
> 			maxlen = sizeof(v);
> 		}

This printf has the following errors:

Fatal printf format error: values of type size_t should be printed
using %zu, but here sizeof(v) is printed using %lu.  Printing it using
%u would be fatal on different systems.

Non-fatal printf format error: maxlen has type uint8_t, so its default
promotion is int, and this should be printed using %d like it was 2
commits ago.  %u will work since the value is representable using both
int and u_int, but this is not easy to see (in fact, I can't see it
in C99 -- I can only see where C99 requires va_arg(ap, u_int) to work
on a u_int).

Format-printf error (style bug).  The message is obfuscated using C90
string concatenation.

Fixed version:

 			device_printf(dev,
 			    "WARNING: cropping maxlen from %d to %zu\n",
 			    maxlen, sizeof(v));

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090915040529.J6194>