linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* In regard of commit "gudev: Use strtoul to parse unsigned 64-bit
@ 2011-10-31 20:13 Rafał Mużyło
  2011-10-31 20:32 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers" David Zeuthen
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Rafał Mużyło @ 2011-10-31 20:13 UTC (permalink / raw)
  To: linux-hotplug

Perhaps I'm simply misreading something, but won't going from strtoll to
strtoul break things for 32bit case ?

I do understand, that 32bit is becoming less and less supported every
day (given i.e. "daemon.c:1351:33: warning: cast to pointer from integer
of different size" warning during udisks 1.0.4 build - bug 24983), but
should it be broken on purpose ?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers"
  2011-10-31 20:13 In regard of commit "gudev: Use strtoul to parse unsigned 64-bit Rafał Mużyło
@ 2011-10-31 20:32 ` David Zeuthen
  2011-10-31 20:44 ` David Zeuthen
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Zeuthen @ 2011-10-31 20:32 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Oct 31, 2011 at 4:13 PM, Rafał Mużyło <galtgendo@gmail.com> wrote:
> Perhaps I'm simply misreading something, but won't going from strtoll to
> strtoul break things for 32bit case ?

What do you think it would break? Or are you perhaps suggesting we
should be using strtoull() instead? Please be specific.


     David

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers"
  2011-10-31 20:13 In regard of commit "gudev: Use strtoul to parse unsigned 64-bit Rafał Mużyło
  2011-10-31 20:32 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers" David Zeuthen
@ 2011-10-31 20:44 ` David Zeuthen
  2011-10-31 21:04 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit Rafał Mużyło
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Zeuthen @ 2011-10-31 20:44 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 675 bytes --]

Hi,

I looked more into this and we should probably just use
g_ascii_strtoull() since that function always returns a guint64 no
matter whether you are on 32- or 64-bit. The attached patch does this.
Kay: please apply.

Thanks,
David

On Mon, Oct 31, 2011 at 4:32 PM, David Zeuthen <zeuthen@gmail.com> wrote:
> On Mon, Oct 31, 2011 at 4:13 PM, Rafał Mużyło <galtgendo@gmail.com> wrote:
>> Perhaps I'm simply misreading something, but won't going from strtoll to
>> strtoul break things for 32bit case ?
>
> What do you think it would break? Or are you perhaps suggesting we
> should be using strtoull() instead? Please be specific.
>
>
>     David
>

[-- Attachment #2: 0001-gudev-Use-g_ascii_strtoull-instead-of-strtoul.patch --]
[-- Type: text/x-patch, Size: 1770 bytes --]

From 2a64773ac80432ca70aa747b55cfaadf3f8c55cb Mon Sep 17 00:00:00 2001
From: David Zeuthen <davidz@redhat.com>
Date: Mon, 31 Oct 2011 16:38:14 -0400
Subject: [PATCH] gudev: Use g_ascii_strtoull() instead of strtoul()

This ensures that we get the same behavior on both 32- and
64-bit. Pointed out on the mailing list:

 http://permalink.gmane.org/gmane.linux.hotplug.devel/17145

Signed-off-by: David Zeuthen <davidz@redhat.com>
---
 extras/gudev/gudevdevice.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/extras/gudev/gudevdevice.c b/extras/gudev/gudevdevice.c
index e77b34b..38d602c 100644
--- a/extras/gudev/gudevdevice.c
+++ b/extras/gudev/gudevdevice.c
@@ -538,7 +538,7 @@ out:
  * @key: Name of property.
  *
  * Look up the value for @key on @device and convert it to an unsigned
- * 64-bit integer using strtoul().
+ * 64-bit integer using g_ascii_strtoull().
  *
  * Returns: The value  for @key or 0 if @key doesn't  exist or isn't a
  * #guint64.
@@ -558,7 +558,7 @@ g_udev_device_get_property_as_uint64 (GUdevDevice  *device,
   if (s == NULL)
     goto out;
 
-  result = strtoul (s, NULL, 0);
+  result = g_ascii_strtoull (s, NULL, 0);
 out:
   return result;
 }
@@ -756,7 +756,7 @@ out:
  * @name: Name of the sysfs attribute.
  *
  * Look up the sysfs attribute with @name on @device and convert it to an unsigned
- * 64-bit integer using strtoul().
+ * 64-bit integer using g_ascii_strtoull().
  *
  * Returns: The value of the sysfs attribute or 0 if there is no such
  * attribute.
@@ -776,7 +776,7 @@ g_udev_device_get_sysfs_attr_as_uint64 (GUdevDevice  *device,
   if (s == NULL)
     goto out;
 
-  result = strtoul (s, NULL, 0);
+  result = g_ascii_strtoull (s, NULL, 0);
 out:
   return result;
 }
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: In regard of commit "gudev: Use strtoul to parse unsigned 64-bit
  2011-10-31 20:13 In regard of commit "gudev: Use strtoul to parse unsigned 64-bit Rafał Mużyło
  2011-10-31 20:32 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers" David Zeuthen
  2011-10-31 20:44 ` David Zeuthen
@ 2011-10-31 21:04 ` Rafał Mużyło
  2011-10-31 21:18 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers" David Zeuthen
  2011-10-31 21:22 ` Kay Sievers
  4 siblings, 0 replies; 6+ messages in thread
From: Rafał Mużyło @ 2011-10-31 21:04 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Oct 31, 2011 at 04:32:07PM -0400, David Zeuthen wrote:
> On Mon, Oct 31, 2011 at 4:13 PM, Rafał Mużyło <galtgendo@gmail.com> wrote:
> > Perhaps I'm simply misreading something, but won't going from strtoll to
> > strtoul break things for 32bit case ?
> 
> What do you think it would break? Or are you perhaps suggesting we
> should be using strtoull() instead? Please be specific.
>
Well, given on what happens on strtoul overflow according to the
manpage...

But, as you're the main author of udisks, would you mind looking at the
bug I've mentioned ?
Perhaps it doesn't matter there, but it would be good to do something
about the warnings.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers"
  2011-10-31 20:13 In regard of commit "gudev: Use strtoul to parse unsigned 64-bit Rafał Mużyło
                   ` (2 preceding siblings ...)
  2011-10-31 21:04 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit Rafał Mużyło
@ 2011-10-31 21:18 ` David Zeuthen
  2011-10-31 21:22 ` Kay Sievers
  4 siblings, 0 replies; 6+ messages in thread
From: David Zeuthen @ 2011-10-31 21:18 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Oct 31, 2011 at 5:04 PM, Rafał Mużyło <galtgendo@gmail.com> wrote:
> On Mon, Oct 31, 2011 at 04:32:07PM -0400, David Zeuthen wrote:
>> On Mon, Oct 31, 2011 at 4:13 PM, Rafał Mużyło <galtgendo@gmail.com> wrote:
>> > Perhaps I'm simply misreading something, but won't going from strtoll to
>> > strtoul break things for 32bit case ?
>>
>> What do you think it would break? Or are you perhaps suggesting we
>> should be using strtoull() instead? Please be specific.
>>
> Well, given on what happens on strtoul overflow according to the
> manpage...

Well, the problem was simply that I just missed an 'l' in the initial
patch and that mistake breaks 32-bit as you tried to point out. The
patch I just sent fixes the problem. Sigh, this is what happens when
people try to make their function names as short as possible... never
a good idea.

    David

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers"
  2011-10-31 20:13 In regard of commit "gudev: Use strtoul to parse unsigned 64-bit Rafał Mużyło
                   ` (3 preceding siblings ...)
  2011-10-31 21:18 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers" David Zeuthen
@ 2011-10-31 21:22 ` Kay Sievers
  4 siblings, 0 replies; 6+ messages in thread
From: Kay Sievers @ 2011-10-31 21:22 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Oct 31, 2011 at 21:44, David Zeuthen <zeuthen@gmail.com> wrote:
> I looked more into this and we should probably just use
> g_ascii_strtoull() since that function always returns a guint64 no
> matter whether you are on 32- or 64-bit. The attached patch does this.
> Kay: please apply.

Done.

Thanks,
Kay

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-10-31 21:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-31 20:13 In regard of commit "gudev: Use strtoul to parse unsigned 64-bit Rafał Mużyło
2011-10-31 20:32 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers" David Zeuthen
2011-10-31 20:44 ` David Zeuthen
2011-10-31 21:04 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit Rafał Mużyło
2011-10-31 21:18 ` In regard of commit "gudev: Use strtoul to parse unsigned 64-bit integers" David Zeuthen
2011-10-31 21:22 ` Kay Sievers

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).