aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2021-04-26 09:42:38 +0200
committerJan200101 <sentrycraft123@gmail.com>2021-04-26 09:42:38 +0200
commit14e8bfdc0a83a1256f2efc92868ead7dbd26bc51 (patch)
treed8d63951d87f9cbb3df90e687e3537c5c82237b4
parent62308a879f0bfe6e714ad2fd1abbe004a6a3c095 (diff)
downloadpolecat-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.h6
-rw-r--r--src/dxvk.c13
-rw-r--r--src/tar.c2
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); \
} \
diff --git a/src/dxvk.c b/src/dxvk.c
index 9b4a5f6..34790cd 100644
--- a/src/dxvk.c
+++ b/src/dxvk.c
@@ -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);
diff --git a/src/tar.c b/src/tar.c
index 0daf657..d11728b 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -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);
}