[ovs-dev] [PATCH 12/15] ovsdb-idlc: Remove special case for "sizeof bool".
Ben Pfaff
blp at ovn.org
Thu Oct 6 03:16:49 UTC 2016
The "sparse" checker used to warn about sizeof(bool). These days, it does
not warn (without -Wsizeof-bool), so remove this ugly special case.
If you have a version of "sparse" that still warns by default, please
upgrade to a version that includes commit 2667c2d4ab33 (sparse: Allow
override of sizeof(bool) warning).
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
ovsdb/ovsdb-idlc.in | 27 ++++-----------------------
1 file changed, 4 insertions(+), 23 deletions(-)
diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
index 680a205..cf6cd58 100755
--- a/ovsdb/ovsdb-idlc.in
+++ b/ovsdb/ovsdb-idlc.in
@@ -311,13 +311,6 @@ def printCIDLSource(schemaFile):
#include "ovsdb-error.h"
#include "util.h"
-#ifdef __CHECKER__
-/* Sparse dislikes sizeof(bool) ("warning: expression using sizeof bool"). */
-enum { sizeof_bool = 1 };
-#else
-enum { sizeof_bool = sizeof(bool) };
-#endif
-
''' % schema.idlHeader
# Cast functions.
@@ -411,23 +404,11 @@ static void
valueSrc = "datum->values[i].%s" % type.value.type.to_string()
print " if (!row->n_%s) {" % (columnName)
- # Special case for boolean types. This is only here because
- # sparse does not like the "normal" case ("warning: expression
- # using sizeof bool").
- if type.key.type == ovs.db.types.BooleanType:
- sizeof = "sizeof_bool"
- else:
- sizeof = "sizeof *%s" % keyVar
- print " %s = xmalloc(%s * %s);" % (keyVar, nMax,
- sizeof)
+ print " %s = xmalloc(%s * sizeof *%s);" % (
+ keyVar, nMax, keyVar)
if valueVar:
- # Special case for boolean types (see above).
- if type.value.type == ovs.db.types.BooleanType:
- sizeof = " * sizeof_bool"
- else:
- sizeof = "sizeof *%s" % valueVar
- print " %s = xmalloc(%s * %s);" % (valueVar,
- nMax, sizeof)
+ print " %s = xmalloc(%s * sizeof *%s);" % (
+ valueVar, nMax, valueVar)
print " }"
print " %s[row->n_%s] = %s;" % (keyVar, columnName, keySrc)
if valueVar:
--
2.1.3
More information about the dev
mailing list