From 84ad9a40a647b97551bc8bc35f082bd82e8b8c92 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 30 Jan 2008 15:01:37 +0000 Subject: [PATCH] Use the variable instead of type for sizeof. --- src/rc/checkpath.c | 2 +- src/rc/mountinfo.c | 4 ++-- src/rc/rc-plugin.c | 6 +++--- src/rc/rc.c | 8 ++++---- src/rc/start-stop-daemon.c | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c index 4b57e187..74bed53f 100644 --- a/src/rc/checkpath.c +++ b/src/rc/checkpath.c @@ -52,7 +52,7 @@ static int do_check (char *path, uid_t uid, gid_t gid, mode_t mode, int file) { struct stat st; - memset (&st, 0, sizeof (struct stat)); + memset (&st, 0, sizeof (st)); if (stat (path, &st)) { if (file) { diff --git a/src/rc/mountinfo.c b/src/rc/mountinfo.c index 7dc7d063..0d8d7a1c 100644 --- a/src/rc/mountinfo.c +++ b/src/rc/mountinfo.c @@ -319,7 +319,7 @@ static char **find_mounts (struct args *args) static regex_t *get_regex (const char *string) { - regex_t *reg = xmalloc (sizeof (regex_t)); + regex_t *reg = xmalloc (sizeof (*reg)); int result; char buffer[256]; @@ -390,7 +390,7 @@ int mountinfo (int argc, char **argv) #define REG_FREE(_var) \ if (_var) { regfree (_var); free (_var); } - memset (&args, 0, sizeof (struct args)); + memset (&args, 0, sizeof (args)); args.mount_type = mount_to; args.netdev = net_ignore; diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c index 635e52fb..29bd43c2 100644 --- a/src/rc/rc-plugin.c +++ b/src/rc/rc-plugin.c @@ -111,15 +111,15 @@ void rc_plugin_load (void) dlclose (h); } else { if (plugin) { - plugin->next = xmalloc (sizeof (plugin_t)); + plugin->next = xmalloc (sizeof (*plugin->next)); plugin = plugin->next; } else - plugin = plugins = xmalloc (sizeof (plugin_t)); + plugin = plugins = xmalloc (sizeof (*plugin)); - memset (plugin, 0, sizeof (plugin_t)); plugin->name = xstrdup (d->d_name); plugin->handle = h; plugin->hook = fptr; + plugin->next = NULL; } } closedir (dp); diff --git a/src/rc/rc.c b/src/rc/rc.c index f0a76396..433babbf 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -224,7 +224,7 @@ static char read_key (bool block) /* Now save our terminal settings. We need to restore them at exit as we * will be changing it for non-blocking reads for Interactive */ if (! termios_orig) { - termios_orig = xmalloc (sizeof (struct termios)); + termios_orig = xmalloc (sizeof (*termios_orig)); tcgetattr (fd, termios_orig); } @@ -401,11 +401,11 @@ static void add_pid (pid_t pid) if (sp) { while (sp->next) sp = sp->next; - sp->next = xmalloc (sizeof (pidlist_t)); + sp->next = xmalloc (sizeof (*sp->next)); sp = sp->next; } else - sp = service_pids = xmalloc (sizeof (pidlist_t)); - memset (sp, 0, sizeof (pidlist_t)); + sp = service_pids = xmalloc (sizeof (*sp)); + memset (sp, 0, sizeof (*sp)); sp->pid = pid; } diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index 85930902..cecf55cf 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -215,13 +215,13 @@ static void parse_schedule (const char *string, int default_signal) if (schedule) free_schedulelist (&schedule); - schedule = xmalloc (sizeof (schedulelist_t)); + schedule = xmalloc (sizeof (*schedule)); schedule->gotolist = NULL; if (count == 0) { schedule->type = schedule_signal; schedule->value = default_signal; - schedule->next = xmalloc (sizeof (schedulelist_t)); + schedule->next = xmalloc (sizeof (*schedule->next)); next = schedule->next; next->type = schedule_timeout; next->gotolist = NULL; @@ -261,14 +261,14 @@ static void parse_schedule (const char *string, int default_signal) } if (string) { - next->next = xmalloc (sizeof (schedulelist_t)); + next->next = xmalloc (sizeof (*next->next)); next = next->next; next->gotolist = NULL; } } if (repeatat) { - next->next = xmalloc (sizeof (schedulelist_t)); + next->next = xmalloc (sizeof (*next->next)); next = next->next; next->type = schedule_goto; next->value = 0;