diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2021-04-26 09:42:38 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2021-04-26 09:42:38 +0200 |
commit | 14e8bfdc0a83a1256f2efc92868ead7dbd26bc51 (patch) | |
tree | d8d63951d87f9cbb3df90e687e3537c5c82237b4 | |
parent | 62308a879f0bfe6e714ad2fd1abbe004a6a3c095 (diff) | |
download | polecat-14e8bfdc0a83a1256f2efc92868ead7dbd26bc51.tar.gz polecat-14e8bfdc0a83a1256f2efc92868ead7dbd26bc51.zip |
rid some warnings
put brackets around flag logic
ignore chdir return
use memmove for putting quotes around the dxvk path
-rw-r--r-- | src/command.h | 6 | ||||
-rw-r--r-- | src/dxvk.c | 13 | ||||
-rw-r--r-- | src/tar.c | 2 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/command.h b/src/command.h index 54ce16f..7460d59 100644 --- a/src/command.h +++ b/src/command.h @@ -65,9 +65,9 @@ \ for (unsigned long i = 0; i < ARRAY_LEN(GROUP##_flags); ++i) \ { \ - if (GROUP##_flags[i].variant & SINGLE && argv[j][1] == GROUP##_flags[i].name[0] || \ - GROUP##_flags[i].variant & DOUBLE && argv[j][1] == '-' \ - && !strcmp(GROUP##_flags[i].name, argv[j]+2)) \ + if ((GROUP##_flags[i].variant & SINGLE && argv[j][1] == GROUP##_flags[i].name[0]) || \ + (GROUP##_flags[i].variant & DOUBLE && argv[j][1] == '-' \ + && !strcmp(GROUP##_flags[i].name, argv[j]+2))) \ { \ return GROUP##_flags[i].func(0, NULL); \ } \ @@ -182,11 +182,14 @@ COMMAND(dxvk, install) { // quote the dxvkpath so whitespace won't cause trouble { - char dxvkpathcpy[PATH_MAX] = {0}; - strncat(dxvkpathcpy, "\"", sizeof(dxvkpathcpy) - strlen(dxvkpathcpy) - 1); - strncat(dxvkpathcpy, dxvkpath, sizeof(dxvkpathcpy) - strlen(dxvkpathcpy) - 1); - strncat(dxvkpathcpy, "\"", sizeof(dxvkpathcpy) - strlen(dxvkpathcpy) - 1); - strncpy(dxvkpath, dxvkpathcpy, sizeof(dxvkpathcpy)); + size_t size = strlen(dxvkpath) + 1; + if (size > sizeof(dxvkpath)) size = sizeof(dxvkpath); + + memmove(dxvkpath+1, dxvkpath, size - 1); + dxvkpath[0] = '"'; + + strncat(dxvkpath, "\"", sizeof(dxvkpath) - size); + } strncat(dxvkpath, " install", sizeof(dxvkpath) - strlen(dxvkpath) - 1); @@ -108,5 +108,5 @@ void extract(const struct MemoryStruct* tar, const char* outputdir) archive_write_close(ext); archive_write_free(ext); - if (err) chdir(cwd); + if (err) (void)chdir(cwd); } |