Skip to content

Commit

Permalink
ovsdb-idlc: Remove special case for "sizeof bool".
Browse files Browse the repository at this point in the history
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@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
  • Loading branch information
blp committed Oct 19, 2016
1 parent aa8628a commit 8b300b7
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions ovsdb/ovsdb-idlc.in
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 8b300b7

Please sign in to comment.