With strict static analysis it should complain when return values go ignored.

The canonical way to flag that this is intentional and avoid the warning is to 
cast the result to (void) however any optimizing compiler will correctly omit 
any storage of the result of an ((unused)) variable, so no big deal really if 
it’s done the way you show. It’s likely this came about incrementally in the 
code.

Chris.

From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of "??
Sent: Saturday, July 11, 2020 04:48
To: vpp-dev <vpp-dev@lists.fd.io>
Subject: [EXTERNAL] [vpp-dev] why define an unused var

hi there,

i'm reading vpp code,  and confused with this code: int rv __attribute__ 
((unused)) = write (2, "Main heap allocation failure!\r\n", 31); why it define 
a var named rv, but never used, what dose this var mean to?

git:stable/1609
vpp/vnet/main.c:264
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#16937): https://lists.fd.io/g/vpp-dev/message/16937
Mute This Topic: https://lists.fd.io/mt/75440695/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to