[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B706F@saturn3.aculab.com>
Date: Fri, 26 Oct 2012 10:00:13 +0100
From: "David Laight" <David.Laight@...LAB.COM>
To: "Neil Horman" <nhorman@...driver.com>, <netdev@...r.kernel.org>
Cc: "Vlad Yasevich" <vyasevich@...il.com>,
"David S. Miller" <davem@...emloft.net>,
<linux-sctp@...r.kernel.org>
Subject: RE: [PATCH] sctp: Clean up type-punning in sctp_cmd_t union
> Subject: [PATCH] sctp: Clean up type-punning in sctp_cmd_t union
...
> +#define SCTP_NULL_BYTE 0xAA
> static inline sctp_arg_t SCTP_NULL(void)
> {
> - sctp_arg_t retval; retval.ptr = NULL; return retval;
> + sctp_arg_t retval;
> + memset(&retval, SCTP_NULL_BYTE, sizeof(sctp_arg_t));
> + return retval;
> }
You really don't want to be taking the address of a local
variable that would normally be held in a register.
It stops the compiler doing a lot of optimisations.
In this case the structure is also being returned by value,
not nice except that all(?) modern ABI do pass small structures
in registers.
An assignment of some member of the union to NULL would
seem most appropriate.
OTOH the code that uses this must be someones 'bright idea (tm)'
that probably wasn't such a good idea after all.
David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists