netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: matheos.worku@sun.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 1/2] [NIU] Determine the # of ports from the card's VPD data.
Date: Wed, 23 Apr 2008 18:28:48 -0700 (PDT)	[thread overview]
Message-ID: <20080423.182848.74720455.davem@davemloft.net> (raw)
In-Reply-To: <200804231811.m3NIBhQl043628@sr1-umpk-33.sfbay.sun.com>

From: Matheos Worku <matheos.worku@sun.com>
Date: Wed, 23 Apr 2008 10:10:52 -0700

> +#define NIU_BMD_MATCHES(np, md_str) \
> +  (!strncmp(np->vpd.board_model, md_str, strlen(md_str)))

Why is this special construct necessary?  How can anyone tell the
reason this is needed by reading this code?

Plain ole' strcmp() should suffice.  If the string length is
different, we should get a comparison failure.  We've also made sure
that the board_model[] field is a properly null terminated string.

Is the issue that there could be some spurious trailing characters in
the board_model[] string that we'd like to ignore?

If that's the case this comparison deserves it's own small function,
with some descriptive text, rather than an ugly and undescriptive
macro.

Something like:

/* Board model strings can have trailing characters we wish
 * to ignore during comparison, for example:
 *
 *	XXXX (add example(s) here) XXX
 */
static int niu_board_model_compare(struct niu *np, const char *model)
{
	return strncmp(np->vpd.board_model, model, strlen(model));
}

Thanks.

       reply	other threads:[~2008-04-24  1:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200804231811.m3NIBhQl043628@sr1-umpk-33.sfbay.sun.com>
2008-04-24  1:28 ` David Miller [this message]
2008-04-24 19:44   ` [PATCH 1/2] [NIU] Determine the # of ports from the card's VPD data Matheos Worku
2008-04-25  4:03     ` David Miller
2008-04-23 18:15 Matheos Worku

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=20080423.182848.74720455.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=matheos.worku@sun.com \
    --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).