Fix -Werror=restrict
While one could be safe to assume that first input is read, then symlink target is copied to user-mode, it causes compiler warning. So, don't reuse the symlink filename buffer for storing symlink target. ../daemon/procfs.c:155:28: error: passing argument 2 to restrict-qualified parameter aliases with argument 1 [-Werror=restrict] 155 | ret = readlink(g_buffer, g_buffer, sizeof(g_buffer)); | ~~~~~~~~ ^~~~~~~~ sys-libs/glibc-2.30-r8 (armv7a, but ISA probably does not matter) gcc (Gentoo 9.3.0 p2) 9.3.0
This commit is contained in:
parent
16e6233620
commit
27e38d3f4b
|
@ -39,6 +39,7 @@
|
||||||
#define BUFFER_SIZE 4096
|
#define BUFFER_SIZE 4096
|
||||||
|
|
||||||
static char g_buffer[BUFFER_SIZE];
|
static char g_buffer[BUFFER_SIZE];
|
||||||
|
static char g_buffer_readlink[BUFFER_SIZE];
|
||||||
|
|
||||||
static
|
static
|
||||||
bool
|
bool
|
||||||
|
@ -152,11 +153,11 @@ procfs_get_process_link(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = readlink(g_buffer, g_buffer, sizeof(g_buffer));
|
ret = readlink(g_buffer, g_buffer_readlink, sizeof(g_buffer_readlink));
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
g_buffer[ret] = 0;
|
g_buffer_readlink[ret] = 0;
|
||||||
buffer_ptr = strdup(g_buffer);
|
buffer_ptr = strdup(g_buffer_readlink);
|
||||||
log_debug("process %llu %s symlink points to \"%s\"", pid, filename, buffer_ptr);
|
log_debug("process %llu %s symlink points to \"%s\"", pid, filename, buffer_ptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue