[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #42549] return code of mkoctfile
From: |
Andreas Weber |
Subject: |
[Octave-bug-tracker] [bug #42549] return code of mkoctfile |
Date: |
Fri, 13 Jun 2014 09:24:18 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20140610 Firefox/24.0 Iceweasel/24.6.0 |
URL:
<http://savannah.gnu.org/bugs/?42549>
Summary: return code of mkoctfile
Project: GNU Octave
Submitted by: andy1978
Submitted on: Fri 13 Jun 2014 09:24:16 AM GMT
Category: Libraries
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Regression
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: GNU/Linux
_______________________________________________________
Details:
See also this thead:
http://octave.1599824.n4.nabble.com/mkoctfile-exits-with-0-if-gcc-failed-td4664462.html
and
http://octave.1599824.n4.nabble.com/RE-return-code-of-mkoctfile-td4664466.html
mkoctfile returns 0 if the called subprocess returns != 0.
~/src/octave-src$ LC_ALL=C mkoctfile nonexistentfile.cpp
g++: error: nonexistentfile.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
g++: error: nonexistentfile.o: No such file or directory
~/src/octave-src$ echo $?
0
This is because system returns the exit status of the called process in the
upper 8bits. According to "man wait" WIFEXITED and WEXITSTSTUS should be used
for the bit shifting and masking stuff.
I propose the following patch (hg changeset attached):
diff -r 0ede4dbb37f1 src/mkoctfile.in.cc
--- a/src/mkoctfile.in.cc Sun Mar 30 14:18:43 2014 -0700
+++ b/src/mkoctfile.in.cc Wed Jun 04 14:42:58 2014 +0200
@@ -344,7 +344,10 @@
{
if (debug)
std::cout << cmd << std::endl;
- return system (cmd.c_str ());
+ int result = system (cmd.c_str ());
+ if (WIFEXITED (result))
+ result = WEXITSTATUS (result);
+ return result;
}
If I use the makros WIFEXITED and WEXITSTATUS I get these warnings when
compiling mkoctfile on debian wheezy 64bit with gcc 4.7.2:
mkoctfile.cc: In function ‘int run_command(const string&)’:
mkoctfile.cc:348:7: warning: use of old-style cast [-Wold-style-cast]
mkoctfile.cc:349:14: warning: use of old-style cast [-Wold-style-cast]
The old style cast is defined in /usr/include/stdlib.h:55
#ifdef __USE_BSD
...
#define __WAIT_INT(status) (*(int *) &(status))
Perhaps we should use the octave wrappers like in toplev.cc:
if (octave_wait::ifexited (cmd_status))
cmd_status = octave_wait::exitstatus (cmd_status);
else
cmd_status = 127;
There are also some other definitions of these makros which wouldn't trigger
teh old-style warning:
$ grep -R "define WEXITSTATUS"
liboctave/system/syswait.h:#define WEXITSTATUS(stat_val) ((unsigned)(stat_val)
>> 8)
configure:# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
gnulib-hg/lib/sys_wait.in.h:# define WEXITSTATUS(x) (((x) >> 8) & 0xff)
$ grep -R "define WIFEXITED"
liboctave/system/syswait.h:#define WIFEXITED(stat_val) (((stat_val) & 255) ==
0)
configure:# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
gnulib-hg/lib/sys_wait.in.h:# define WIFEXITED(x) (WTERMSIG (x) == 0)
gnulib-hg/lib/sys_wait.in.h:# define WIFEXITED(x) ((x) != 3)
I'll attach a patch using WIFEXITED and WEXITSTATUS (ignoring the old-style
cast warning)
-- Andy
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?42549>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #42549] return code of mkoctfile,
Andreas Weber <=