[liboobs] Improve computing of max [UG]ID, and move to G_MAXUINT32



commit b4e353886d721c0a59e73fcd4d6b32ea3d38e418
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Tue Dec 22 19:01:58 2009 +0100

    Improve computing of max [UG]ID, and move to G_MAXUINT32
    
    Use << instead of pow(). The latter is computed at compile time by gcc, but using the second is cleaner anyway.
    
    Now that the System Tools Backends use and unsigned 32 bits integer, we can raise the limit, which should be enough for all known platforms for a while.

 oobs/oobs-defines.h |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/oobs/oobs-defines.h b/oobs/oobs-defines.h
index f2f9f17..5890517 100644
--- a/oobs/oobs-defines.h
+++ b/oobs/oobs-defines.h
@@ -19,14 +19,12 @@
  *          Milan Bouchet-Valat <nalimilan club fr>.
  */
 
-#include <math.h>
-
-/* The system-tools-backends protocol is using an int32
- * to store [UG]IDs, thus we can't go beyond this,
- * even if the system supports it.
+/* The system-tools-backends protocol is using an unsigned int32
+ * to store [UG]IDs. It is unlikely that any platform will go
+ * beyond this, but some are more restrictive.
  *
  * Computing the size of [ug]id_t is tricky, because
- * no system constant exists for that.*/
+ * no system constant exists for that. */
 
-#define OOBS_MAX_UID MIN (G_MAXINT32, pow (2, 8 * sizeof (uid_t) - 1))
-#define OOBS_MAX_GID MIN (G_MAXINT32, pow (2, 8 * sizeof (gid_t) - 1))
+#define OOBS_MAX_UID MIN (G_MAXUINT32, ((guint32) (1 << (8 * sizeof (uid_t) - 1)) - 1))
+#define OOBS_MAX_GID MIN (G_MAXUINT32, ((guint32) (1 << (8 * sizeof (gid_t) - 1)) - 1))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]