[ 
https://issues.apache.org/jira/browse/MYNEWT-688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15942216#comment-15942216
 ] 

Jeff Chan commented on MYNEWT-688:
----------------------------------

+        (void)write(1, msg, sizeof(msg)); <- does not seem to work

----

#pragma works:

+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result" 
+#pragma GCC diagnostic pop 

---

fake use of return works (but seems bad for performance)

+++ b/kernel/os/src/arch/sim/os_fault.c
+    if (1 == write(1, msg, strlen(msg))) {;};


> error: ignoring return value of 'write', declared with attribute 
> warn_unused_result
> -----------------------------------------------------------------------------------
>
>                 Key: MYNEWT-688
>                 URL: https://issues.apache.org/jira/browse/MYNEWT-688
>             Project: Mynewt
>          Issue Type: Bug
>          Components: HAL
>    Affects Versions: v1_0_0_beta1
>         Environment: OS X w/ newt docker container
>            Reporter: Jeff Chan
>            Assignee: Marko Kiiskila
>            Priority: Minor
>             Fix For: v1_0_0_rel
>
>
> Compile fails for native sim target.  Would love to help, but unsure what the 
> official way to ignore the return value is.  GCC compile flag? Macro that 
> uses and discards the result?
> Error: repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c: In function 
> 'hal_uart_blocking_tx':
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c:317:5: error: ignoring 
> return value of 'write', declared with attribute warn_unused_result 
> [-Werror=unused-result]
>      (void) write(uarts[port].u_fd, &data, sizeof(data));
>      ^
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c: In function 'uart_pty':
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c:267:9: error: ignoring 
> return value of 'write', declared with attribute warn_unused_result 
> [-Werror=unused-result]
>          write(1, msg, sizeof(msg));
>          ^
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c:276:5: error: ignoring 
> return value of 'write', declared with attribute warn_unused_result 
> [-Werror=unused-result]
>      write(1, msg, strlen(msg));
>      ^
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c: In function 
> 'uart_set_attr':
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c:240:9: error: ignoring 
> return value of 'write', declared with attribute warn_unused_result 
> [-Werror=unused-result]
>          write(1, msg, sizeof(msg));
>          ^
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c:251:9: error: ignoring 
> return value of 'write', declared with attribute warn_unused_result 
> [-Werror=unused-result]
>          write(1, msg, sizeof(msg));
>          ^
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c: In function 
> 'set_nonblock':
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c:223:9: error: ignoring 
> return value of 'write', declared with attribute warn_unused_result 
> [-Werror=unused-result]
>          write(1, msg, sizeof(msg));
>          ^
> repos/apache-mynewt-core/hw/mcu/native/src/hal_uart.c:228:9: error: ignoring 
> return value of 'write', declared with attribute warn_unused_result 
> [-Werror=unused-result]
>          write(1, msg, sizeof(msg));
>          ^
> Error: repos/apache-mynewt-core/hw/mcu/native/src/hal_system.c: In function 
> 'usage':
> repos/apache-mynewt-core/hw/mcu/native/src/hal_system.c:58:5: error: ignoring 
> return value of 'write', declared with attribute warn_unused_result 
> [-Werror=unused-result]
>      (void) write(2, msg, strlen(msg));
>      ^
> cc1: all warnings being treated as errors



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to