From patchwork Mon Mar 21 02:31:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Wendling X-Patchwork-Id: 12786756 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 597AEC433F5 for ; Mon, 21 Mar 2022 02:32:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344179AbiCUCd0 (ORCPT ); Sun, 20 Mar 2022 22:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243021AbiCUCdZ (ORCPT ); Sun, 20 Mar 2022 22:33:25 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84929179430 for ; Sun, 20 Mar 2022 19:32:01 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id h16-20020a056902009000b00628a70584b2so11035641ybs.6 for ; Sun, 20 Mar 2022 19:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=boRSKJ2tOd7N5XEAa4B8sR46+PMs9h1rt8wOI6es9nU=; b=e+DYSJ6J4paaD5hjVJ9z6K3g9Dlc5iJR/piV9wrM7WrJ62idld4T8gp1NZeiabtn75 m4fc6XPBgq8fwxOKGaCHlORLI0CKCHWQahMug7WecFa9t+Did6gkp+Ruil0tcsW2gWp4 WG6FAKuS+XCAQ34muSpOMVixjI7Bw3mDUHdOjTgYD4PFKNEY6xHkkqMcAV3MyNx/paqb nVZ8XJ0tzt0qGIbw5XfG/s0xpaCVpyDXkpZTO0JCCijAhOvoHbLMPlxTMrFrFR0pRBz8 VcYeka/aU89nRe2QkdTfRzYwlLXrsXPOKlppn9kCfY7Y6tbefdlzWbLqUJNBxm5UjU9n m0VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=boRSKJ2tOd7N5XEAa4B8sR46+PMs9h1rt8wOI6es9nU=; b=PpRl60dGvnGXp2fHMPATDBSjCwTkBiuFnc6W2MYtmt+JPW0m5S17PK+AfqTxrQ2AJX +hTVvgR1+VpP4Xc10JFFbeuwsUhNtVnwCZA0aNsBPeuICGCuT9ANQwTT4hULKu2B6geU Yfe7mGcWFOBBZPddql/2Pb7r8h4ockZDuuUWUA6yBr2LRDDwRQ6NgKcRQOfxbB0IqZs4 Ks88gK2GFN/9XO0fpxznxR/OSvPNcI6VK6NzxWSYvav9dbUtNrMutaRpEP73DjUez0K/ pApUnltYUH9b/Uaq4R5x2iIflpl6v6XgXe8K4IdnX+dYGFOuoSJtpOX9baiCFx3r94WS WRGA== X-Gm-Message-State: AOAM533lmWQIgb8okoiQtU10iwjuhdH8VW0w5z/fJl+77zeD6qudDO4X IrnjVJdns1q9U/QoOwGMreq0OWmb X-Google-Smtp-Source: ABdhPJyzrvk3yeBbTRFVV+NGZxPwVpkPI8MBUPHkVocMLRjo1fQjiUwhSHaaXmPhtnYe163M9H0VAvC6qw== X-Received: from fawn.svl.corp.google.com ([2620:15c:2cd:202:27bd:2eea:bd8:2ea5]) (user=morbo job=sendgmr) by 2002:a25:86cf:0:b0:633:8702:1bb3 with SMTP id y15-20020a2586cf000000b0063387021bb3mr20571751ybm.515.1647829920673; Sun, 20 Mar 2022 19:32:00 -0700 (PDT) Date: Sun, 20 Mar 2022 19:31:55 -0700 Message-Id: <20220321023155.106066-1-morbo@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.894.gb6a874cedc-goog Subject: [PATCH] bnx2x: truncate value to original sizing From: Bill Wendling To: Ariel Elior , Sudarsana Kalluru , Manish Chopra , "David S . Miller" , Jakub Kicinski , Nathan Chancellor , Nick Desaulniers , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Bill Wendling Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The original behavior was to print out unsigned short or unsigned char values. The change in commit d65aea8e8298 ("bnx2x: use correct format characters") prints out the whole value if not truncated. So truncate the value to an unsigned {short|char} to retain the original behavior. Fixes: d65aea8e8298 ("bnx2x: use correct format characters") Link: https://github.com/ClangBuiltLinux/linux/issues/378 Signed-off-by: Bill Wendling --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c index bede16760388..7071604f9984 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c @@ -6178,7 +6178,8 @@ static int bnx2x_format_ver(u32 num, u8 *str, u16 *len) return -EINVAL; } - ret = scnprintf(str, *len, "%x.%x", num >> 16, num); + ret = scnprintf(str, *len, "%x.%x", (num >> 16) & 0xFFFF, + num & 0xFFFF); *len -= ret; return 0; } @@ -6193,7 +6194,8 @@ static int bnx2x_3_seq_format_ver(u32 num, u8 *str, u16 *len) return -EINVAL; } - ret = scnprintf(str, *len, "%x.%x.%x", num >> 16, num >> 8, num); + ret = scnprintf(str, *len, "%x.%x.%x", (num >> 16) & 0xFF, + (num >> 8) & 0xFF, num & 0xFF); *len -= ret; return 0; }