[GHC] #11697: rts/posix/Itimer.c: ignoring return value of ‘read’

#11697: rts/posix/Itimer.c: ignoring return value of ‘read’ -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime | Version: 8.1 System | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Builds currently failing in travis. Eg : https://travis- ci.org/ghc/ghc/jobs/115023819 {{{ rts/posix/Itimer.c: In function ‘itimer_thread_func’: rts/posix/Itimer.c:205:17: error: error: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Werror=unused-result] }}} The code being complained about is: {{{ if (USE_TIMERFD_FOR_ITIMER) { read(timerfd, &nticks, sizeof(nticks)); } else { }}} The value of `nticks` is never used, so a solution to this may be: {{{ if (USE_TIMERFD_FOR_ITIMER) { if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) nticks = 0; } else { }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11697 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11697: rts/posix/Itimer.c: ignoring return value of ‘read’ -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Probably a better solution: {{{ if (USE_TIMERFD_FOR_ITIMER) { int MAYBE_UNUSED rc; rc = read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)); } else { }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11697#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11697: rts/posix/Itimer.c: ignoring return value of ‘read’ -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by erikd: @@ -27,0 +27,3 @@ + + This seems to be a warning that only occurs on Ubuntu, because the Ubuntu + libc has marked the `read` function as `warn_unused_result`. New description: Builds currently failing in travis. Eg : https://travis- ci.org/ghc/ghc/jobs/115023819 {{{ rts/posix/Itimer.c: In function ‘itimer_thread_func’: rts/posix/Itimer.c:205:17: error: error: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Werror=unused-result] }}} The code being complained about is: {{{ if (USE_TIMERFD_FOR_ITIMER) { read(timerfd, &nticks, sizeof(nticks)); } else { }}} The value of `nticks` is never used, so a solution to this may be: {{{ if (USE_TIMERFD_FOR_ITIMER) { if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) nticks = 0; } else { }}} This seems to be a warning that only occurs on Ubuntu, because the Ubuntu libc has marked the `read` function as `warn_unused_result`. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11697#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11697: rts/posix/Itimer.c: ignoring return value of ‘read’ -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:1 erikd]:
Probably a better solution:
IMO, in case of an unexpected return code we should rather emit some error/warning message. I would have fixed this myself a few days ago when this started breaking my `./validate`s but I didn't have time for a proper fix yet and was hoping the author of the patch would beat me providing a fix... PS: phab:rGHC120b9cdb31878ecee442c0a4bb9532a9d30c0c64 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11697#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

IMO, in case of an unexpected return code we should rather emit some error/warning message. I would have fixed this myself a few days ago when
#11697: rts/posix/Itimer.c: ignoring return value of ‘read’ -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Replying to [comment:3 hvr]: this started breaking my `./validate`s but I didn't have time for a proper fix yet and was hoping the author of the patch would beat me providing a fix... Would you prefer something like: {{{ if (USE_TIMERFD_FOR_ITIMER) { if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) sysErrorBelch("Itimer: read(timer_fd) failed"); } else { }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11697#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11697: rts/posix/Itimer.c: ignoring return value of ‘read’ -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): ...yes, definitely better than silencing symptoms...! :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11697#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11697: rts/posix/Itimer.c: ignoring return value of ‘read’ -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D1993 Wiki Page: | -------------------------------------+------------------------------------- Changes (by hvr): * status: new => patch * differential: => phab:D1993 Comment: I see you already made a patch... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11697#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11697: rts/posix/Itimer.c: ignoring return value of ‘read’
-------------------------------------+-------------------------------------
Reporter: erikd | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Runtime System | Version: 8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): phab:D1993
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11697: rts/posix/Itimer.c: ignoring return value of ‘read’ -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D1993 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.2.1 Comment: Merged to `ghc-8.0` as fd3e581b7c9142247601774afc98e49f63b8af45. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11697#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC