Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10649970rwp; Fri, 21 Jul 2023 02:43:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlH7KlKEXpFbkVPvLb2saSWdLViZ/W28t3Xlx5jzvG4Sip1TRobz0mWJMH9naOteFpQUx6gx X-Received: by 2002:a17:906:3009:b0:988:797c:759c with SMTP id 9-20020a170906300900b00988797c759cmr1204340ejz.69.1689932609624; Fri, 21 Jul 2023 02:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689932609; cv=none; d=google.com; s=arc-20160816; b=N3NNQxQvfYBcmKueI7kcmzujSOxU7AmkjQlwvWu3Dg/OeSrM4QwjWm/Y2YJCe6Orzz 4dJgJoAvObMSNmxnHZ9Qe7kJ4KCVUQqmBpwxidirOQueaVqsrsO17s0TH+h3f/jYNs00 woEoQHxaT06oE8Mc5YSBmQl/3cp+UnL98oruYJtNRSAi144Y5V9Q7t18v54iEuDDHO+0 lyjWhPmUD7cJhoAQ9M9h3+xya0UQjIsGQ4NgcnUEhfsMpv/5Ui+GvCIh9Qt8ENg1hTIk nXPa5Xoms4rpn+XtZpM6QgrIvdPkFRgob5mCOFzQOAAaHHljWExt0MrHnG18ZmgAndVA wqyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nffHfmIGWBNnYrHHaoebYbm1P0ZPQ4FxstxDXTgR2ek=; fh=7RuZVHvwAj74FNHTgOXk6lvFEXP3wdynNPCTlYZdPBk=; b=V4K153qCkRJdwFLLu6D9mSMKEUViiN5mVQmWcVbiB6b0A26hPSJ3K0IYLhYgZG5GTB ox3Y9kPghRDbedSEOZDijXJ1SB4gq2TgnFQrhQG9vj3TEjq/cWRYybwyxtislrYxWkdM uWa57czLM6NzoPoDUz+rDqsR0wmSVwrFRLXq/kRPpCkjYRj3nR14s8QW7yrdt6ta6Edl qySDILrCy7VfCi2FYoC/dwrZXCTMlChgwmfoDeHeUaRg5XgG3LNMlEZaKsx410HEC5UO irh6iO73DzaM/RGUtvHFaBHHSUXD3v2bEjnn6xjSHcuyFX+wwDuJid7e4CzOVKcz6ieB IZFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a17090613cc00b00991f1e4b03dsi1809071ejc.406.2023.07.21.02.43.02; Fri, 21 Jul 2023 02:43:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbjGUJWM (ORCPT + 99 others); Fri, 21 Jul 2023 05:22:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231752AbjGUJWC (ORCPT ); Fri, 21 Jul 2023 05:22:02 -0400 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91F8C30D7; Fri, 21 Jul 2023 02:22:00 -0700 (PDT) Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-992ca792065so267324766b.2; Fri, 21 Jul 2023 02:22:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689931319; x=1690536119; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nffHfmIGWBNnYrHHaoebYbm1P0ZPQ4FxstxDXTgR2ek=; b=X9meTX17x8yJaG8IIV6000QQx46DxXf+I1hyIOGxeZ1d9d5pPUHoMwL9OZG8LS8dJj jB/nbe8eyISiwTKxhLNWK2sP/G4FeC3ClWhedhEktMa6i8doKr9Dx0gwwAwNEStDosOz q4SPXbNwwo9rMja8r+NnTYUfhC0OSwH8rh4o1hBdj+VVICSZuzaAQ3e64tLexIUDFmFq 1Ukq88zvQGPlM4C6cO/8HDCCOuQkSyvdn4cb2lsXcTiDDK4ZpyId46S+8mX39wsV8r/Y g9gwjGMrxAG4u2BubrY9kxsF4ehDdg5zfpIcukhmMzGQ/riJLqywLbIOTixcSd00s0hj 4S5g== X-Gm-Message-State: ABy/qLYmDmXykGwK+eRN5wyZbfzhAyYyvFQlRZ7m2NiKN2flKBGQr/Gw AANXzHjLzVFBgTAtRSZJTVo= X-Received: by 2002:a17:906:51c2:b0:99b:5cce:9746 with SMTP id v2-20020a17090651c200b0099b5cce9746mr1221087ejk.52.1689931318643; Fri, 21 Jul 2023 02:21:58 -0700 (PDT) Received: from localhost (fwdproxy-cln-012.fbsv.net. [2a03:2880:31ff:c::face:b00c]) by smtp.gmail.com with ESMTPSA id j1-20020a170906254100b00992076f4a01sm1885080ejb.190.2023.07.21.02.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:21:58 -0700 (PDT) From: Breno Leitao To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: leit@meta.com, Petr Mladek , netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 1/2] netconsole: Use sysfs_emit() instead of snprintf() Date: Fri, 21 Jul 2023 02:21:44 -0700 Message-Id: <20230721092146.4036622-1-leitao@debian.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to the sysfs.rst documentation, _show() functions should only use sysfs_emit() instead of snprintf(). Since snprintf() shouldn't be used in the sysfs _show() path, replace it by sysfs_emit(). Suggested-by: Petr Mladek Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 31cbe02eda49..a3c53b8c9efc 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -260,32 +260,32 @@ static struct netconsole_target *to_target(struct config_item *item) static ssize_t enabled_show(struct config_item *item, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->enabled); + return sysfs_emit(buf, "%d\n", to_target(item)->enabled); } static ssize_t extended_show(struct config_item *item, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->extended); + return sysfs_emit(buf, "%d\n", to_target(item)->extended); } static ssize_t release_show(struct config_item *item, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->release); + return sysfs_emit(buf, "%d\n", to_target(item)->release); } static ssize_t dev_name_show(struct config_item *item, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", to_target(item)->np.dev_name); + return sysfs_emit(buf, "%s\n", to_target(item)->np.dev_name); } static ssize_t local_port_show(struct config_item *item, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.local_port); + return sysfs_emit(buf, "%d\n", to_target(item)->np.local_port); } static ssize_t remote_port_show(struct config_item *item, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.remote_port); + return sysfs_emit(buf, "%d\n", to_target(item)->np.remote_port); } static ssize_t local_ip_show(struct config_item *item, char *buf) @@ -293,9 +293,9 @@ static ssize_t local_ip_show(struct config_item *item, char *buf) struct netconsole_target *nt = to_target(item); if (nt->np.ipv6) - return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6); + return sysfs_emit(buf, "%pI6c\n", &nt->np.local_ip.in6); else - return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); + return sysfs_emit(buf, "%pI4\n", &nt->np.local_ip); } static ssize_t remote_ip_show(struct config_item *item, char *buf) @@ -303,9 +303,9 @@ static ssize_t remote_ip_show(struct config_item *item, char *buf) struct netconsole_target *nt = to_target(item); if (nt->np.ipv6) - return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6); + return sysfs_emit(buf, "%pI6c\n", &nt->np.remote_ip.in6); else - return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); + return sysfs_emit(buf, "%pI4\n", &nt->np.remote_ip); } static ssize_t local_mac_show(struct config_item *item, char *buf) @@ -313,12 +313,12 @@ static ssize_t local_mac_show(struct config_item *item, char *buf) struct net_device *dev = to_target(item)->np.dev; static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - return snprintf(buf, PAGE_SIZE, "%pM\n", dev ? dev->dev_addr : bcast); + return sysfs_emit(buf, "%pM\n", dev ? dev->dev_addr : bcast); } static ssize_t remote_mac_show(struct config_item *item, char *buf) { - return snprintf(buf, PAGE_SIZE, "%pM\n", to_target(item)->np.remote_mac); + return sysfs_emit(buf, "%pM\n", to_target(item)->np.remote_mac); } /* -- 2.34.1