Re: [reiserfs-dev] Re: [PATCH] sparc32: wrong type of nlink_t

From: Thunder from the hill (thunder@lightweight.ods.org)
Date: Wed Sep 04 2002 - 16:44:26 EST


Hi,

On Wed, 4 Sep 2002, Tomas Szepe wrote:
> typedef unsigned long long u64;
>
> /* usable for char, short int, and int */
> #define set_to_max(a) \
> { \
> u64 max = ((u64) 2 << (sizeof(a) * 8 - 1)) - 1; \
> a = max; if ((u64) a != max) a = max / 2; \
> }

To make it more secure, we should consider the following version:

typedef unsigned long long u64;

/* usable for char, short int, and int */
#define set_to_max(a) { \
        u64 __val_max = ((u64) 1 << (sizeof(a) * 8)) - 1; \
        a = __val_max; \
        if ((u64) a != __val_max) \
                a = __val_max / 2; \
}

So it's basically naming.

                        Thunder

-- 
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Sep 07 2002 - 22:00:23 EST