summaryrefslogtreecommitdiff
path: root/lib/compat
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2018-11-17 20:35:54 +0100
committerGuillem Jover <guillem@debian.org>2019-01-22 13:41:54 +0100
commite29648778ccd54ff834c3581b460542fdb766d44 (patch)
tree254d03b751ee9dfee54a8d220855021437a83378 /lib/compat
parentf94d12b62e0747791ece6400f31a15fddc3a2d5b (diff)
downloaddpkg-e29648778ccd54ff834c3581b460542fdb766d44.tar.gz
When allocating use the variable instead of the type in sizeof()
This makes it easier to guarantee we use the correct size for the involved variable.
Diffstat (limited to 'lib/compat')
-rw-r--r--lib/compat/scandir.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/compat/scandir.c b/lib/compat/scandir.c
index 4765d7dcb..8771de093 100644
--- a/lib/compat/scandir.c
+++ b/lib/compat/scandir.c
@@ -72,13 +72,13 @@ scandir(const char *dir, struct dirent ***namelist,
avail *= 2;
else
avail = 20;
- newlist = realloc(list, avail * sizeof(struct dirent *));
+ newlist = realloc(list, avail * sizeof(*newlist));
if (!newlist)
return cleanup(d, list, used);
list = newlist;
}
- m = malloc(sizeof(struct dirent) + strlen(e->d_name));
+ m = malloc(sizeof(*m) + strlen(e->d_name));
if (!m)
return cleanup(d, list, used);
*m = *e;
@@ -91,7 +91,7 @@ scandir(const char *dir, struct dirent ***namelist,
closedir(d);
if (list != NULL && cmp != NULL)
- qsort(list, used, sizeof(struct dirent *), cmp);
+ qsort(list, used, sizeof(list[0]), cmp);
*namelist = list;