From: Ben Hutchings <ben@decadent.org.uk>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: netdev <netdev@vger.kernel.org>, Aurelien Guillaume <aurelien@iwi.me>
Subject: [PATCH ethtool] Fix iteration count in sff8472_calibration()
Date: Sun, 22 Sep 2013 02:36:42 +0100 [thread overview]
Message-ID: <1379813802.21174.36.camel@deadeye.wl.decadent.org.uk> (raw)
[-- Attachment #1: Type: text/plain, Size: 962 bytes --]
We want to iterate over all elements of the various arrays of readings
(which all have the same dimensions - and maybe ought to be a single
array). Unfortunately the iteration count is sizeof(sd->bias_cur) and
bias_cur has 2-byte elements, so we iterate over twice as many
elements as are really there.
Compiler-detected, and compile-tested only.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
sfpdiag.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sfpdiag.c b/sfpdiag.c
index f67e491..04fd880 100644
--- a/sfpdiag.c
+++ b/sfpdiag.c
@@ -224,7 +224,7 @@ static void sff8472_calibration(const __u8 *id, struct sff8472_diags *sd)
__u16 rx_reading;
/* Calibration should occur for all values (threshold and current) */
- for (i = 0; i < sizeof(sd->bias_cur); ++i) {
+ for (i = 0; i < ARRAY_SIZE(sd->bias_cur); ++i) {
/*
* Apply calibration formula 1 (Temp., Voltage, Bias, Tx Power)
*/
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next reply other threads:[~2013-09-22 1:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-22 1:36 Ben Hutchings [this message]
2013-11-08 16:54 ` [PATCH ethtool] Fix iteration count in sff8472_calibration() 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=1379813802.21174.36.camel@deadeye.wl.decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=aurelien@iwi.me \
--cc=bhutchings@solarflare.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