git://git.onelab.eu
/
sliver-openvswitch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ac718c9
)
Add new function xzalloc(n) as a shorthand for xcalloc(1, n).
author
Ben Pfaff
<blp@nicira.com>
Mon, 28 Sep 2009 20:56:42 +0000
(13:56 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Wed, 4 Nov 2009 22:52:32 +0000
(14:52 -0800)
22 files changed:
SubmittingPatches
patch
|
blob
|
history
extras/ezio/ovs-switchui.c
patch
|
blob
|
history
lib/dhcp-client.c
patch
|
blob
|
history
lib/dpif-netdev.c
patch
|
blob
|
history
lib/learning-switch.c
patch
|
blob
|
history
lib/netdev-linux.c
patch
|
blob
|
history
lib/poll-loop.c
patch
|
blob
|
history
lib/process.c
patch
|
blob
|
history
lib/rconn.c
patch
|
blob
|
history
lib/stp.c
patch
|
blob
|
history
lib/util.c
patch
|
blob
|
history
lib/util.h
patch
|
blob
|
history
ofproto/discovery.c
patch
|
blob
|
history
ofproto/executer.c
patch
|
blob
|
history
ofproto/in-band.c
patch
|
blob
|
history
ofproto/ofproto.c
patch
|
blob
|
history
ofproto/pinsched.c
patch
|
blob
|
history
ofproto/pktbuf.c
patch
|
blob
|
history
ofproto/status.c
patch
|
blob
|
history
tests/test-classifier.c
patch
|
blob
|
history
vswitchd/bridge.c
patch
|
blob
|
history
vswitchd/proc-net-compat.c
patch
|
blob
|
history
diff --git
a/SubmittingPatches
b/SubmittingPatches
index
917cddb
..
280f11e
100644
(file)
--- a/
SubmittingPatches
+++ b/
SubmittingPatches
@@
-193,7
+193,7
@@
index 32647ea..00cffbc 100644
/* Get rid of deleted bridges and add new bridges. */
svec_sort(&old_br);
@@ -793,7 +780,7 @@ bridge_create(const char *name)
/* Get rid of deleted bridges and add new bridges. */
svec_sort(&old_br);
@@ -793,7 +780,7 @@ bridge_create(const char *name)
- br = x
calloc(1,
sizeof *br);
+ br = x
zalloc(
sizeof *br);
error = dpif_create(name, &br->dpif);
- if (error == EEXIST) {
error = dpif_create(name, &br->dpif);
- if (error == EEXIST) {
diff --git
a/extras/ezio/ovs-switchui.c
b/extras/ezio/ovs-switchui.c
index
0f6640e
..
e56f83e
100644
(file)
--- a/
extras/ezio/ovs-switchui.c
+++ b/
extras/ezio/ovs-switchui.c
@@
-1247,7
+1247,7
@@
allocate_message(struct message **msgp)
{
if (!*msgp) {
/* Allocate and initialize message. */
{
if (!*msgp) {
/* Allocate and initialize message. */
- *msgp = x
calloc(1,
sizeof **msgp);
+ *msgp = x
zalloc(
sizeof **msgp);
(*msgp)->index = n_messages;
/* Add to list of messages. */
(*msgp)->index = n_messages;
/* Add to list of messages. */
diff --git
a/lib/dhcp-client.c
b/lib/dhcp-client.c
index
4f90781
..
720cd2f
100644
(file)
--- a/
lib/dhcp-client.c
+++ b/
lib/dhcp-client.c
@@
-172,7
+172,7
@@
dhclient_create(const char *netdev_name,
return error;
}
return error;
}
- cli = x
calloc(1,
sizeof *cli);
+ cli = x
zalloc(
sizeof *cli);
cli->modify_request = modify_request;
cli->validate_offer = validate_offer;
cli->aux = aux;
cli->modify_request = modify_request;
cli->validate_offer = validate_offer;
cli->aux = aux;
diff --git
a/lib/dpif-netdev.c
b/lib/dpif-netdev.c
index
4c25f13
..
8bd9648
100644
(file)
--- a/
lib/dpif-netdev.c
+++ b/
lib/dpif-netdev.c
@@
-219,7
+219,7
@@
create_dp_netdev(const char *name, int dp_idx, struct dpif **dpifp)
}
/* Create datapath. */
}
/* Create datapath. */
- dp_netdevs[dp_idx] = dp = x
calloc(1,
sizeof *dp);
+ dp_netdevs[dp_idx] = dp = x
zalloc(
sizeof *dp);
list_push_back(&dp_netdev_list, &dp->node);
dp->dp_idx = dp_idx;
dp->open_cnt = 0;
list_push_back(&dp_netdev_list, &dp->node);
dp->dp_idx = dp_idx;
dp->open_cnt = 0;
@@
-788,7
+788,7
@@
add_flow(struct dpif *dpif, struct odp_flow *odp_flow)
struct dp_netdev_flow *flow;
int error;
struct dp_netdev_flow *flow;
int error;
- flow = x
calloc(1,
sizeof *flow);
+ flow = x
zalloc(
sizeof *flow);
flow->key = odp_flow->key;
flow->key.reserved = 0;
flow->key = odp_flow->key;
flow->key.reserved = 0;
diff --git
a/lib/learning-switch.c
b/lib/learning-switch.c
index
73464c6
..
99d5ee4
100644
(file)
--- a/
lib/learning-switch.c
+++ b/
lib/learning-switch.c
@@
-110,7
+110,7
@@
lswitch_create(struct rconn *rconn, bool learn_macs, int max_idle)
struct lswitch *sw;
size_t i;
struct lswitch *sw;
size_t i;
- sw = x
calloc(1,
sizeof *sw);
+ sw = x
zalloc(
sizeof *sw);
sw->max_idle = max_idle;
sw->datapath_id = 0;
sw->last_features_request = time_now() - 1;
sw->max_idle = max_idle;
sw->datapath_id = 0;
sw->last_features_request = time_now() - 1;
diff --git
a/lib/netdev-linux.c
b/lib/netdev-linux.c
index
7324703
..
c33405f
100644
(file)
--- a/
lib/netdev-linux.c
+++ b/
lib/netdev-linux.c
@@
-203,7
+203,7
@@
netdev_linux_open(const char *name, char *suffix, int ethertype,
int error;
/* Allocate network device. */
int error;
/* Allocate network device. */
- netdev = x
calloc(1,
sizeof *netdev);
+ netdev = x
zalloc(
sizeof *netdev);
netdev_init(&netdev->netdev, suffix, &netdev_linux_class);
netdev->netdev_fd = -1;
netdev->tap_fd = -1;
netdev_init(&netdev->netdev, suffix, &netdev_linux_class);
netdev->netdev_fd = -1;
netdev->tap_fd = -1;
diff --git
a/lib/poll-loop.c
b/lib/poll-loop.c
index
aff2c33
..
26a17e8
100644
(file)
--- a/
lib/poll-loop.c
+++ b/
lib/poll-loop.c
@@
-253,7
+253,7
@@
poll_cancel(struct poll_waiter *pw)
static struct poll_waiter *
new_waiter(int fd, short int events)
{
static struct poll_waiter *
new_waiter(int fd, short int events)
{
- struct poll_waiter *waiter = x
calloc(1,
sizeof *waiter);
+ struct poll_waiter *waiter = x
zalloc(
sizeof *waiter);
assert(fd >= 0);
waiter->fd = fd;
waiter->events = events;
assert(fd >= 0);
waiter->fd = fd;
waiter->events = events;
diff --git
a/lib/process.c
b/lib/process.c
index
1fe3c12
..
0c7f424
100644
(file)
--- a/
lib/process.c
+++ b/
lib/process.c
@@
-161,7
+161,7
@@
process_register(const char *name, pid_t pid)
assert(sigchld_is_blocked());
assert(sigchld_is_blocked());
- p = x
calloc(1,
sizeof *p);
+ p = x
zalloc(
sizeof *p);
p->pid = pid;
slash = strrchr(name, '/');
p->name = xstrdup(slash ? slash + 1 : name);
p->pid = pid;
slash = strrchr(name, '/');
p->name = xstrdup(slash ? slash + 1 : name);
diff --git
a/lib/rconn.c
b/lib/rconn.c
index
2cbe43e
..
b6e958e
100644
(file)
--- a/
lib/rconn.c
+++ b/
lib/rconn.c
@@
-176,7
+176,7
@@
rconn_new_from_vconn(const char *name, struct vconn *vconn)
struct rconn *
rconn_create(int probe_interval, int max_backoff)
{
struct rconn *
rconn_create(int probe_interval, int max_backoff)
{
- struct rconn *rc = x
calloc(1,
sizeof *rc);
+ struct rconn *rc = x
zalloc(
sizeof *rc);
rc->state = S_VOID;
rc->state_entered = time_now();
rc->state = S_VOID;
rc->state_entered = time_now();
diff --git
a/lib/stp.c
b/lib/stp.c
index
87230bd
..
cf1b2f9
100644
(file)
--- a/
lib/stp.c
+++ b/
lib/stp.c
@@
-214,7
+214,7
@@
stp_create(const char *name, stp_identifier bridge_id,
struct stp *stp;
struct stp_port *p;
struct stp *stp;
struct stp_port *p;
- stp = x
calloc(1,
sizeof *stp);
+ stp = x
zalloc(
sizeof *stp);
stp->name = xstrdup(name);
stp->bridge_id = bridge_id;
if (!(stp->bridge_id >> 48)) {
stp->name = xstrdup(name);
stp->bridge_id = bridge_id;
if (!(stp->bridge_id >> 48)) {
diff --git
a/lib/util.c
b/lib/util.c
index
f766d59
..
cecd582
100644
(file)
--- a/
lib/util.c
+++ b/
lib/util.c
@@
-42,6
+42,12
@@
xcalloc(size_t count, size_t size)
return p;
}
return p;
}
+void *
+xzalloc(size_t size)
+{
+ return xcalloc(1, size);
+}
+
void *
xmalloc(size_t size)
{
void *
xmalloc(size_t size)
{
diff --git
a/lib/util.h
b/lib/util.h
index
962bad2
..
1290d33
100644
(file)
--- a/
lib/util.h
+++ b/
lib/util.h
@@
-98,6
+98,7
@@
void ovs_print_version(char *date, char *time,
void out_of_memory(void) NO_RETURN;
void *xmalloc(size_t) MALLOC_LIKE;
void *xcalloc(size_t, size_t) MALLOC_LIKE;
void out_of_memory(void) NO_RETURN;
void *xmalloc(size_t) MALLOC_LIKE;
void *xcalloc(size_t, size_t) MALLOC_LIKE;
+void *xzalloc(size_t) MALLOC_LIKE;
void *xrealloc(void *, size_t);
void *xmemdup(const void *, size_t) MALLOC_LIKE;
char *xmemdup0(const char *, size_t) MALLOC_LIKE;
void *xrealloc(void *, size_t);
void *xmemdup(const void *, size_t) MALLOC_LIKE;
char *xmemdup0(const char *, size_t) MALLOC_LIKE;
diff --git
a/ofproto/discovery.c
b/ofproto/discovery.c
index
2868db5
..
c762506
100644
(file)
--- a/
ofproto/discovery.c
+++ b/
ofproto/discovery.c
@@
-102,7
+102,7
@@
discovery_create(const char *re, bool update_resolv_conf,
char local_name[IF_NAMESIZE];
int error;
char local_name[IF_NAMESIZE];
int error;
- d = x
calloc(1,
sizeof *d);
+ d = x
zalloc(
sizeof *d);
/* Controller regular expression. */
error = discovery_set_accept_controller_re(d, re);
/* Controller regular expression. */
error = discovery_set_accept_controller_re(d, re);
diff --git
a/ofproto/executer.c
b/ofproto/executer.c
index
bc42ccf
..
cdbe5bd
100644
(file)
--- a/
ofproto/executer.c
+++ b/
ofproto/executer.c
@@
-471,7
+471,7
@@
executer_create(const char *command_acl, const char *command_dir,
return errno;
}
return errno;
}
- e = x
calloc(1,
sizeof *e);
+ e = x
zalloc(
sizeof *e);
e->command_acl = xstrdup(command_acl);
e->command_dir = (command_dir
? xstrdup(command_dir)
e->command_acl = xstrdup(command_acl);
e->command_dir = (command_dir
? xstrdup(command_dir)
diff --git
a/ofproto/in-band.c
b/ofproto/in-band.c
index
2b362bc
..
4a2ea83
100644
(file)
--- a/
ofproto/in-band.c
+++ b/
ofproto/in-band.c
@@
-624,7
+624,7
@@
in_band_create(struct ofproto *ofproto, struct dpif *dpif,
return error;
}
return error;
}
- in_band = x
calloc(1,
sizeof *in_band);
+ in_band = x
zalloc(
sizeof *in_band);
in_band->ofproto = ofproto;
in_band->controller = controller;
in_band->ss_cat = switch_status_register(ss, "in-band",
in_band->ofproto = ofproto;
in_band->controller = controller;
in_band->ss_cat = switch_status_register(ss, "in-band",
diff --git
a/ofproto/ofproto.c
b/ofproto/ofproto.c
index
eb8a7a9
..
c618e3c
100644
(file)
--- a/
ofproto/ofproto.c
+++ b/
ofproto/ofproto.c
@@
-292,7
+292,7
@@
ofproto_create(const char *datapath, const struct ofhooks *ofhooks, void *aux,
dpif_recv_purge(dpif);
/* Initialize settings. */
dpif_recv_purge(dpif);
/* Initialize settings. */
- p = x
calloc(1,
sizeof *p);
+ p = x
zalloc(
sizeof *p);
p->fallback_dpid = pick_fallback_dpid();
p->datapath_id = p->fallback_dpid;
p->manufacturer = xstrdup("Nicira Networks, Inc.");
p->fallback_dpid = pick_fallback_dpid();
p->datapath_id = p->fallback_dpid;
p->manufacturer = xstrdup("Nicira Networks, Inc.");
@@
-1389,7
+1389,7
@@
rule_create(struct rule *super,
const union ofp_action *actions, size_t n_actions,
uint16_t idle_timeout, uint16_t hard_timeout)
{
const union ofp_action *actions, size_t n_actions,
uint16_t idle_timeout, uint16_t hard_timeout)
{
- struct rule *rule = x
calloc(1,
sizeof *rule);
+ struct rule *rule = x
zalloc(
sizeof *rule);
rule->idle_timeout = idle_timeout;
rule->hard_timeout = hard_timeout;
rule->used = rule->created = time_msec();
rule->idle_timeout = idle_timeout;
rule->hard_timeout = hard_timeout;
rule->used = rule->created = time_msec();
@@
-2427,7
+2427,7
@@
query_stats(struct ofproto *p, struct rule *rule,
byte_count = rule->byte_count;
n_odp_flows = rule->cr.wc.wildcards ? list_size(&rule->list) : 1;
byte_count = rule->byte_count;
n_odp_flows = rule->cr.wc.wildcards ? list_size(&rule->list) : 1;
- odp_flows = x
calloc(1,
n_odp_flows * sizeof *odp_flows);
+ odp_flows = x
zalloc(
n_odp_flows * sizeof *odp_flows);
if (rule->cr.wc.wildcards) {
size_t i = 0;
LIST_FOR_EACH (subrule, struct rule, list, &rule->list) {
if (rule->cr.wc.wildcards) {
size_t i = 0;
LIST_FOR_EACH (subrule, struct rule, list, &rule->list) {
diff --git
a/ofproto/pinsched.c
b/ofproto/pinsched.c
index
0afd22f
..
a4f5bfa
100644
(file)
--- a/
ofproto/pinsched.c
+++ b/
ofproto/pinsched.c
@@
-227,7
+227,7
@@
pinsched_create(int rate_limit, int burst_limit, struct switch_status *ss)
{
struct pinsched *ps;
{
struct pinsched *ps;
- ps = x
calloc(1,
sizeof *ps);
+ ps = x
zalloc(
sizeof *ps);
port_array_init(&ps->queues);
ps->n_queued = 0;
ps->last_tx_port = PORT_ARRAY_SIZE;
port_array_init(&ps->queues);
ps->n_queued = 0;
ps->last_tx_port = PORT_ARRAY_SIZE;
diff --git
a/ofproto/pktbuf.c
b/ofproto/pktbuf.c
index
450cc3b
..
3701aeb
100644
(file)
--- a/
ofproto/pktbuf.c
+++ b/
ofproto/pktbuf.c
@@
-63,7
+63,7
@@
pktbuf_capacity(void)
struct pktbuf *
pktbuf_create(void)
{
struct pktbuf *
pktbuf_create(void)
{
- return x
calloc(1,
sizeof *pktbuf_create());
+ return x
zalloc(
sizeof *pktbuf_create());
}
void
}
void
diff --git
a/ofproto/status.c
b/ofproto/status.c
index
b2cb935
..
5e61888
100644
(file)
--- a/
ofproto/status.c
+++ b/
ofproto/status.c
@@
-177,7
+177,7
@@
switch_status_cb(struct status_reply *sr, void *ss_)
struct switch_status *
switch_status_create(const struct ofproto *ofproto)
{
struct switch_status *
switch_status_create(const struct ofproto *ofproto)
{
- struct switch_status *ss = x
calloc(1,
sizeof *ss);
+ struct switch_status *ss = x
zalloc(
sizeof *ss);
ss->booted = time_now();
list_init(&ss->categories);
ss->config_cat = switch_status_register(ss, "config", config_status_cb,
ss->booted = time_now();
list_init(&ss->categories);
ss->config_cat = switch_status_register(ss, "config", config_status_cb,
diff --git
a/tests/test-classifier.c
b/tests/test-classifier.c
index
0307e48
..
d36c8eb
100644
(file)
--- a/
tests/test-classifier.c
+++ b/
tests/test-classifier.c
@@
-446,7
+446,7
@@
make_rule(int wc_fields, unsigned int priority, int value_pat)
}
}
}
}
- rule = x
calloc(1,
sizeof *rule);
+ rule = x
zalloc(
sizeof *rule);
cls_rule_from_flow(&rule->cls_rule, &flow, wildcards,
!wildcards ? UINT_MAX : priority);
return rule;
cls_rule_from_flow(&rule->cls_rule, &flow, wildcards,
!wildcards ? UINT_MAX : priority);
return rule;
diff --git
a/vswitchd/bridge.c
b/vswitchd/bridge.c
index
b0db9ab
..
b1e4e16
100644
(file)
--- a/
vswitchd/bridge.c
+++ b/
vswitchd/bridge.c
@@
-964,7
+964,7
@@
bridge_create(const char *name)
int error;
assert(!bridge_lookup(name));
int error;
assert(!bridge_lookup(name));
- br = x
calloc(1,
sizeof *br);
+ br = x
zalloc(
sizeof *br);
error = dpif_create(name, &br->dpif);
if (error == EEXIST || error == EBUSY) {
error = dpif_create(name, &br->dpif);
if (error == EEXIST || error == EBUSY) {
@@
-2838,7
+2838,7
@@
port_create(struct bridge *br, const char *name)
{
struct port *port;
{
struct port *port;
- port = x
calloc(1,
sizeof *port);
+ port = x
zalloc(
sizeof *port);
port->bridge = br;
port->port_idx = br->n_ports;
port->vlan = -1;
port->bridge = br;
port->port_idx = br->n_ports;
port->vlan = -1;
@@
-3191,7
+3191,7
@@
iface_create(struct port *port, const char *name)
{
struct iface *iface;
{
struct iface *iface;
- iface = x
calloc(1,
sizeof *iface);
+ iface = x
zalloc(
sizeof *iface);
iface->port = port;
iface->port_ifidx = port->n_ifaces;
iface->name = xstrdup(name);
iface->port = port;
iface->port_ifidx = port->n_ifaces;
iface->name = xstrdup(name);
@@
-3398,7
+3398,7
@@
mirror_create(struct bridge *br, const char *name)
VLOG_INFO("created port mirror %s on bridge %s", name, br->name);
bridge_flush(br);
VLOG_INFO("created port mirror %s on bridge %s", name, br->name);
bridge_flush(br);
- br->mirrors[i] = m = x
calloc(1,
sizeof *m);
+ br->mirrors[i] = m = x
zalloc(
sizeof *m);
m->bridge = br;
m->idx = i;
m->name = xstrdup(name);
m->bridge = br;
m->idx = i;
m->name = xstrdup(name);
diff --git
a/vswitchd/proc-net-compat.c
b/vswitchd/proc-net-compat.c
index
7a59526
..
68ae1ac
100644
(file)
--- a/
vswitchd/proc-net-compat.c
+++ b/
vswitchd/proc-net-compat.c
@@
-256,7
+256,7
@@
proc_net_compat_update_vlan(const char *tagged_dev, const char *trunk_dev,
}
if (!vlan) {
/* Create a new compat_vlan for (trunk_dev,vid). */
}
if (!vlan) {
/* Create a new compat_vlan for (trunk_dev,vid). */
- vlan = x
calloc(1,
sizeof *vlan);
+ vlan = x
zalloc(
sizeof *vlan);
vlan->trunk_dev = xstrdup(trunk_dev);
vlan->vid = vid;
vlan->vlan_dev = xasprintf("%s.%d", trunk_dev, vid);
vlan->trunk_dev = xstrdup(trunk_dev);
vlan->vid = vid;
vlan->vlan_dev = xasprintf("%s.%d", trunk_dev, vid);