This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/2] sysdeps/ieee754: prevent maybe-uninitialized errors


* with -O included in CFLAGS it fails to build with:

../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_jnl':
../sysdeps/ieee754/ldbl-96/e_jnl.c:146:20: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      b = invsqrtpi * temp / sqrtl (x);
          ~~~~~~~~~~^~~~~~
../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_ynl':
../sysdeps/ieee754/ldbl-96/e_jnl.c:375:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  b = invsqrtpi * temp / sqrtl (x);
      ~~~~~~~~~~^~~~~~

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 sysdeps/ieee754/dbl-64/e_jn.c    | 2 ++
 sysdeps/ieee754/ldbl-128/e_jnl.c | 4 ++++
 sysdeps/ieee754/ldbl-96/e_jnl.c  | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
index cb7c6cf266..e9964311ca 100644
--- a/sysdeps/ieee754/dbl-64/e_jn.c
+++ b/sysdeps/ieee754/dbl-64/e_jn.c
@@ -109,6 +109,7 @@ __ieee754_jn (int n, double x)
 	      case 1: temp = -c + s; break;
 	      case 2: temp = -c - s; break;
 	      case 3: temp = c - s; break;
+	      default: temp = 0; // just to prevent error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 	      }
 	    b = invsqrtpi * temp / sqrt (x);
 	  }
@@ -316,6 +317,7 @@ __ieee754_yn (int n, double x)
 	  case 1: temp = -s - c; break;
 	  case 2: temp = -s + c; break;
 	  case 3: temp = s + c; break;
+	  default: temp = 0; // just to prevent error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 	  }
 	b = invsqrtpi * temp / sqrt (x);
       }
diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c
index 540b95ca58..2270522e24 100644
--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128/e_jnl.c
@@ -150,6 +150,8 @@ __ieee754_jnl (int n, _Float128 x)
 	      case 3:
 		temp = c - s;
 		break;
+	      default:
+	        temp = 0; // just to prevent error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 	      }
 	    b = invsqrtpi * temp / sqrtl (x);
 	  }
@@ -386,6 +388,8 @@ __ieee754_ynl (int n, _Float128 x)
 	  case 3:
 	    temp = s + c;
 	    break;
+	  default:
+	    temp = 0; // just to prevent error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 	  }
 	b = invsqrtpi * temp / sqrtl (x);
       }
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index fd28f6ae91..ee158cf39a 100644
--- a/sysdeps/ieee754/ldbl-96/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-96/e_jnl.c
@@ -143,6 +143,8 @@ __ieee754_jnl (int n, long double x)
 	      case 3:
 		temp = c - s;
 		break;
+	      default:
+	        temp = 0; // just to prevent error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 	      }
 	    b = invsqrtpi * temp / sqrtl (x);
 	  }
@@ -372,6 +374,8 @@ __ieee754_ynl (int n, long double x)
 	  case 3:
 	    temp = s + c;
 	    break;
+	  default:
+	    temp = 0; // just to prevent error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 	  }
 	b = invsqrtpi * temp / sqrtl (x);
       }
-- 
2.17.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]