diff options
author | Greg KH <gregkh@linuxfoundation.org> | 2014-01-31 06:51:32 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-01-31 11:55:01 +0100 |
commit | 29804cc1e0f37ee34301530fd7f1eb8550be464e (patch) | |
tree | ba287b984b216279bb342579a9d1039383ca3a39 /src/udev | |
parent | b5cfa7408c4cb68e9bb232fc34b07fd03c915617 (diff) |
use memzero(foo, length); for all memset(foo, 0, length); calls
In trying to track down a stupid linker bug, I noticed a bunch of
memset() calls that should be using memzero() to make it more "obvious"
that the options are correct (i.e. 0 is not the length, but the data to
set). So fix up all current calls to memset(foo, 0, length) to
memzero(foo, length).
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/cdrom_id/cdrom_id.c | 2 | ||||
-rw-r--r-- | src/udev/scsi_id/scsi_serial.c | 16 | ||||
-rw-r--r-- | src/udev/udev-builtin-input_id.c | 2 | ||||
-rw-r--r-- | src/udev/udev-ctrl.c | 2 | ||||
-rw-r--r-- | src/udev/udev-event.c | 4 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 6 | ||||
-rw-r--r-- | src/udev/udevadm-monitor.c | 4 | ||||
-rw-r--r-- | src/udev/udevd.c | 16 |
8 files changed, 26 insertions, 26 deletions
diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index c62fbf9c8c..02a4d399e7 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -155,7 +155,7 @@ struct scsi_cmd { static void scsi_cmd_init(struct udev *udev, struct scsi_cmd *cmd) { - memset(cmd, 0x00, sizeof(struct scsi_cmd)); + memzero(cmd, sizeof(struct scsi_cmd)); cmd->cgc.quiet = 1; cmd->cgc.sense = &cmd->_sense.s; cmd->sg_io.interface_id = 'S'; diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index 66e752e426..2f2afcee6e 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -331,7 +331,7 @@ static int scsi_inquiry(struct udev *udev, resend: if (dev_scsi->use_sg == 4) { - memset(&io_v4, 0, sizeof(struct sg_io_v4)); + memzero(&io_v4, sizeof(struct sg_io_v4)); io_v4.guard = 'Q'; io_v4.protocol = BSG_PROTOCOL_SCSI; io_v4.subprotocol = BSG_SUB_PROTOCOL_SCSI_CMD; @@ -343,7 +343,7 @@ resend: io_v4.din_xferp = (uintptr_t)buf; io_buf = (void *)&io_v4; } else { - memset(&io_hdr, 0, sizeof(struct sg_io_hdr)); + memzero(&io_hdr, sizeof(struct sg_io_hdr)); io_hdr.interface_id = 'S'; io_hdr.cmd_len = sizeof(inq_cmd); io_hdr.mx_sb_len = sizeof(sense); @@ -410,7 +410,7 @@ static int do_scsi_page0_inquiry(struct udev *udev, { int retval; - memset(buffer, 0, len); + memzero(buffer, len); retval = scsi_inquiry(udev, dev_scsi, fd, 1, 0x0, buffer, len); if (retval < 0) return 1; @@ -622,7 +622,7 @@ static int do_scsi_page83_inquiry(struct udev *udev, /* also pick up the page 80 serial number */ do_scsi_page80_inquiry(udev, dev_scsi, fd, NULL, unit_serial_number, MAX_SERIAL_LEN); - memset(page_83, 0, SCSI_INQ_BUFF_LEN); + memzero(page_83, SCSI_INQ_BUFF_LEN); retval = scsi_inquiry(udev, dev_scsi, fd, 1, PAGE_83, page_83, SCSI_INQ_BUFF_LEN); if (retval < 0) @@ -709,7 +709,7 @@ static int do_scsi_page83_prespc3_inquiry(struct udev *udev, int i, j; unsigned char page_83[SCSI_INQ_BUFF_LEN]; - memset(page_83, 0, SCSI_INQ_BUFF_LEN); + memzero(page_83, SCSI_INQ_BUFF_LEN); retval = scsi_inquiry(udev, dev_scsi, fd, 1, PAGE_83, page_83, SCSI_INQ_BUFF_LEN); if (retval < 0) return 1; @@ -773,7 +773,7 @@ static int do_scsi_page80_inquiry(struct udev *udev, int len; unsigned char buf[SCSI_INQ_BUFF_LEN]; - memset(buf, 0, SCSI_INQ_BUFF_LEN); + memzero(buf, SCSI_INQ_BUFF_LEN); retval = scsi_inquiry(udev, dev_scsi, fd, 1, PAGE_80, buf, SCSI_INQ_BUFF_LEN); if (retval < 0) return retval; @@ -832,7 +832,7 @@ int scsi_std_inquiry(struct udev *udev, sprintf(dev_scsi->kernel,"%d:%d", major(statbuf.st_rdev), minor(statbuf.st_rdev)); - memset(buf, 0, SCSI_INQ_BUFF_LEN); + memzero(buf, SCSI_INQ_BUFF_LEN); err = scsi_inquiry(udev, dev_scsi, fd, 0, 0, buf, SCSI_INQ_BUFF_LEN); if (err < 0) goto out; @@ -861,7 +861,7 @@ int scsi_get_serial(struct udev *udev, int ind; int retval; - memset(dev_scsi->serial, 0, len); + memzero(dev_scsi->serial, len); srand((unsigned int)getpid()); for (cnt = 20; cnt > 0; cnt--) { struct timespec duration; diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index 4691fc073d..9b99d1ff9f 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -59,7 +59,7 @@ static void get_cap_mask(struct udev_device *dev, snprintf(text, sizeof(text), "%s", udev_device_get_sysattr_value(pdev, attr)); log_debug("%s raw kernel attribute: %s", attr, text); - memset (bitmask, 0, bitmask_size); + memzero(bitmask, bitmask_size); i = 0; while ((word = strrchr(text, ' ')) != NULL) { val = strtoul (word+1, NULL, 16); diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c index 26879864b0..a65603b3cf 100644 --- a/src/udev/udev-ctrl.c +++ b/src/udev/udev-ctrl.c @@ -246,7 +246,7 @@ static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int struct udev_ctrl_msg_wire ctrl_msg_wire; int err = 0; - memset(&ctrl_msg_wire, 0x00, sizeof(struct udev_ctrl_msg_wire)); + memzero(&ctrl_msg_wire, sizeof(struct udev_ctrl_msg_wire)); strcpy(ctrl_msg_wire.version, "udev-" VERSION); ctrl_msg_wire.magic = UDEV_CTRL_MAGIC; ctrl_msg_wire.type = type; diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 5aec077043..228232bf79 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -439,7 +439,7 @@ static void spawn_read(struct udev_event *event, } if (fd_stdout >= 0) { - memset(&ep_outpipe, 0, sizeof(struct epoll_event)); + memzero(&ep_outpipe, sizeof(struct epoll_event)); ep_outpipe.events = EPOLLIN; ep_outpipe.data.ptr = &fd_stdout; if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stdout, &ep_outpipe) < 0) { @@ -449,7 +449,7 @@ static void spawn_read(struct udev_event *event, } if (fd_stderr >= 0) { - memset(&ep_errpipe, 0, sizeof(struct epoll_event)); + memzero(&ep_errpipe, sizeof(struct epoll_event)); ep_errpipe.events = EPOLLIN; ep_errpipe.data.ptr = &fd_stderr; if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stderr, &ep_errpipe) < 0) { diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 855a4e4060..e90829811b 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -870,7 +870,7 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type, struct token *token = &rule_tmp->token[rule_tmp->token_cur]; const char *attr = NULL; - memset(token, 0x00, sizeof(struct token)); + memzero(token, sizeof(struct token)); switch (type) { case TK_M_ACTION: @@ -1052,7 +1052,7 @@ static int add_rule(struct udev_rules *rules, char *line, const char *attr; struct rule_tmp rule_tmp; - memset(&rule_tmp, 0x00, sizeof(struct rule_tmp)); + memzero(&rule_tmp, sizeof(struct rule_tmp)); rule_tmp.rules = rules; rule_tmp.rule.type = TK_RULE; /* the offset in the rule is limited to unsigned short */ @@ -1652,7 +1652,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) strv_free(files); - memset(&end_token, 0x00, sizeof(struct token)); + memzero(&end_token, sizeof(struct token)); end_token.type = TK_END; add_token(rules, &end_token); log_debug("rules contain %zu bytes tokens (%u * %zu bytes), %zu bytes strings", diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c index 6022e8db82..b2f7f6ba4c 100644 --- a/src/udev/udevadm-monitor.c +++ b/src/udev/udevadm-monitor.c @@ -194,7 +194,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) return 2; } - memset(&ep_udev, 0, sizeof(struct epoll_event)); + memzero(&ep_udev, sizeof(struct epoll_event)); ep_udev.events = EPOLLIN; ep_udev.data.fd = fd_udev; if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_udev, &ep_udev) < 0) { @@ -228,7 +228,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) return 4; } - memset(&ep_kernel, 0, sizeof(struct epoll_event)); + memzero(&ep_kernel, sizeof(struct epoll_event)); ep_kernel.events = EPOLLIN; ep_kernel.data.fd = fd_kernel; if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_kernel, &ep_kernel) < 0) { diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 0dfad762f1..dca62f2429 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -247,12 +247,12 @@ static void worker_new(struct event *event) goto out; } - memset(&ep_signal, 0, sizeof(struct epoll_event)); + memzero(&ep_signal, sizeof(struct epoll_event)); ep_signal.events = EPOLLIN; ep_signal.data.fd = fd_signal; fd_monitor = udev_monitor_get_fd(worker_monitor); - memset(&ep_monitor, 0, sizeof(struct epoll_event)); + memzero(&ep_monitor, sizeof(struct epoll_event)); ep_monitor.events = EPOLLIN; ep_monitor.data.fd = fd_monitor; @@ -303,7 +303,7 @@ static void worker_new(struct event *event) udev_monitor_send_device(worker_monitor, NULL, dev); /* send udevd the result of the event execution */ - memset(&msg, 0, sizeof(struct worker_message)); + memzero(&msg, sizeof(struct worker_message)); if (err != 0) msg.exitcode = err; msg.pid = getpid(); @@ -1159,23 +1159,23 @@ int main(int argc, char *argv[]) goto exit; } - memset(&ep_ctrl, 0, sizeof(struct epoll_event)); + memzero(&ep_ctrl, sizeof(struct epoll_event)); ep_ctrl.events = EPOLLIN; ep_ctrl.data.fd = fd_ctrl; - memset(&ep_inotify, 0, sizeof(struct epoll_event)); + memzero(&ep_inotify, sizeof(struct epoll_event)); ep_inotify.events = EPOLLIN; ep_inotify.data.fd = fd_inotify; - memset(&ep_signal, 0, sizeof(struct epoll_event)); + memzero(&ep_signal, sizeof(struct epoll_event)); ep_signal.events = EPOLLIN; ep_signal.data.fd = fd_signal; - memset(&ep_netlink, 0, sizeof(struct epoll_event)); + memzero(&ep_netlink, sizeof(struct epoll_event)); ep_netlink.events = EPOLLIN; ep_netlink.data.fd = fd_netlink; - memset(&ep_worker, 0, sizeof(struct epoll_event)); + memzero(&ep_worker, sizeof(struct epoll_event)); ep_worker.events = EPOLLIN; ep_worker.data.fd = fd_worker; |