Skip to content

Commit

Permalink
Consistently write null pointer constants as NULL instead of 0.
Browse files Browse the repository at this point in the history
Found with sparse.
  • Loading branch information
blp committed May 16, 2011
1 parent 1102893 commit e3c1773
Show file tree
Hide file tree
Showing 24 changed files with 138 additions and 138 deletions.
12 changes: 6 additions & 6 deletions lib/daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
OPT_PIDFILE, \
OPT_MONITOR

#define DAEMON_LONG_OPTIONS \
{"detach", no_argument, 0, OPT_DETACH}, \
{"no-chdir", no_argument, 0, OPT_NO_CHDIR}, \
{"pidfile", optional_argument, 0, OPT_PIDFILE}, \
{"overwrite-pidfile", no_argument, 0, OPT_OVERWRITE_PIDFILE},\
{"monitor", no_argument, 0, OPT_MONITOR}
#define DAEMON_LONG_OPTIONS \
{"detach", no_argument, NULL, OPT_DETACH}, \
{"no-chdir", no_argument, NULL, OPT_NO_CHDIR}, \
{"pidfile", optional_argument, NULL, OPT_PIDFILE}, \
{"overwrite-pidfile", no_argument, NULL, OPT_OVERWRITE_PIDFILE}, \
{"monitor", no_argument, NULL, OPT_MONITOR}

#define DAEMON_OPTION_HANDLERS \
case OPT_DETACH: \
Expand Down
6 changes: 3 additions & 3 deletions lib/leak-checker.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2009 Nicira Networks.
* Copyright (c) 2008, 2009, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,8 +23,8 @@
OPT_CHECK_LEAKS, \
OPT_LEAK_LIMIT
#define LEAK_CHECKER_LONG_OPTIONS \
{"check-leaks", required_argument, 0, OPT_CHECK_LEAKS}, \
{"leak-limit", required_argument, 0, OPT_LEAK_LIMIT}
{"check-leaks", required_argument, NULL, OPT_CHECK_LEAKS}, \
{"leak-limit", required_argument, NULL, OPT_LEAK_LIMIT}
#define LEAK_CHECKER_OPTION_HANDLERS \
case OPT_CHECK_LEAKS: \
leak_checker_start(optarg); \
Expand Down
2 changes: 1 addition & 1 deletion lib/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rtnetlink_create(int multicast_group, rtnetlink_parse_func *parse,
struct rtnetlink *rtn;

rtn = xzalloc(sizeof *rtn);
rtn->notify_sock = 0;
rtn->notify_sock = NULL;
rtn->multicast_group = multicast_group;
rtn->parse = parse;
rtn->change = change;
Expand Down
6 changes: 3 additions & 3 deletions lib/stream-ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void stream_ssl_set_key_and_cert(const char *private_key_file,
const char *certificate_file);

#define STREAM_SSL_LONG_OPTIONS \
{"private-key", required_argument, 0, 'p'}, \
{"certificate", required_argument, 0, 'c'}, \
{"ca-cert", required_argument, 0, 'C'}
{"private-key", required_argument, NULL, 'p'}, \
{"certificate", required_argument, NULL, 'c'}, \
{"ca-cert", required_argument, NULL, 'C'}

#define STREAM_SSL_OPTION_HANDLERS \
case 'p': \
Expand Down
12 changes: 6 additions & 6 deletions lib/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ struct table_style {
OPT_PRETTY, \
OPT_BARE

#define TABLE_LONG_OPTIONS \
{"format", required_argument, 0, 'f'}, \
{"data", required_argument, 0, 'd'}, \
{"no-headings", no_argument, 0, OPT_NO_HEADINGS}, \
{"pretty", no_argument, 0, OPT_PRETTY}, \
{"bare", no_argument, 0, OPT_BARE}
#define TABLE_LONG_OPTIONS \
{"format", required_argument, NULL, 'f'}, \
{"data", required_argument, NULL, 'd'}, \
{"no-headings", no_argument, NULL, OPT_NO_HEADINGS}, \
{"pretty", no_argument, NULL, OPT_PRETTY}, \
{"bare", no_argument, NULL, OPT_BARE}

#define TABLE_OPTION_HANDLERS(STYLE) \
case 'f': \
Expand Down
4 changes: 2 additions & 2 deletions lib/vlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ void vlog_rate_limit(const struct vlog_module *, enum vlog_level,
/* Command line processing. */
#define VLOG_OPTION_ENUMS OPT_LOG_FILE
#define VLOG_LONG_OPTIONS \
{"verbose", optional_argument, 0, 'v'}, \
{"log-file", optional_argument, 0, OPT_LOG_FILE}
{"verbose", optional_argument, NULL, 'v'}, \
{"log-file", optional_argument, NULL, OPT_LOG_FILE}
#define VLOG_OPTION_HANDLERS \
case 'v': \
vlog_set_verbosity(optarg); \
Expand Down
6 changes: 3 additions & 3 deletions ovsdb/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ ovsdb_log_read(struct ovsdb_log *file, struct json **jsonp)
file->prev_offset = file->offset;
file->offset = data_offset + data_length;
*jsonp = json;
return 0;
return NULL;

error:
file->read_error = ovsdb_error_clone(error);
Expand Down Expand Up @@ -372,7 +372,7 @@ ovsdb_log_write(struct ovsdb_log *file, struct json *json)

file->offset += strlen(header) + length;
free(json_string);
return 0;
return NULL;

error:
file->write_error = ovsdb_error_clone(error);
Expand All @@ -386,7 +386,7 @@ ovsdb_log_commit(struct ovsdb_log *file)
if (fsync(fileno(file->stream))) {
return ovsdb_io_error(errno, "%s: fsync failed", file->name);
}
return 0;
return NULL;
}

/* Returns the current offset into the file backing 'log', in bytes. This
Expand Down
10 changes: 5 additions & 5 deletions ovsdb/ovsdb-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ parse_options(int argc, char *argv[])
TABLE_OPTION_ENUMS
};
static struct option long_options[] = {
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"verbose", optional_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
DAEMON_LONG_OPTIONS,
#ifdef HAVE_OPENSSL
{"bootstrap-ca-cert", required_argument, 0, OPT_BOOTSTRAP_CA_CERT},
{"bootstrap-ca-cert", required_argument, NULL, OPT_BOOTSTRAP_CA_CERT},
STREAM_SSL_LONG_OPTIONS,
#endif
TABLE_LONG_OPTIONS,
{0, 0, 0, 0},
{NULL, 0, NULL, 0},
};
char *short_options = long_options_to_short_options(long_options);

Expand Down
22 changes: 11 additions & 11 deletions ovsdb/ovsdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ read_string_column(const struct ovsdb_row *row, const char *column_name,
const union ovsdb_atom *atom;

atom = read_column(row, column_name, OVSDB_TYPE_STRING);
*stringp = atom ? atom->string : 0;
*stringp = atom ? atom->string : NULL;
return atom != NULL;
}

Expand Down Expand Up @@ -659,19 +659,19 @@ parse_options(int argc, char *argv[], char **file_namep,
DAEMON_OPTION_ENUMS
};
static struct option long_options[] = {
{"remote", required_argument, 0, OPT_REMOTE},
{"unixctl", required_argument, 0, OPT_UNIXCTL},
{"run", required_argument, 0, OPT_RUN},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"remote", required_argument, NULL, OPT_REMOTE},
{"unixctl", required_argument, NULL, OPT_UNIXCTL},
{"run", required_argument, NULL, OPT_RUN},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
DAEMON_LONG_OPTIONS,
VLOG_LONG_OPTIONS,
LEAK_CHECKER_LONG_OPTIONS,
{"bootstrap-ca-cert", required_argument, 0, OPT_BOOTSTRAP_CA_CERT},
{"private-key", required_argument, 0, 'p'},
{"certificate", required_argument, 0, 'c'},
{"ca-cert", required_argument, 0, 'C'},
{0, 0, 0, 0},
{"bootstrap-ca-cert", required_argument, NULL, OPT_BOOTSTRAP_CA_CERT},
{"private-key", required_argument, NULL, 'p'},
{"certificate", required_argument, NULL, 'c'},
{"ca-cert", required_argument, NULL, 'C'},
{NULL, 0, NULL, 0},
};
char *short_options = long_options_to_short_options(long_options);

Expand Down
10 changes: 5 additions & 5 deletions ovsdb/ovsdb-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ static void
parse_options(int argc, char *argv[])
{
static struct option long_options[] = {
{"more", no_argument, 0, 'm'},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{0, 0, 0, 0},
{"more", no_argument, NULL, 'm'},
{"verbose", optional_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0},
};
char *short_options = long_options_to_short_options(long_options);

Expand Down
2 changes: 1 addition & 1 deletion ovsdb/ovsdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ ovsdb_schema_from_json(struct json *json, struct ovsdb_schema **schemap)
}

*schemap = schema;
return 0;
return NULL;
}

struct json *
Expand Down
2 changes: 1 addition & 1 deletion ovsdb/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ ovsdb_table_schema_from_json(const struct json *json, const char *name,
add_column(ts, column);
}
*tsp = ts;
return 0;
return NULL;
}

/* Returns table schema 'ts' serialized into JSON.
Expand Down
8 changes: 4 additions & 4 deletions tests/test-jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ parse_options(int argc, char *argv[])
DAEMON_OPTION_ENUMS
};
static struct option long_options[] = {
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"verbose", optional_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
DAEMON_LONG_OPTIONS,
{"bootstrap-ca-cert", required_argument, 0, OPT_BOOTSTRAP_CA_CERT},
{"bootstrap-ca-cert", required_argument, NULL, OPT_BOOTSTRAP_CA_CERT},
STREAM_SSL_LONG_OPTIONS,
{0, 0, 0, 0},
{NULL, 0, NULL, 0},
};
char *short_options = long_options_to_short_options(long_options);

Expand Down
4 changes: 2 additions & 2 deletions tests/test-lockfile.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2010 Nicira Networks.
* Copyright (c) 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -231,7 +231,7 @@ static const struct test tests[] = {
TEST(lock_timeout_runs_out),
TEST(lock_multiple),
TEST(help),
{ 0, 0 }
{ NULL, NULL }
#undef TEST
};

Expand Down
8 changes: 4 additions & 4 deletions tests/test-ovsdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ static void
parse_options(int argc, char *argv[])
{
static struct option long_options[] = {
{"timeout", required_argument, 0, 't'},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0},
{"timeout", required_argument, NULL, 't'},
{"verbose", optional_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0},
};
char *short_options = long_options_to_short_options(long_options);

Expand Down
4 changes: 2 additions & 2 deletions utilities/ovs-appctl.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2009, 2010 Nicira Networks.
* Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -109,7 +109,7 @@ parse_command_line(int argc, char *argv[])
{"execute", no_argument, NULL, 'e'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
{0, 0, 0, 0},
{NULL, 0, NULL, 0},
};
const char *target;
int e_options;
Expand Down
28 changes: 14 additions & 14 deletions utilities/ovs-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,23 +310,23 @@ parse_options(int argc, char *argv[])
DAEMON_OPTION_ENUMS
};
static struct option long_options[] = {
{"hub", no_argument, 0, 'H'},
{"noflow", no_argument, 0, 'n'},
{"normal", no_argument, 0, 'N'},
{"wildcard", no_argument, 0, 'w'},
{"max-idle", required_argument, 0, OPT_MAX_IDLE},
{"mute", no_argument, 0, OPT_MUTE},
{"queue", required_argument, 0, 'q'},
{"port-queue", required_argument, 0, 'Q'},
{"with-flows", required_argument, 0, OPT_WITH_FLOWS},
{"unixctl", required_argument, 0, OPT_UNIXCTL},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"hub", no_argument, NULL, 'H'},
{"noflow", no_argument, NULL, 'n'},
{"normal", no_argument, NULL, 'N'},
{"wildcard", no_argument, NULL, 'w'},
{"max-idle", required_argument, NULL, OPT_MAX_IDLE},
{"mute", no_argument, NULL, OPT_MUTE},
{"queue", required_argument, NULL, 'q'},
{"port-queue", required_argument, NULL, 'Q'},
{"with-flows", required_argument, NULL, OPT_WITH_FLOWS},
{"unixctl", required_argument, NULL, OPT_UNIXCTL},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
DAEMON_LONG_OPTIONS,
VLOG_LONG_OPTIONS,
STREAM_SSL_LONG_OPTIONS,
{"peer-ca-cert", required_argument, 0, OPT_PEER_CA_CERT},
{0, 0, 0, 0},
{"peer-ca-cert", required_argument, NULL, OPT_PEER_CA_CERT},
{NULL, 0, NULL, 0},
};
char *short_options = long_options_to_short_options(long_options);

Expand Down
10 changes: 5 additions & 5 deletions utilities/ovs-dpctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ parse_options(int argc, char *argv[])
VLOG_OPTION_ENUMS
};
static struct option long_options[] = {
{"statistics", no_argument, 0, 's'},
{"timeout", required_argument, 0, 't'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"statistics", no_argument, NULL, 's'},
{"timeout", required_argument, NULL, 't'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
VLOG_LONG_OPTIONS,
{0, 0, 0, 0},
{NULL, 0, NULL, 0},
};
char *short_options = long_options_to_short_options(long_options);

Expand Down
14 changes: 7 additions & 7 deletions utilities/ovs-ofctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ parse_options(int argc, char *argv[])
VLOG_OPTION_ENUMS
};
static struct option long_options[] = {
{"timeout", required_argument, 0, 't'},
{"strict", no_argument, 0, OPT_STRICT},
{"flow-format", required_argument, 0, 'F'},
{"more", no_argument, 0, 'm'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"timeout", required_argument, NULL, 't'},
{"strict", no_argument, NULL, OPT_STRICT},
{"flow-format", required_argument, NULL, 'F'},
{"more", no_argument, NULL, 'm'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
VLOG_LONG_OPTIONS,
STREAM_SSL_LONG_OPTIONS,
{0, 0, 0, 0},
{NULL, 0, NULL, 0},
};
char *short_options = long_options_to_short_options(long_options);

Expand Down
Loading

0 comments on commit e3c1773

Please sign in to comment.