mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
CUDA Wrangler: Fix strict compiler warning
Namely addresses -Wstringop-truncation Not sure if there is anything to be done for strncpy. Differential Revision: https://developer.blender.org/D6006
This commit is contained in:
parent
a630e46a58
commit
bc6f439e94
2 changed files with 19 additions and 2 deletions
19
extern/cuew/src/cuew.c
vendored
19
extern/cuew/src/cuew.c
vendored
|
|
@ -859,6 +859,23 @@ int cuewNvrtcVersion(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static size_t safe_strnlen(const char *s, size_t maxlen) {
|
||||
size_t length;
|
||||
for (length = 0; length < maxlen; s++, length++) {
|
||||
if (*s == '\0') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
static char *safe_strncpy(char *dest, const char *src, size_t n) {
|
||||
const size_t src_len = safe_strnlen(src, n - 1);
|
||||
memcpy(dest, src, src_len);
|
||||
dest[src_len] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
int cuewCompilerVersion(void) {
|
||||
const char *path = cuewCompilerPath();
|
||||
const char *marker = "Cuda compilation tools, release ";
|
||||
|
|
@ -874,7 +891,7 @@ int cuewCompilerVersion(void) {
|
|||
}
|
||||
|
||||
/* get --version output */
|
||||
strncpy(command, path, sizeof(command));
|
||||
safe_strncpy(command, path, sizeof(command));
|
||||
strncat(command, " --version", sizeof(command) - strlen(path));
|
||||
pipe = popen(command, "r");
|
||||
if (!pipe) {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit a17cabe4c9976547b20078149a99c9bb58152d1d
|
||||
Subproject commit 120d31a17c0eb571420b828425fc1fe6ef13db2d
|
||||
Loading…
Add table
Add a link
Reference in a new issue