Use the variable instead of type for sizeof.

This commit is contained in:
Roy Marples 2008-01-30 15:01:37 +00:00
parent 3506cb2dc7
commit 84ad9a40a6
5 changed files with 14 additions and 14 deletions

View File

@ -52,7 +52,7 @@ static int do_check (char *path, uid_t uid, gid_t gid, mode_t mode, int file)
{ {
struct stat st; struct stat st;
memset (&st, 0, sizeof (struct stat)); memset (&st, 0, sizeof (st));
if (stat (path, &st)) { if (stat (path, &st)) {
if (file) { if (file) {

View File

@ -319,7 +319,7 @@ static char **find_mounts (struct args *args)
static regex_t *get_regex (const char *string) static regex_t *get_regex (const char *string)
{ {
regex_t *reg = xmalloc (sizeof (regex_t)); regex_t *reg = xmalloc (sizeof (*reg));
int result; int result;
char buffer[256]; char buffer[256];
@ -390,7 +390,7 @@ int mountinfo (int argc, char **argv)
#define REG_FREE(_var) \ #define REG_FREE(_var) \
if (_var) { regfree (_var); 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.mount_type = mount_to;
args.netdev = net_ignore; args.netdev = net_ignore;

View File

@ -111,15 +111,15 @@ void rc_plugin_load (void)
dlclose (h); dlclose (h);
} else { } else {
if (plugin) { if (plugin) {
plugin->next = xmalloc (sizeof (plugin_t)); plugin->next = xmalloc (sizeof (*plugin->next));
plugin = plugin->next; plugin = plugin->next;
} else } 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->name = xstrdup (d->d_name);
plugin->handle = h; plugin->handle = h;
plugin->hook = fptr; plugin->hook = fptr;
plugin->next = NULL;
} }
} }
closedir (dp); closedir (dp);

View File

@ -224,7 +224,7 @@ static char read_key (bool block)
/* Now save our terminal settings. We need to restore them at exit as we /* Now save our terminal settings. We need to restore them at exit as we
* will be changing it for non-blocking reads for Interactive */ * will be changing it for non-blocking reads for Interactive */
if (! termios_orig) { if (! termios_orig) {
termios_orig = xmalloc (sizeof (struct termios)); termios_orig = xmalloc (sizeof (*termios_orig));
tcgetattr (fd, termios_orig); tcgetattr (fd, termios_orig);
} }
@ -401,11 +401,11 @@ static void add_pid (pid_t pid)
if (sp) { if (sp) {
while (sp->next) while (sp->next)
sp = sp->next; sp = sp->next;
sp->next = xmalloc (sizeof (pidlist_t)); sp->next = xmalloc (sizeof (*sp->next));
sp = sp->next; sp = sp->next;
} else } else
sp = service_pids = xmalloc (sizeof (pidlist_t)); sp = service_pids = xmalloc (sizeof (*sp));
memset (sp, 0, sizeof (pidlist_t)); memset (sp, 0, sizeof (*sp));
sp->pid = pid; sp->pid = pid;
} }

View File

@ -215,13 +215,13 @@ static void parse_schedule (const char *string, int default_signal)
if (schedule) if (schedule)
free_schedulelist (&schedule); free_schedulelist (&schedule);
schedule = xmalloc (sizeof (schedulelist_t)); schedule = xmalloc (sizeof (*schedule));
schedule->gotolist = NULL; schedule->gotolist = NULL;
if (count == 0) { if (count == 0) {
schedule->type = schedule_signal; schedule->type = schedule_signal;
schedule->value = default_signal; schedule->value = default_signal;
schedule->next = xmalloc (sizeof (schedulelist_t)); schedule->next = xmalloc (sizeof (*schedule->next));
next = schedule->next; next = schedule->next;
next->type = schedule_timeout; next->type = schedule_timeout;
next->gotolist = NULL; next->gotolist = NULL;
@ -261,14 +261,14 @@ static void parse_schedule (const char *string, int default_signal)
} }
if (string) { if (string) {
next->next = xmalloc (sizeof (schedulelist_t)); next->next = xmalloc (sizeof (*next->next));
next = next->next; next = next->next;
next->gotolist = NULL; next->gotolist = NULL;
} }
} }
if (repeatat) { if (repeatat) {
next->next = xmalloc (sizeof (schedulelist_t)); next->next = xmalloc (sizeof (*next->next));
next = next->next; next = next->next;
next->type = schedule_goto; next->type = schedule_goto;
next->value = 0; next->value = 0;