Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2490778rwp; Fri, 14 Jul 2023 07:02:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlEtoytunUgr7FQxu7ABAiZKEnJJOpniEZSgflCs37toPL7u2BBPvllUl504UJY/4+aG/vLx X-Received: by 2002:a05:6a20:160a:b0:12e:65f8:10dd with SMTP id l10-20020a056a20160a00b0012e65f810ddmr4097645pzj.53.1689343367946; Fri, 14 Jul 2023 07:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689343367; cv=none; d=google.com; s=arc-20160816; b=z4UDST3s7ASflIbqWCqfhnIKplruboSpLDGDT1K8H8g9pYqEOhuKc+Zv7Ki1XPCdQd FU+kcWvR5n2i8OUUev6Lg7csnLK9Ksx7g8VKqQ7yJ5E/uosWXVfNFUxNXsOZ63gN9bUo mHCWgCmMQUxsPWs8bGI4Mod6/MjPX9tB9JvUO4/ID7tue8TIDOmN9wqBGKM31zwb9ACC Cx4lekZmFKDXj135bZxIfefT9dPthk/Eerv8XENKVZMClzLa7LAO/3zqnuvWp8URm6Y8 5UFJumxkYau8iy1qG88KEdsVK4WHjvHch4xaLbB8rINRAEppkyDzY+ng6v+Vf73CqPxF CXtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9ehiH+nJa6KAQHmBUdX/E6O673kcIIwUhMgPN51VMJA=; fh=hQdPDCK+jD4i5EelvNVKW62n7yKJATCzP87mBSSEsK0=; b=HLW58Yi+dqmPfER78SV6rg1kInBfcXl5gmD4oQZW6GPght9FA83pHY1yyQ9AX77HzT oUjZbA3bEBvZwdQuAX3bgEjQPVX5ZoPBp1WYX6awUZeda4TDRCKVah1xTSIb0YoU4KFw DVI3bsPq6fyQh2w/c1M6gzhpE9P5yMr1AYWo2HvqrP3NNuM3xD05E3mCKCEd7wn+pPtJ Q/zP+fheRPqhM01Hr3zT9ygGYroudg2bdkFI6d1Dl7vjfgejHAarxXy9jHoGDYKFFLja k01sL2OqMd+gnfsVLDfWirDtgiqvA0BrwD+kC48Y3b+CAcVTundEh2uIHMAOiAla8eaB UazQ== 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 dw11-20020a056a00368b00b00682a0e45b59si2483706pfb.85.2023.07.14.07.02.35; Fri, 14 Jul 2023 07:02:47 -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 S235756AbjGNNtp (ORCPT + 99 others); Fri, 14 Jul 2023 09:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235510AbjGNNtm (ORCPT ); Fri, 14 Jul 2023 09:49:42 -0400 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A8AF3580; Fri, 14 Jul 2023 06:49:41 -0700 (PDT) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-3fbc6ab5ff5so17647465e9.1; Fri, 14 Jul 2023 06:49:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689342580; x=1691934580; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9ehiH+nJa6KAQHmBUdX/E6O673kcIIwUhMgPN51VMJA=; b=KQpHRNzV9d4rrGez7i5omKcEbADoom4mJ8ZEHRHQ5PEy9sG0IYvjW9tcm2vVX4IQPq e31HrZZeNLr9+QcFcZH7LxOJ/ph0d09C7MPZTiOD+w5A/Fmvi733AaV7SxthTxo9Vcjl buv0qODvX769MqoWNCjn5SLSpbaAVnXiebNnakYGzbQ4jD0IMwddmTUbiqtzhawIB6Ml /CA7WyAL8wB7MDg/QUQN/1xV1oGSgB1xbvDmfq0p6fLVdLUIbkn+7AMwzwq2HUGgcpks 34g9G+DvH+KqhAvvdGAzV/zUcUpFwzBOofOVed9rBqsgvlsFed+5+m17fkr5V5OENV3X /glQ== X-Gm-Message-State: ABy/qLbV7G4lOlwuIkvt36umUEho9qwaD6uL0CeGGz63iGatbaKjZM9S WkiY+kY70RvueIaUQaQrM+E= X-Received: by 2002:a05:600c:240a:b0:3f9:b430:199b with SMTP id 10-20020a05600c240a00b003f9b430199bmr3992071wmp.15.1689342579485; Fri, 14 Jul 2023 06:49:39 -0700 (PDT) Received: from gmail.com (fwdproxy-cln-018.fbsv.net. [2a03:2880:31ff:12::face:b00c]) by smtp.gmail.com with ESMTPSA id j18-20020a5d4492000000b00315a1c160casm10900178wrq.99.2023.07.14.06.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 06:49:39 -0700 (PDT) Date: Fri, 14 Jul 2023 06:49:37 -0700 From: Breno Leitao To: Petr Mladek Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , sergey.senozhatsky@gmail.com, tj@kernel.org, stephen@networkplumber.org, Dave Jones , "open list:NETWORKING [GENERAL]" , "open list:DOCUMENTATION" , open list Subject: Re: [PATCH v2] netconsole: Append kernel version to message Message-ID: References: <20230707132911.2033870-1-leitao@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, 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 On Fri, Jul 14, 2023 at 01:41:55PM +0200, Petr Mladek wrote: > On Fri 2023-07-07 06:29:11, Breno Leitao wrote: > > @@ -254,6 +267,11 @@ static ssize_t extended_show(struct config_item *item, char *buf) > > return snprintf(buf, PAGE_SIZE, "%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); > > I have learned recently that sysfs_emit() was preferred over snprintf() in the > _show() callbacks. I didn't know either, I just read about it in the thread. Thanks for the heads up. We probably want to change it for the other _show() structs. > > +} > > + > > 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); > > @@ -366,6 +389,38 @@ static ssize_t enabled_store(struct config_item *item, > > return err; > > } > > > > +static ssize_t release_store(struct config_item *item, const char *buf, > > + size_t count) > > +{ > > + struct netconsole_target *nt = to_target(item); > > + int release; > > + int err; > > + > > + mutex_lock(&dynamic_netconsole_mutex); > > + if (nt->enabled) { > > + pr_err("target (%s) is enabled, disable to update parameters\n", > > + config_item_name(&nt->item)); > > + err = -EINVAL; > > + goto out_unlock; > > + } > > + > > + err = kstrtoint(buf, 10, &release); > > + if (err < 0) > > + goto out_unlock; > > + if (release < 0 || release > 1) { > > + err = -EINVAL; > > + goto out_unlock; > > + } > > You might consider using: > > bool enabled; > > err = kstrtobool(buf, &enabled); > if (err) > goto unlock; > > > It accepts more input values, for example, 1/0, y/n, Y/N, ... > > Well, I see that kstrtoint() is used also in enabled_store(). > It might be confusing when "/enabled" supports only "1/0" > and "/release" supports more variants. Right. we probably want to move a few _stores to kstrtobool(). Here is what I have in mind: * enabled_store() * release_store() * extended_store() That said, there are two ways moving forward: 1) I forward fix it. I've send v3 earlier today[1], I can send a patch on top of it. 2) I fix this in a v4 patch. Probably a patchset of 3 patches: a) Move the current snprintf to emit_sysfs() b) Move kstrtoint() to kstrtobool() c) This new feature using emit_sysfs() and kstrtobool(). What is the best way moving forward? Thanks for the review! [1] Link: https://lore.kernel.org/all/20230714111330.3069605-1-leitao@debian.org/