Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Compilation failure error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result] #11

Closed
kianmeng opened this issue Sep 5, 2017 · 7 comments · Fixed by #12

Comments

@kianmeng
Copy link

kianmeng commented Sep 5, 2017

GCC version.

$ cc --version
cc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Errors.

$ make
mkdir -p /home/foobar/.estx
cp stx/* /home/foobar/.estx
mkdir -p bin/
cc main.c src/clipboard.c src/editor.c src/buffer.c src/util.c src/colors.c src/syntax.c -DSTXDIR=\"/home/foobar/.estx\" -o bin/e -Werror -Wall -g -fPIC -O2 -DNDEBUG -ftrapv -Wfloat-equal -Wundef -Wwrite-strings -Wuninitialized -pedantic -std=c11
src/editor.c: In function ‘e_die’:
src/editor.c:24:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   write(STDOUT_FILENO, "\x1b[2J\x1b[?47l\x1b""8", 12);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor.c: In function ‘e_exit’:
src/editor.c:31:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   write(STDOUT_FILENO, "\x1b[2J\x1b[?47l\x1b""8", 12);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor.c: In function ‘e_clear_screen’:
src/editor.c:214:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   write(STDOUT_FILENO, ab.b, ab.len);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/editor.c: In function ‘e_setup’:
src/editor.c:1214:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   write(STDOUT_FILENO, "\x1b""7\x1b[?47h", 8);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
src/syntax.c: In function ‘syntax_read_extensions’:
src/syntax.c:26:5: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
     fgets(line, MAX_LINE_WIDTH, f);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/syntax.c: In function ‘syntax_read_pattern’:
src/syntax.c:55:5: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
     fgets(line, MAX_LINE_WIDTH, f);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:11: recipe for target 'all' failed
make: *** [all] Error 1
hellerve added a commit that referenced this issue Sep 5, 2017
@hellerve
Copy link
Owner

hellerve commented Sep 5, 2017

Thanks for the report! Sadly I cannot reproduce this, GCC 7 on OS X seems to work just fine. I fixed the errors that threw off your compiler and pushed my fixes into the branch fix-unused-result. Could you try whether it works with this branch?

@manu-chroma
Copy link

Using branch fix-unused-result

~/github/e · (fix-unused-result) $ gcc --version   
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609


~/github/e · (fix-unused-result) $ make 
mkdir -p /home/manu/.estx
cp stx/* /home/manu/.estx
mkdir -p bin/
cc main.c src/clipboard.c src/editor.c src/buffer.c src/util.c src/colors.c src/syntax.c -DSTXDIR=\"/home/manu/.estx\" -o bin/e -Werror -Wall -g -fPIC -O2 -DNDEBUG -ftrapv -Wfloat-equal -Wundef -Wwrite-strings -Wuninitialized -pedantic -std=c11
src/editor.c: In function ‘e_die’:
src/editor.c:24:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   (void)write(STDOUT_FILENO, "\x1b[2J\x1b[?47l\x1b""8", 12);
   ^
src/editor.c: In function ‘e_exit’:
src/editor.c:31:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   (void)write(STDOUT_FILENO, "\x1b[2J\x1b[?47l\x1b""8", 12);
   ^
src/editor.c: In function ‘e_clear_screen’:
src/editor.c:214:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   (void)write(STDOUT_FILENO, ab.b, ab.len);
   ^
src/editor.c: In function ‘e_setup’:
src/editor.c:1214:3: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   (void)write(STDOUT_FILENO, "\x1b""7\x1b[?47h", 8);
   ^
cc1: all warnings being treated as errors
src/syntax.c: In function ‘syntax_read_extensions’:
src/syntax.c:26:5: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
     (void)fgets(line, MAX_LINE_WIDTH, f);
     ^
src/syntax.c: In function ‘syntax_read_pattern’:
src/syntax.c:55:5: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
     (void)fgets(line, MAX_LINE_WIDTH, f);
     ^
cc1: all warnings being treated as errors
Makefile:11: recipe for target 'all' failed
make: *** [all] Error 1

@hellerve
Copy link
Owner

hellerve commented Sep 5, 2017

Okay, thats quite interesting. Ill set up a debug VM and get back to you once I've fixed it for good, okay?

@LuRsT
Copy link

LuRsT commented Sep 6, 2017

Same here on Linux

hellerve added a commit that referenced this issue Sep 6, 2017
@hellerve
Copy link
Owner

hellerve commented Sep 6, 2017

It should work now; could any of you verify the fix in fix-unused-result actually works so that I can merge it and close the issue?

@LuRsT
Copy link

LuRsT commented Sep 6, 2017

It does work! But after running sudo make install, /usr/local/bin/e just exits with an error:

$ e
$ echo $?
13

@hellerve
Copy link
Owner

hellerve commented Sep 6, 2017

I’m not sure this issue is related, and I’m going to close this for now. I can, however, reproduce this on Ubuntu and will open a new issue for this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants