netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: bhutchings@solarflare.com
Cc: shemminger@vyatta.com, arnd@arndb.de, netdev@vger.kernel.org,
	linux-net-drivers@solarflare.com
Subject: Re: [PATCHv2 1/2] net: Enable 64-bit net device statistics on 32-bit architectures
Date: Mon, 07 Jun 2010 21:18:29 -0700 (PDT)	[thread overview]
Message-ID: <20100607.211829.63035366.davem@davemloft.net> (raw)
In-Reply-To: <1275689093.2095.36.camel@achroite.uk.solarflarecom.com>

From: Ben Hutchings <bhutchings@solarflare.com>
Date: Fri, 04 Jun 2010 23:04:53 +0100

> +#if BITS_PER_LONG == 64
> +#define NET_DEVICE_STATS_DEFINE(name)	u64 name
> +#elif defined(__LITTLE_ENDIAN)
> +#define NET_DEVICE_STATS_DEFINE(name)	u32 name, pad_ ## name
> +#else
> +#define NET_DEVICE_STATS_DEFINE(name)	u32 pad_ ## name, name
> +#endif
> +
 ...
> +	NET_DEVICE_STATS_DEFINE(rx_packets);
> +	NET_DEVICE_STATS_DEFINE(tx_packets);
> +	NET_DEVICE_STATS_DEFINE(rx_bytes);
 ...
>  	static const char fmt[] = "%30s %12lu\n";
> +	static const char fmt64[] = "%30s %12llu\n";
 ...
> +	seq_printf(seq, fmt64, "total frames received", stats->rx_packets);
> +	seq_printf(seq, fmt64, "total bytes received", stats->rx_bytes);
> +	seq_printf(seq, fmt64, "Broadcast/Multicast Rcvd", stats->multicast);

I guess you only built this on a 64-bit platform that defines u64 as a
long long type.

The rest of the world will receive tons of warnings for these print
statements.

You have basically 3 cases to handle:

1) u64 defined as "unsigned long long"

2) u64 defined as "unsigned long"

3) u32 defined as "unsigned int"

And the whole tree needs to be inspected to make sure there isn't going
to be fallout in areas your patch didn't take care of wrt. printf format
strings and the like.

What was always "unsigned long" is now a variable type, therefore using
a fixed printf format string is impossible unless you always cast these
things when passed in as printf arguments.


  parent reply	other threads:[~2010-06-08  4:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-04 22:04 [PATCHv2 1/2] net: Enable 64-bit net device statistics on 32-bit architectures Ben Hutchings
2010-06-04 22:06 ` [PATCHv2 2/2] sfc: Implement 64-bit net device statistics on all architectures Ben Hutchings
2010-06-08  4:18 ` David Miller [this message]
2010-06-08 11:35   ` [PATCHv2 1/2] net: Enable 64-bit net device statistics on 32-bit architectures Ben Hutchings
2010-06-08 15:56     ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100607.211829.63035366.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=arnd@arndb.de \
    --cc=bhutchings@solarflare.com \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).