Re: [systemd-devel] [PATCH] shared/util.h: portable sizeof(long) == sizeof(int) test

2014-09-22 Thread David Herrmann
Hi

On Fri, Sep 19, 2014 at 10:56 PM, Emil Renner Berthing syst...@esmil.dk wrote:
 On 19 September 2014 22:19, David Herrmann dh.herrm...@gmail.com wrote:
 On Fri, Sep 19, 2014 at 8:26 PM, Emil Renner Berthing syst...@esmil.dk 
 wrote:
 Don't rely on __WORDSIZE, but just standard LONG_MAX
 and INT_MAX from limits.h.

 Why? The commit message lacks any explanation of that change.

 Ah, sorry. This is a better version of the [RFC 5/25] patch I sent earlier.
 The point is that __WORDSIZE is not portable, but both
 LONG_MAX and INT_MAX are mandated in limits.h.

 I can resend with this explanation in the commit message if you want.

I rewrote the commit-message and pushed the fix.

Thanks
David
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] shared/util.h: portable sizeof(long) == sizeof(int) test

2014-09-19 Thread Emil Renner Berthing
Don't rely on __WORDSIZE, but just standard LONG_MAX
and INT_MAX from limits.h.
---
 src/shared/util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/util.h b/src/shared/util.h
index 08d556f..00068c6 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -205,7 +205,7 @@ int safe_atod(const char *s, double *ret_d);
 
 int safe_atou8(const char *s, uint8_t *ret);
 
-#if __WORDSIZE == 32
+#if LONG_MAX == INT_MAX
 static inline int safe_atolu(const char *s, unsigned long *ret_u) {
 assert_cc(sizeof(unsigned long) == sizeof(unsigned));
 return safe_atou(s, (unsigned*) ret_u);
-- 
2.1.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] shared/util.h: portable sizeof(long) == sizeof(int) test

2014-09-19 Thread David Herrmann
Hi

On Fri, Sep 19, 2014 at 8:26 PM, Emil Renner Berthing syst...@esmil.dk wrote:
 Don't rely on __WORDSIZE, but just standard LONG_MAX
 and INT_MAX from limits.h.

Why? The commit message lacks any explanation of that change.

Thanks
David

 ---
  src/shared/util.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/shared/util.h b/src/shared/util.h
 index 08d556f..00068c6 100644
 --- a/src/shared/util.h
 +++ b/src/shared/util.h
 @@ -205,7 +205,7 @@ int safe_atod(const char *s, double *ret_d);

  int safe_atou8(const char *s, uint8_t *ret);

 -#if __WORDSIZE == 32
 +#if LONG_MAX == INT_MAX
  static inline int safe_atolu(const char *s, unsigned long *ret_u) {
  assert_cc(sizeof(unsigned long) == sizeof(unsigned));
  return safe_atou(s, (unsigned*) ret_u);
 --
 2.1.0

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] shared/util.h: portable sizeof(long) == sizeof(int) test

2014-09-19 Thread Emil Renner Berthing
On 19 September 2014 22:19, David Herrmann dh.herrm...@gmail.com wrote:
 On Fri, Sep 19, 2014 at 8:26 PM, Emil Renner Berthing syst...@esmil.dk 
 wrote:
 Don't rely on __WORDSIZE, but just standard LONG_MAX
 and INT_MAX from limits.h.

 Why? The commit message lacks any explanation of that change.

Ah, sorry. This is a better version of the [RFC 5/25] patch I sent earlier.
The point is that __WORDSIZE is not portable, but both
LONG_MAX and INT_MAX are mandated in limits.h.

I can resend with this explanation in the commit message if you want.

/Emil
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel