diff options
author | Jim Meyering <meyering@redhat.com> | 2009-07-02 15:25:58 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-07-02 23:23:13 +0200 |
commit | d0bdef850e7bf0edc1a8ee1f05880cdf867aeeb6 (patch) | |
tree | b4abeea472b7d628e9c6fe8f7a78cacce75103de /src | |
parent | ee4c49fad5a3e36c6e909ab90bcb7d719c9395b3 (diff) | |
download | libguestfs-d0bdef850e7bf0edc1a8ee1f05880cdf867aeeb6.tar.gz libguestfs-d0bdef850e7bf0edc1a8ee1f05880cdf867aeeb6.tar.xz libguestfs-d0bdef850e7bf0edc1a8ee1f05880cdf867aeeb6.zip |
prefer sizeof *VAR over sizeof TYPE (no semantic change)
* src/generator.ml: Slightly safer, in case the
declared type ever changes.
Diffstat (limited to 'src')
-rwxr-xr-x | src/generator.ml | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/generator.ml b/src/generator.ml index ed5810bf..4b7efa09 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -8228,16 +8228,16 @@ print_strings (char * const* const argv) pr " return strs;\n" | RIntBool _ -> pr " struct guestfs_int_bool *r;\n"; - pr " r = malloc (sizeof (struct guestfs_int_bool));\n"; + pr " r = malloc (sizeof *r);\n"; pr " sscanf (val, \"%%\" SCNi32, &r->i);\n"; pr " r->b = 0;\n"; pr " return r;\n" | RPVList _ -> pr " struct guestfs_lvm_pv_list *r;\n"; pr " int i;\n"; - pr " r = malloc (sizeof (struct guestfs_lvm_pv_list));\n"; + pr " r = malloc (sizeof *r);\n"; pr " sscanf (val, \"%%d\", &r->len);\n"; - pr " r->val = calloc (r->len, sizeof (struct guestfs_lvm_pv));\n"; + pr " r->val = calloc (r->len, sizeof *r->val);\n"; pr " for (i = 0; i < r->len; ++i) {\n"; pr " r->val[i].pv_name = malloc (16);\n"; pr " snprintf (r->val[i].pv_name, 16, \"%%d\", i);\n"; @@ -8246,9 +8246,9 @@ print_strings (char * const* const argv) | RVGList _ -> pr " struct guestfs_lvm_vg_list *r;\n"; pr " int i;\n"; - pr " r = malloc (sizeof (struct guestfs_lvm_vg_list));\n"; + pr " r = malloc (sizeof *r);\n"; pr " sscanf (val, \"%%d\", &r->len);\n"; - pr " r->val = calloc (r->len, sizeof (struct guestfs_lvm_vg));\n"; + pr " r->val = calloc (r->len, sizeof *r->val);\n"; pr " for (i = 0; i < r->len; ++i) {\n"; pr " r->val[i].vg_name = malloc (16);\n"; pr " snprintf (r->val[i].vg_name, 16, \"%%d\", i);\n"; @@ -8257,9 +8257,9 @@ print_strings (char * const* const argv) | RLVList _ -> pr " struct guestfs_lvm_lv_list *r;\n"; pr " int i;\n"; - pr " r = malloc (sizeof (struct guestfs_lvm_lv_list));\n"; + pr " r = malloc (sizeof *r);\n"; pr " sscanf (val, \"%%d\", &r->len);\n"; - pr " r->val = calloc (r->len, sizeof (struct guestfs_lvm_lv));\n"; + pr " r->val = calloc (r->len, sizeof *r->val);\n"; pr " for (i = 0; i < r->len; ++i) {\n"; pr " r->val[i].lv_name = malloc (16);\n"; pr " snprintf (r->val[i].lv_name, 16, \"%%d\", i);\n"; @@ -8279,7 +8279,7 @@ print_strings (char * const* const argv) pr " char **strs;\n"; pr " int n, i;\n"; pr " sscanf (val, \"%%d\", &n);\n"; - pr " strs = malloc ((n*2+1) * sizeof (char *));\n"; + pr " strs = malloc ((n*2+1) * sizeof (*strs));\n"; pr " for (i = 0; i < n; ++i) {\n"; pr " strs[i*2] = malloc (16);\n"; pr " strs[i*2+1] = malloc (16);\n"; @@ -8291,9 +8291,9 @@ print_strings (char * const* const argv) | RDirentList _ -> pr " struct guestfs_dirent_list *r;\n"; pr " int i;\n"; - pr " r = malloc (sizeof (struct guestfs_dirent_list));\n"; + pr " r = malloc (sizeof *r);\n"; pr " sscanf (val, \"%%d\", &r->len);\n"; - pr " r->val = calloc (r->len, sizeof (struct guestfs_dirent));\n"; + pr " r->val = calloc (r->len, sizeof *r->val);\n"; pr " for (i = 0; i < r->len; ++i)\n"; pr " r->val[i].ino = i;\n"; pr " return r;\n" |