bug-groff
[Top][All Lists]
Advanced

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

[PATCH] groff, fix pushback.cpp dup warnings


From: g . esp
Subject: [PATCH] groff, fix pushback.cpp dup warnings
Date: Sat, 2 Feb 2013 15:04:23 +0100 (CET)

Fix those warnings
pushback.cpp: In destructor 'pushBackBuffer::~pushBackBuffer()':
pushback.cpp:90: warning: ignoring return value of 'int dup(int)', declared 
with attribute warn_unused_result
pushback.cpp: In destructor 'pushBackBuffer::~pushBackBuffer()':
pushback.cpp:90: warning: ignoring return value of 'int dup(int)', declared 
with attribute warn_unused_result
pushback.cpp: In destructor 'pushBackBuffer::~pushBackBuffer()':
pushback.cpp:90: warning: ignoring return value of 'int dup(int)', declared 
with attribute warn_unused_result

visible on unhardened gcc-4.4 with PAGE=letter ./configure --prefix=/usr 
CPPFLAGS="-D_FORTIFY_SOURCE=2" && make

Patch is attached too if inline version is wrapped

Gilles

Index: src/preproc/html/pushback.cpp
===================================================================
RCS file: /sources/groff/groff/src/preproc/html/pushback.cpp,v
retrieving revision 1.8
diff -u -r1.8 pushback.cpp
--- src/preproc/html/pushback.cpp       5 Jan 2009 20:11:08 -0000       1.8
+++ src/preproc/html/pushback.cpp       2 Feb 2013 13:38:43 -0000
@@ -71,6 +71,9 @@
   lineNo   = 1;
   if (strcmp(filename, "") != 0) {
     stdIn = dup(0);
+    if (stdIn<0) {
+      sys_fatal("dup stdin");
+    }
     close(0);
     if (open(filename, O_RDONLY) != 0) {
       sys_fatal("when trying to open file");
@@ -87,7 +90,9 @@
   }
   close(0);
   /* restore stdin in file descriptor 0 */
-  dup(stdIn);
+  if (dup(stdIn)<0) {
+    sys_fatal("restore stdin");
+  }
   close(stdIn);
 }
 

Attachment: groff_dup.patch
Description: Text Data


reply via email to

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