mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
daemon: simplify string allocation
When creating an helper string for do_aug_match(), use a simpler asprintf() with manual free(), since the code block is small enough. This slightly helps static code analyzers.
This commit is contained in:
committed by
Richard W.M. Jones
parent
d48d0fc2d1
commit
9667587366
@@ -420,17 +420,15 @@ do_aug_ls (const char *path)
|
||||
if (STREQ (path, "/"))
|
||||
matches = do_aug_match ("/*");
|
||||
else {
|
||||
CLEANUP_FREE char *buf = NULL;
|
||||
char *buf = NULL;
|
||||
|
||||
len += 3; /* / * + terminating \0 */
|
||||
buf = malloc (len);
|
||||
if (buf == NULL) {
|
||||
reply_with_perror ("malloc");
|
||||
if (asprintf (&buf, "%s/*", path) == -1) {
|
||||
reply_with_perror ("asprintf");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snprintf (buf, len, "%s/*", path);
|
||||
matches = do_aug_match (buf);
|
||||
free (buf);
|
||||
}
|
||||
|
||||
if (matches == NULL)
|
||||
|
||||
Reference in New Issue
Block a user