[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080423.182848.74720455.davem@davemloft.net>
Date: Wed, 23 Apr 2008 18:28:48 -0700 (PDT)
From: David Miller <davem@...emloft.net>
To: matheos.worku@....com
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH 1/2] [NIU] Determine the # of ports from the card's VPD
data.
From: Matheos Worku <matheos.worku@....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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists