[klibc] [PATCH] nfsmount: defeat dummypmap compiler warning
maximilian attems
max at stro.at
Thu Feb 23 13:23:56 PST 2012
On Wed, 11 Jan 2012, Greg Thelen wrote:
> Without this patch gcc 4.6 warns:
> KLIBCCC usr/kinit/nfsmount/dummypmap.o
> usr/kinit/nfsmount/dummypmap.c: In function 'dummy_portmap':
> usr/kinit/nfsmount/dummypmap.c:191:13: warning: array subscript is below array bounds [-Warray-bounds]
>
> Signed-off-by: Greg Thelen <gthelen at google.com>
> ---
> usr/kinit/nfsmount/dummypmap.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/usr/kinit/nfsmount/dummypmap.c b/usr/kinit/nfsmount/dummypmap.c
> index 7c5b6bc..7c4da35 100644
> --- a/usr/kinit/nfsmount/dummypmap.c
> +++ b/usr/kinit/nfsmount/dummypmap.c
> @@ -150,7 +150,7 @@ static int dummy_portmap(int sock, FILE *portmap_file)
> int pktlen, addrlen;
> unsigned char pkt[65536]; /* Max UDP packet size */
> /* RPC UDP packets do not include TCP fragment size */
> - struct rpc_call *rpc = (struct rpc_call *) &pkt[-4];
> + struct rpc_call *rpc = (struct rpc_call *)((uintptr_t)pkt - 4);
> struct rpc_auth *cred;
> struct rpc_auth *vrf;
> struct portmap_args *args;
hmm suspect this looks like papering, please
hpa has the following suggestion:
"I would actually be happier making pkt a union/structure with a (dummy)
fragment size header
Wasting 4 bytes on the stack is not an issue here
I'd actually suggest we do:
union {
struct rpc_call rpc;
char pkt[65536+4];
} pkt;
And just load the packet at &rpc.hdr.udp"
thanks.
--
maks
More information about the klibc
mailing list