From 4a2eea2939bc9131f240491355aa40976ca7a38d Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Sun, 7 May 2006 10:52:47 +0000 Subject: [PATCH] minor cleanup, removed unneeded check in safemult_sizet --- src/ngircd/array.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/ngircd/array.c b/src/ngircd/array.c index d34c00d5..bc405351 100644 --- a/src/ngircd/array.c +++ b/src/ngircd/array.c @@ -12,7 +12,7 @@ #include "array.h" -static char UNUSED id[] = "$Id: array.c,v 1.8 2005/08/30 13:36:32 fw Exp $"; +static char UNUSED id[] = "$Id: array.c,v 1.9 2006/05/07 10:52:47 fw Exp $"; #include @@ -21,26 +21,21 @@ static char UNUSED id[] = "$Id: array.c,v 1.8 2005/08/30 13:36:32 fw Exp $"; #include "log.h" -#define array_UNUSABLE(x) ( ! x->mem || (0 == x->allocated) ) +#define array_UNUSABLE(x) ( !(x)->mem || (0 == (x)->allocated) ) -#define ALIGN_32U(x) ((x | 0x1fU) +1) -#define ALIGN_1024U(x) ((x | 0x3ffU) +1) -#define ALIGN_4096U(x) ((x | 0xfffU) +1) +#define ALIGN_32U(x) (((x) | 0x1fU) +1) +#define ALIGN_1024U(x) (((x) | 0x3ffU) +1) +#define ALIGN_4096U(x) (((x) | 0xfffU) +1) static bool safemult_sizet(size_t a, size_t b, size_t *res) { size_t tmp; - - if (!a || !b) { - *res = 0; - return true; - } - + tmp = a * b; - if (tmp / b != a) + if (b && (tmp / b != a)) return false; *res = tmp; @@ -51,7 +46,7 @@ safemult_sizet(size_t a, size_t b, size_t *res) void array_init(array *a) { - assert(a); + assert(a != NULL); a->mem = NULL; a->allocated = 0; a->used = 0;