[pacman-dev] [PATCH 1/2] shut up GCC on -Wmaybe-initialized warnings
Admittedly, these are totally bogus, but a clean build is a happy build. --- src/pacman/conf.c | 2 +- src/pacman/pacman.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 5028284..873ca0e 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -459,7 +459,7 @@ static int process_cleanmethods(alpm_list_t *values, static void setrepeatingoption(char *ptr, const char *option, alpm_list_t **list) { - char *val, *saveptr; + char *val, *saveptr = NULL; val = strtok_r(ptr, " ", &saveptr); while(val) { diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 6161048..6234570 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -341,8 +341,7 @@ static void invalid_opt(int used, const char *opt1, const char *opt2) static int parsearg_util_addlist(alpm_list_t **list) { - char *i, *save; - + char *i, *save = NULL; for(i = strtok_r(optarg, ",", &save); i; i = strtok_r(NULL, ",", &save)) { *list = alpm_list_add(*list, strdup(i)); -- 2.1.3
Before this, we'd see bizzare behavior of: -> Adding changelog file (systemd.install)... And, changelog files in the global section would not be added at all. The code is clearly wrong here, as it references 'install' within a loop of 'changelog' and 'install'. Let's use parameter indirection to ensure that the proper file is identified and added. --- scripts/makepkg.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 771aa72..33dff24 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -2367,7 +2367,7 @@ create_srcpackage() { for i in 'changelog' 'install'; do local file files - [[ $install ]] && files+=("$install") + [[ ${!i} ]] && files+=("${!i}") for name in "${pkgname[@]}"; do if extract_function_var "package_$name" "$i" 0 file; then files+=("$file") -- 2.1.3
On 15/12/14 03:35, Dave Reisner wrote:
Admittedly, these are totally bogus, but a clean build is a happy build. --- src/pacman/conf.c | 2 +- src/pacman/pacman.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
Are these the only wanings on -Wmaybe-initialized warnings? Do we want to add that to our standard warning compiler flag list.
On Dec 14, 2014 6:49 PM, "Allan McRae" <allan@archlinux.org> wrote:
On 15/12/14 03:35, Dave Reisner wrote:
Admittedly, these are totally bogus, but a clean build is a happy build. --- src/pacman/conf.c | 2 +- src/pacman/pacman.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
Are these the only wanings on -Wmaybe-initialized warnings? Do we want to add that to our standard warning compiler flag list.
Yes, and if we merge this patch, probably.
participants (3)
-
Allan McRae
-
Dave Reisner
-
Dave Reisner