All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH 4/6] libsensors4: Use strtoul
Date: Thu, 16 Aug 2007 08:02:05 +0000	[thread overview]
Message-ID: <20070816100205.7aaf7724@hyperion.delvare> (raw)
In-Reply-To: <20070815174240.34ddf040@hyperion>

Hi Hans,

On Wed, 15 Aug 2007 18:59:25 +0200, Hans de Goede wrote:
> Jean Delvare wrote:
> > Use strtoul() instead of parsing integers on our own.
> 
> Erm, why all the < 0 checks on the return value of strtoul, are the variable in 
> which the return value gets stored signed and can we have a wrap?

Yes, this is the reason why I added these "< 0" checks.

> In that case wouldn't it be better to first store in an unsigned long and then 
> explicitly check the limits we want to enforce?

There's no specific limit I want to enforce, I only want to make sure
that we don't end up with a negative value due to a possible wrap. This
is pure paranoia, BTW, no sane user would ever trigger it. I agree that
letting the overflow happen and checking for it afterwards isn't very
elegant, but it works and it is efficient, so I am a bit reluctant to
make the code more complex than it needs be.

I could probably use strtol instead of strtoul if you prefer, though.

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2007-08-16  8:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-15 15:42 [lm-sensors] [PATCH 4/6] libsensors4: Use strtoul Jean Delvare
2007-08-15 16:59 ` Hans de Goede
2007-08-16  8:02 ` Jean Delvare [this message]
2007-08-16  8:42 ` Hans de Goede

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=20070816100205.7aaf7724@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=lm-sensors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.