From: Stephen Hemminger Subject: [PATCH iproute2] ipmacsec: fix warning on 32bit platform Date: Mon, 10 Dec 2018 13:49:48 -0800 Message-ID: <20181210214947.5562-1-stephen@networkplumber.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Stephen Hemminger To: netdev@vger.kernel.org Return-path: Received: from mail-pl1-f195.google.com ([209.85.214.195]:42852 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbeLJVuE (ORCPT ); Mon, 10 Dec 2018 16:50:04 -0500 Received: by mail-pl1-f195.google.com with SMTP id y1so5862260plp.9 for ; Mon, 10 Dec 2018 13:50:04 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: On some 32 bit platforms, the printf was causing warning: ipmacsec.c: In function ‘getattr_u64’: ipmacsec.c:655:47: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] fprintf(stderr, "invalid attribute length %lu\n", Resolve by computing length as size_t first. Signed-off-by: Stephen Hemminger --- ip/ipmacsec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ip/ipmacsec.c b/ip/ipmacsec.c index 9b991065e483..54cd2b8c97e4 100644 --- a/ip/ipmacsec.c +++ b/ip/ipmacsec.c @@ -640,9 +640,11 @@ static void print_attrs(struct rtattr *attrs[]) } } -static __u64 getattr_u64(struct rtattr *stat) +static __u64 getattr_u64(const struct rtattr *stat) { - switch (RTA_PAYLOAD(stat)) { + size_t len = RTA_PAYLOAD(stat); + + switch (len) { case sizeof(__u64): return rta_getattr_u64(stat); case sizeof(__u32): @@ -652,8 +654,8 @@ static __u64 getattr_u64(struct rtattr *stat) case sizeof(__u8): return rta_getattr_u8(stat); default: - fprintf(stderr, "invalid attribute length %lu\n", - RTA_PAYLOAD(stat)); + fprintf(stderr, "invalid attribute length %zu\n", + len); exit(-1); } } -- 2.19.2