Hi Brad and Greg,
Sorry, I tested Greg's new patch but it did not work.
I will attach two patches to fix the warnings. I confirmed
that I got no warning with them.
One is the patch for files.cpp which adds error handling
when fscanf() fails.
The other is for comm-gasnet.c. It avoids the warning using
a wrapper function of write(). This is an ugly way but does
not seem to break the runtime on other compilers.
Thanks,
-
Jun
Hi Jun --
I think that we could probably put together a fix for the
first issue as well, though we don't have a gcc compiler
that will generate these warnings (that I know of), so if
there are others lurking behind this one, we might not
catch those. Are you able to assemble and submit a patch
that would address it (by tomorrow for the code freeze,
I'm sorry to say).
-Brad
On Mon, 31 Mar 2014, [email protected] wrote:
Hi Jun, all --
I will fix the 2nd warning, in comm-gasnet.c.
greg
On Mon, 31 Mar 2014, Jun Nakashima wrote:
When I ran the nightly test on Ubuntu Linux 13.10 with gcc
4.8.0, I got two compile warnings treated as errors:
The one has occured when compiling util/files.cpp in the
compiler.
--
files.cpp: In function 'const char*
mysystem_getresult(const
char*, const char*,
int)':
files.cpp:373:41: error: ignoring return value of 'int
fscanf(FILE*, const char*
, ...)', declared with attribute warn_unused_result
[-Werror=unused-result]
fscanf(systemFile->fptr, "%s", result);
--
The other has occured when compiling
src/comm/gasnet/comm-gasnet.c in the runtime.
--
comm-gasnet.c: In function 'AM_fork_fast':
comm-gasnet.c:142:10: error: ignoring return value of
'write', declared with att
ribute warn_unused_result [-Werror=unused-result]
write(2, mybuf, strlen(mybuf));
--
Both of the errors warn the return values are ignored. Thus
it may be fixed by handling the results correctly.
FYI, when I do the same on Debian squeeze with gcc 4.4.5 I
got no error. I guess these warnings are recently appended
to gcc.
-
Jun Nakashima
The University of Tokyo
------------------------------------------------------------------------------
_______________________________________________
Chapel-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-bugs
------------------------------------------------------------------------------
_______________________________________________
Chapel-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-bugs
Index: compiler/util/files.cpp
===================================================================
--- compiler/util/files.cpp (ãªãã¸ã§ã³ 23026)
+++ compiler/util/files.cpp (使¥ã³ãã¼)
@@ -370,7 +370,9 @@
char* result = (char*)malloc(256*sizeof(char));
mysystem(astr(command, " > ", fullSystemFilename), description, ignorestatus);
fileinfo* systemFile = openTmpFile(systemFilename, "r");
- fscanf(systemFile->fptr, "%s", result);
+ if (fscanf(systemFile->fptr, "%s", result) != 1){
+ strcpy(result,"");
+ }
closefile(systemFile);
return astr(result); // canonicalize
}
Index: runtime/src/comm/gasnet/comm-gasnet.c
===================================================================
--- runtime/src/comm/gasnet/comm-gasnet.c (ãªãã¸ã§ã³ 23026)
+++ runtime/src/comm/gasnet/comm-gasnet.c (使¥ã³ãã¼)
@@ -132,6 +132,12 @@
#define EXIT_ANY 137 // free data at addr
#define BCAST_SEGINFO 138 // broadcast for segment info table
+// An ugly hack to avoid warning on GCC 4.8.0
+static ___always_inline int write_wrapper(int fd, char *buf, size_t s)
+{
+ return write(fd,buf,s);
+}
+
static void AM_fork_fast(gasnet_token_t token, void* buf, size_t nbytes) {
fork_t *f = buf;
@@ -139,7 +145,7 @@
char mybuf[128];
sprintf(mybuf, "%d: running (fast) remote task created by %d\n",
chpl_nodeID, f->caller);
- write(2, mybuf, strlen(mybuf));
+ write_wrapper(1, mybuf, strlen(mybuf));
}
if (f->arg_size)
------------------------------------------------------------------------------
_______________________________________________
Chapel-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-bugs