nasmlib.c: prefix_name(): use the elements() macro
authorH. Peter Anvin <hpa@zytor.com>
Fri, 9 Nov 2007 03:34:01 +0000 (19:34 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 9 Nov 2007 03:34:01 +0000 (19:34 -0800)
Use the elements() macro to count the elements in a static array.

nasmlib.c

index 44e3a36..170c95f 100644 (file)
--- a/nasmlib.c
+++ b/nasmlib.c
@@ -776,7 +776,7 @@ static const char *prefix_names[] = {
 const char *prefix_name(int token)
 {
     unsigned int prefix = token-PREFIX_ENUM_START;
-    if (prefix > sizeof prefix_names / sizeof(const char *))
+    if (prefix > elements(prefix_names))
        return NULL;
 
     return prefix_names[prefix];