Skip to contentSkip to conversation

libdecnumber/dpd/decimal64: Fix compiler warning from Clang 15

PATCH In review Thomas Huth 3 participants 5 messages Nov 10, 2022 – Nov 11, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libdecnumber/dpd/decimal64: Fix compiler warning from Clang 15

Clang 15 from Fedora 37 complains:

../libdecnumber/dpd/decimal64.c:620:8: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
Int n; /* output bunch counter */

        ^

1 error generated.

Remove the unused variable to silence the compiler warning.

---
 libdecnumber/dpd/decimal64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
libdecnumber/dpd/decimal64.c +1 -2
index 4816176410..290dbe8177 100644
@@ -617,7 +617,6 @@ static const uInt multies[]={131073, 26215, 5243, 1049, 210};
 #endif
 void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) {
   Int  cut;		      /* work */
-  Int  n;		      /* output bunch counter */
   Int  digits=dn->digits;     /* digit countdown */
   uInt dpd;		      /* densely packed decimal value */
   uInt bin;		      /* binary value 0-999 */
@@ -676,7 +675,7 @@ void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) {
     bin=0;			   /* [keep compiler quiet] */
   #endif
 
-  for(n=0; digits>0; n++) {	   /* each output bunch */
+  while (digits > 0) {             /* each output bunch */
     #if DECDPUN==3		   /* fast path, 3-at-a-time */
       bin=*inu;			   /* 3 digits ready for convert */
       digits-=3;		   /* [may go negative] */
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Thomas Huth

Clang 15 from Fedora 37 complains:

../libdecnumber/dpd/decimal64.c:620:8: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
Int n; /* output bunch counter */
^
1 error generated.

Remove the unused variable to silence the compiler warning.

Thanks,

C.

Quoted 25 lines
---
  libdecnumber/dpd/decimal64.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
libdecnumber/dpd/decimal64.c +1 -2
index 4816176410..290dbe8177 100644
@@ -617,7 +617,6 @@ static const uInt multies[]={131073, 26215, 5243, 1049, 210};
  #endif
  void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) {
    Int  cut;		      /* work */
-  Int  n;		      /* output bunch counter */
    Int  digits=dn->digits;     /* digit countdown */
    uInt dpd;		      /* densely packed decimal value */
    uInt bin;		      /* binary value 0-999 */
@@ -676,7 +675,7 @@ void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) {
      bin=0;			   /* [keep compiler quiet] */
    #endif
 
-  for(n=0; digits>0; n++) {	   /* each output bunch */
+  while (digits > 0) {             /* each output bunch */
      #if DECDPUN==3		   /* fast path, 3-at-a-time */
        bin=*inu;			   /* 3 digits ready for convert */
        digits-=3;		   /* [may go negative] */
#2 lore raw
In reply to Thomas Huth
Quoted 28 lines · Thomas Huth

Clang 15 from Fedora 37 complains:

../libdecnumber/dpd/decimal64.c:620:8: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
Int n; /* output bunch counter */
^
1 error generated.

Remove the unused variable to silence the compiler warning.

---
  libdecnumber/dpd/decimal64.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
libdecnumber/dpd/decimal64.c +0 -1
index 4816176410..290dbe8177 100644
@@ -617,7 +617,6 @@ static const uInt multies[]={131073, 26215, 5243, 1049, 210};
  #endif
  void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) {
    Int  cut;		      /* work */
-  Int  n;		      /* output bunch counter */
    Int  digits=dn->digits;     /* digit countdown */
    uInt dpd;		      /* densely packed decimal value */
    uInt bin;		      /* binary value 0-999 */

libdecnumber/dpd/decimal64.c void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) { · line 681

Quoted 8 lines
libdecnumber/dpd/decimal64.c +1 -1
@@ -676,7 +675,7 @@ void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) {
      bin=0;			   /* [keep compiler quiet] */
    #endif
 
-  for(n=0; digits>0; n++) {	   /* each output bunch */
+  while (digits > 0) {             /* each output bunch */
      #if DECDPUN==3		   /* fast path, 3-at-a-time */
        bin=*inu;			   /* 3 digits ready for convert */
        digits-=3;		   /* [may go negative] */

Or we could we backport the upstream fix :)

https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=libdecnumber/dpd/decimal64.c;h=f72c5730ac3b473e2c334f604e7e52da9711fa72;hp=269eaecade5115a62e979897742cd5decec0681e;hb=8a79685989bff33f479d0ac2df0e18d55d3ba78b;hpb=e1d1842b5432472330384d1523bb3c3132c4fea0

#3 lore raw
Quoted 41 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Thomas Huth

Clang 15 from Fedora 37 complains:

  ../libdecnumber/dpd/decimal64.c:620:8: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
    Int  n;                     /* output bunch counter */ ^
  1 error generated.

Remove the unused variable to silence the compiler warning.

---
  libdecnumber/dpd/decimal64.c | 3 +--

  1 file changed, 1 insertion(+), 2 deletions(-)
libdecnumber/dpd/decimal64.c +0 -0
index 4816176410..290dbe8177 100644
@@ -617,7 +617,6 @@ static const uInt multies[]={131073, 26215, 5243, 
 1049, 210};
   #endif
   void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) {

    Int  cut;              /* work */
-  Int  n;              /* output bunch counter */ Int  digits=dn->digits;     /* digit countdown */ uInt dpd;              /* densely packed decimal value */ uInt bin;              /* binary value 0-999 */

libdecnumber/dpd/decimal64.c +0 -0
@@ -676,7 +675,7 @@ void decDigitsToDPD(const decNumber *dn, uInt *targ, 
 Int shift) {
Quoted 7 lines

      bin=0;               /* [keep compiler quiet] */ #endif
-  for(n=0; digits>0; n++) {       /* each output bunch */ +  while (digits > 0) {             /* each output bunch */ #if DECDPUN==3           /* fast path, 3-at-a-time */ bin=*inu;               /* 3 digits ready for convert */ digits-=3;           /* [may go negative] */

Or we could we backport the upstream fix :)

Quoted 1 line

https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=libdecnumber/dpd/decimal64.c;h=f72c5730ac3b473e2c334f604e7e52da9711fa72;hp=269eaecade5115a62e979897742cd5decec0681e;hb=8a79685989bff33f479d0ac2df0e18d55d3ba78b;hpb=e1d1842b5432472330384d1523bb3c3132c4fea0

I did not look on that code on purpose - it's licensed under the GPLv3, so we should not mix that back into our GPLv2 version.

Thomas

#4 lore raw
Quoted 18 lines · Thomas Huth
Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Thomas Huth

Clang 15 from Fedora 37 complains:

  ../libdecnumber/dpd/decimal64.c:620:8: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
    Int  n;                     /* output bunch counter */ ^
  1 error generated.

Remove the unused variable to silence the compiler warning.

---
  libdecnumber/dpd/decimal64.c | 3 +--

  1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 5 lines
Quoted 3 lines

Or we could we backport the upstream fix :)

https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=libdecnumber/dpd/decimal64.c;h=f72c5730ac3b473e2c334f604e7e52da9711fa72;hp=269eaecade5115a62e979897742cd5decec0681e;hb=8a79685989bff33f479d0ac2df0e18d55d3ba78b;hpb=e1d1842b5432472330384d1523bb3c3132c4fea0

I did not look on that code on purpose - it's licensed under the GPLv3, so we should not mix that back into our GPLv2 version.

Sigh, right. So: