X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fprocd.git;a=blobdiff_plain;f=plug%2Fhotplug.c;h=9fc19385d31da3bb598d27d0b88ce0b6337826eb;hp=c8bea1b75b958284968fd6663a8fcb0c9a9fab2a;hb=006c19c45464648a356e200f8ef011b021b9ff6f;hpb=f13e12cc86163662c51a9109fdccd52812564c33 diff --git a/plug/hotplug.c b/plug/hotplug.c index c8bea1b..9fc1938 100644 --- a/plug/hotplug.c +++ b/plug/hotplug.c @@ -431,11 +431,12 @@ static void handle_button_complete(struct blob_attr *msg, struct blob_attr *data if (!timeout) return; - b = malloc(sizeof(*b)); - if (!b || !name) + if (!name) return; - memset(b, 0, sizeof(*b)); + b = calloc(1, sizeof(*b)); + if (!b) + return; b->data = malloc(blob_pad_len(data)); b->name = strdup(name); @@ -489,15 +490,13 @@ static void rule_handle_command(struct json_script_ctx *ctx, const char *name, int rem, i; if (debug > 3) { - DEBUG(4, "Command: %s", name); + DEBUG(4, "Command: %s\n", name); blobmsg_for_each_attr(cur, data, rem) - DEBUG(4, " %s", (char *) blobmsg_data(cur)); - DEBUG(4, "\n"); + DEBUG(4, " %s\n", (char *) blobmsg_data(cur)); - DEBUG(4, "Message:"); + DEBUG(4, "Message:\n"); blobmsg_for_each_attr(cur, vars, rem) - DEBUG(4, " %s=%s", blobmsg_name(cur), (char *) blobmsg_data(cur)); - DEBUG(4, "\n"); + DEBUG(4, " %s=%s\n", blobmsg_name(cur), (char *) blobmsg_data(cur)); } for (i = 0; i < ARRAY_SIZE(handlers); i++) @@ -583,11 +582,10 @@ void hotplug_last_event(uloop_timeout_handler handler) void hotplug(char *rules) { - struct sockaddr_nl nls; + struct sockaddr_nl nls = {}; int nlbufsize = 512 * 1024; rule_file = strdup(rules); - memset(&nls,0,sizeof(struct sockaddr_nl)); nls.nl_family = AF_NETLINK; nls.nl_pid = getpid(); nls.nl_groups = -1;