Message ID | 20210309174657.2336-1-anton@khirnov.net |
---|---|
State | Accepted |
Commit | b334fd39c9c00c739faeece87fa81c980c148a16 |
Headers | show |
Series | [FFmpeg-devel] cmdutils: replace strncpy() with direct assignment | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
> // Change all the ' --' strings to '~--' so that > // they can be identified as tokens. > while ((conflist = strstr(str, " --")) != NULL) { > - strncpy(conflist, "~--", 3); > + conflist[0] = '~'; > } Doesn't this simply replace -- with ~- ? The comment seems wrong to me...
Quoting Gregor Riepl (2021-03-09 18:54:11) > > // Change all the ' --' strings to '~--' so that > > // they can be identified as tokens. > > while ((conflist = strstr(str, " --")) != NULL) { > > - strncpy(conflist, "~--", 3); > > + conflist[0] = '~'; > > } > > Doesn't this simply replace -- with ~- ? > The comment seems wrong to me... No, it replaces ' --' with '~--', just as the comment says.
No further comments, so set pushed.
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 8cfca22564..5a457b997b 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -1163,13 +1163,13 @@ static void print_buildconf(int flags, int level) // Change all the ' --' strings to '~--' so that // they can be identified as tokens. while ((conflist = strstr(str, " --")) != NULL) { - strncpy(conflist, "~--", 3); + conflist[0] = '~'; } // Compensate for the weirdness this would cause // when passing 'pkg-config --static'. while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) { - strncpy(remove_tilde, "pkg-config ", 11); + remove_tilde[sizeof("pkg-config~") - 2] = ' '; } splitconf = strtok(str, "~");