aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-10-21 10:21:52 +0200
committerJakub Jelinek <jakub@redhat.com>2020-10-21 10:21:52 +0200
commit121a8812c45b3155ccbd268b000ad00a778e81e8 (patch)
treeaf92e526851805c8e1c4eedd7b3da0b209f954ce
parentbae73ca5222381861a29202c88ce5cfe675b6753 (diff)
downloadgcc-121a8812c45b3155ccbd268b000ad00a778e81e8.zip
gcc-121a8812c45b3155ccbd268b000ad00a778e81e8.tar.gz
gcc-121a8812c45b3155ccbd268b000ad00a778e81e8.tar.bz2
libgomp: Hopefully avoid false positive warnings in env.c on solaris
> the patch also breaks bootstrap on both i386-pc-solaris2.11 and > sparc-sun-solaris2.11: > > /vol/gcc/src/hg/master/local/libgomp/env.c: In function 'initialize_env': > /vol/gcc/src/hg/master/local/libgomp/env.c:414:16: error: 'new_offload' may be used uninitialized in this function [-Werror=maybe-uninitialized] > 414 | *offload = new_offload; > | ~~~~~~~~~^~~~~~~~~~~~~ > /vol/gcc/src/hg/master/local/libgomp/env.c:384:30: note: 'new_offload' was declared here > 384 | enum gomp_target_offload_t new_offload; > | ^~~~~~~~~~~ I can't reproduce that, but I fail to see why we need two separate variables, one with actual value and one tracking if the value is valid. So, I'm going with: 2020-10-21 Jakub Jelinek <jakub@redhat.com> * env.c (parse_target_offload): Change new_offload var type to int, preinitialize to -1, remove found var and test new_offload != -1 instead of found.
-rw-r--r--libgomp/env.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/libgomp/env.c b/libgomp/env.c
index f305b14..ab22525 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -380,8 +380,7 @@ static void
parse_target_offload (const char *name, enum gomp_target_offload_t *offload)
{
const char *env;
- bool found = false;
- enum gomp_target_offload_t new_offload;
+ int new_offload = -1;
env = getenv (name);
if (env == NULL)
@@ -392,24 +391,21 @@ parse_target_offload (const char *name, enum gomp_target_offload_t *offload)
if (strncasecmp (env, "default", 7) == 0)
{
env += 7;
- found = true;
new_offload = GOMP_TARGET_OFFLOAD_DEFAULT;
}
else if (strncasecmp (env, "mandatory", 9) == 0)
{
env += 9;
- found = true;
new_offload = GOMP_TARGET_OFFLOAD_MANDATORY;
}
else if (strncasecmp (env, "disabled", 8) == 0)
{
env += 8;
- found = true;
new_offload = GOMP_TARGET_OFFLOAD_DISABLED;
}
while (isspace ((unsigned char) *env))
++env;
- if (found && *env == '\0')
+ if (new_offload != -1 && *env == '\0')
{
*offload = new_offload;
return;