bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] [PATCH] xheader: avoid pointer-arith warning


From: Bernhard Voelker
Subject: [Bug-tar] [PATCH] xheader: avoid pointer-arith warning
Date: Tue, 16 Dec 2014 17:50:24 +0100

GCC-4.8.3 (on openSUSE-13.2) gives the following warnings:

xheader.c: In function ‘xheader_string_end’:
xheader.c:1030:38: error: pointer of type ‘void *’ used in arithmetic 
[-Werror=pointer-arith]
   cp = obstack_next_free (xhdr->stk) - xhdr->string_length - p - 1;
                                      ^
xheader.c:1030:60: error: pointer of type ‘void *’ used in arithmetic 
[-Werror=pointer-arith]
   cp = obstack_next_free (xhdr->stk) - xhdr->string_length - p - 1;
                                                            ^
xheader.c:1030:64: error: pointer of type ‘void *’ used in arithmetic 
[-Werror=pointer-arith]
   cp = obstack_next_free (xhdr->stk) - xhdr->string_length - p - 1;
                                                                ^
* src/xheader.c (xheader_string_end): Split calcuation to avoid the
above warning.
---
 src/xheader.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/xheader.c b/src/xheader.c
index b7a54a6..8bcd9ae 100644
--- a/src/xheader.c
+++ b/src/xheader.c
@@ -1027,7 +1027,8 @@ xheader_string_end (struct xheader *xhdr, char const 
*keyword)
     }
   x_obstack_blank (xhdr, p);
   x_obstack_1grow (xhdr, '\n');
-  cp = obstack_next_free (xhdr->stk) - xhdr->string_length - p - 1;
+  cp = obstack_next_free (xhdr->stk);
+  cp -= xhdr->string_length - p - 1;
   memmove (cp + p, cp, xhdr->string_length);
   cp = stpcpy (cp, np);
   *cp++ = ' ';
-- 
2.1.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]