From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH 4/6] libsensors4: Use strtoul
Date: Thu, 16 Aug 2007 08:42:52 +0000 [thread overview]
Message-ID: <46C40E0C.8060901@hhs.nl> (raw)
In-Reply-To: <20070815174240.34ddf040@hyperion>
Jean Delvare wrote:
> 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.
>
No its fine as is then.
Regards,
Hans
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
prev parent reply other threads:[~2007-08-16 8:42 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
2007-08-16 8:42 ` Hans de Goede [this message]
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=46C40E0C.8060901@hhs.nl \
--to=j.w.r.degoede@hhs.nl \
--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.