Skip to content

Commit e02290d

Browse files
committed
vcgencmd: Avoid compiler complaints
In file included from /usr/include/string.h:535, from /<<PKGBUILDDIR>>/vcgencmd/vcgencmd.c:34: In function ‘strncat’, inlined from ‘gencmd’ at /<<PKGBUILDDIR>>/vcgencmd/vcgencmd.c:109:4, inlined from ‘main’ at /<<PKGBUILDDIR>>/vcgencmd/vcgencmd.c:152:14: /usr/include/arm-linux-gnueabihf/bits/string_fortified.h:138:10: warning: ‘__builtin___strncat_chk’ specified bound 1024 equals destination size [-Wstringop-overflow=] 138 | return __builtin___strncat_chk (__dest, __src, __len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 139 | __glibc_objsize (__dest)); | ~~~~~~~~~~~~~~~~~~~~~~~~~ can be seen with "gcc -O2 -Wall"
1 parent 32602f5 commit e02290d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

vcgencmd/vcgencmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ static unsigned gencmd(int file_desc, const char *command, char *result, int res
105105
p[0] = i*sizeof *p; // actual size
106106

107107
mbox_property(file_desc, p);
108-
result[0] = 0;
109-
strncat(result, (const char *)(p+6), result_len);
108+
memcpy(result, p+6, result_len);
109+
result[result_len -1] = '\0';
110110

111111
return p[5];
112112
}

0 commit comments

Comments
 (0)