mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-31 14:23:53 -06:00
use g_path_get_basename instead of basename
basename(3) and dirname(3) modify their argument and may return pointers to statically allocated memory which may be overwritten by subsequent calls. g_path_get_basename and g_path_get_dirname have no such issues, and therefore more preferable. Signed-off-by: Julia Suvorova <jusual@mail.ru> Message-Id: <1519888086-4207-1-git-send-email-jusual@mail.ru> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
4060e671c3
commit
3e015d815b
6 changed files with 15 additions and 12 deletions
|
@ -808,7 +808,7 @@ static char *get_pci_driver(char const *syspath, int pathlen, Error **errp)
|
|||
len = readlink(dpath, buf, sizeof(buf) - 1);
|
||||
if (len != -1) {
|
||||
buf[len] = 0;
|
||||
driver = g_strdup(basename(buf));
|
||||
driver = g_path_get_basename(buf);
|
||||
}
|
||||
g_free(dpath);
|
||||
g_free(path);
|
||||
|
@ -1053,7 +1053,7 @@ static void build_guest_fsinfo_for_device(char const *devpath,
|
|||
}
|
||||
|
||||
if (!fs->name) {
|
||||
fs->name = g_strdup(basename(syspath));
|
||||
fs->name = g_path_get_basename(syspath);
|
||||
}
|
||||
|
||||
g_debug(" parse sysfs path '%s'", syspath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue