Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writes to log file are not error checked #12

Closed
ralphlange opened this issue Sep 22, 2016 · 1 comment
Closed

Writes to log file are not error checked #12

ralphlange opened this issue Sep 22, 2016 · 1 comment
Assignees

Comments

@ralphlange
Copy link
Owner

The calls to write() when procServ is writing to the log file are not checked for errors.

procServ.cc: In function 'void SendToAll(const char*, int, const connectionItem*)':
procServ.cc:662:53: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
                         write(logFileFD, stamp, len);
                                                     ^
procServ.cc:666:59: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
                         write(logFileFD, message+j, i-j+1);
                                                           ^
procServ.cc:671:53: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
                 write(logFileFD, message+j, count-j);  // finish off rest of line with no newline at end
                                                     ^
procServ.cc:673:49: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
                 write(logFileFD, message, count);
                                                 ^
procServ.cc:677:77: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
         if (inFgMode == false && debugFD > 0) write(debugFD, message, count);
                                                                             ^
procServ.cc: In function 'void forkAndGo()':
procServ.cc:823:16: warning: ignoring return value of 'int dup(int)', declared with attribute warn_unused_result [-Wunused-result]
         dup(fh); dup(fh); dup(fh);
                ^
procServ.cc:823:25: warning: ignoring return value of 'int dup(int)', declared with attribute warn_unused_result [-Wunused-result]
         dup(fh); dup(fh); dup(fh);
                         ^
procServ.cc:823:34: warning: ignoring return value of 'int dup(int)', declared with attribute warn_unused_result [-Wunused-result]
         dup(fh); dup(fh); dup(fh);
                                  ^
[...]
clientFactory.cc: In constructor 'clientItem::clientItem(int, bool)':
clientFactory.cc:137:51: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
         write( _fd, greeting1, strlen(greeting1) );
                                                   ^
clientFactory.cc:138:51: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
         write( _fd, greeting2, strlen(greeting2) );
                                                   ^
clientFactory.cc:141:53: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
     write( _fd, infoMessage1, strlen(infoMessage1) );
                                                     ^
clientFactory.cc:142:53: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
     write( _fd, infoMessage2, strlen(infoMessage2) );
                                                     ^
clientFactory.cc:143:37: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
     write( _fd, buf1, strlen(buf1) );
                                     ^
clientFactory.cc:145:41: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
         write( _fd, buf2, strlen(buf2) );
                                         ^
clientFactory.cc:147:57: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
         write( _fd, infoMessage3, strlen(infoMessage3) );
                                                         ^
@ralphlange ralphlange added the bug label Sep 22, 2016
@ralphlange ralphlange self-assigned this Sep 22, 2016
@ralphlange
Copy link
Owner Author

I will add the boilerplate code to programmatically ignore the return code in these cases.
I don't see any reasonable way to handle errors at these places:

  • Errors writing to the log. Errors should be logged. But when logging produces errors, this makes no sense.
  • Errors sending to a client. I am afraid that flaky client connections would be filling up the log. In case of network issues and logging across the network, buffers would fill up quickly.

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

No branches or pull requests

1 participant