netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: davem@davemloft.net, bhutchings@solarflare.com, netdev@vger.kernel.org
Subject: Re: [PATCH v2 5/5] alx: add stats to ethtool
Date: Mon, 6 Jan 2014 15:56:29 +0100	[thread overview]
Message-ID: <20140106145629.GA7886@kria> (raw)
In-Reply-To: <1389017496.5891.15.camel@jlt4.sipsolutions.net>

2014-01-06, 15:11:36 +0100, Johannes Berg wrote:
> On Mon, 2014-01-06 at 11:57 +0100, Sabrina Dubroca wrote:
> > [2014-01-06, 10:03:10] Johannes Berg wrote:
> > > On Sat, 2014-01-04 at 17:47 +0100, Sabrina Dubroca wrote:
> > > 
> > > > +	__alx_update_hw_stats(hw);
> > > > +	BUILD_BUG_ON(sizeof(hw->stats) - offsetof(struct alx_hw_stats, rx_ok) <
> > > > +		     ALX_NUM_STATS * sizeof(u64));
> > > 
> > > I think you should make that != instead of <, otherwise you won't catch
> > > all possible differences.
> > 
> > With a !=, BUILD_BUG_ON is triggered if a new field is added at the
> > end of the structure. 
> 
> That seems reasonable, you'd want to export that field as well? Fields
> that shouldn't be exported could be added before rx_ok.

I don't have anything else to add here, I'm just considering what
others might want to do. Maybe overthinking. But, yeah, that's the idea.
(and fields added to the end of the struct but that don't have a
description in alx_gstrings_stats are ignored)

> > But adding a field doesn't break the code,
> > though I'm not sure allowing this is useful. The offsetof (and the
> > source in memcpy) also allows to add new fields at the beginning.
> > 
> > And the way alx_update_hw_stats is written already includes a kind of
> > check that all fields are present.
> 
> I was more worried about type mismatches. That's not really a concern
> with u64 since that's the largest type that really makes sense here, but
> if the type of some variables changed vs. the ethtool type u64...

Add "all stats fields must be u64" to the comment before the struct?


> Maybe I'm overly worried. It seems likely nobody will ever touch this
> code again :)

:)

-- 
Sabrina

  reply	other threads:[~2014-01-06 14:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-04 16:47 [PATCH v2 0/5] alx: add statistics Sabrina Dubroca
2014-01-04 16:47 ` [PATCH v2 1/5] alx: add a hardware stats structure Sabrina Dubroca
2014-01-04 16:47 ` [PATCH v2 2/5] alx: add constants for the stats fields Sabrina Dubroca
2014-01-04 16:47 ` [PATCH v2 3/5] alx: add stats update function Sabrina Dubroca
2014-01-04 22:16   ` Stephen Hemminger
2014-01-04 23:16     ` Sabrina Dubroca
2014-01-04 16:47 ` [PATCH v2 4/5] alx: add alx_get_stats64 operation Sabrina Dubroca
2014-01-04 16:47 ` [PATCH v2 5/5] alx: add stats to ethtool Sabrina Dubroca
2014-01-06  9:03   ` Johannes Berg
2014-01-06 10:57     ` Sabrina Dubroca
2014-01-06 14:11       ` Johannes Berg
2014-01-06 14:56         ` Sabrina Dubroca [this message]
2014-01-06 15:16           ` Johannes Berg

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=20140106145629.GA7886@kria \
    --to=sd@queasysnail.net \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=johannes@sipsolutions.net \
    --cc=netdev@vger.kernel.org \
    /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).