From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFCC433CC8 for ; Thu, 23 Nov 2023 14:47:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hZo0f+CL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BAE1C433C7; Thu, 23 Nov 2023 14:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700750859; bh=+th0nIoDm1aaTnqJ4eM6ZXTyefMOYaMLSlSeSUCjtjc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hZo0f+CLMFYCcBTjYTUawrekLzgsPKFVVK7dGUuLcztUIWJoYKIV31J/zWOdbqLLj +6xJAATodTiRJJy+Ll3TQBa8GaOyS+88QHHEM+Umo985t4LWSqucNd9buqN5s+F0qS d6EFak9zGW7Q2FpFVu1ZI80EbL8iKJYTv1vYpmKAEpFT14Az+2xWh8HY6nbEAkKy77 lfolfJ+gtBOxKChZ03O3eZKtLzn+aQ4Gm3i92Ohi4b8MYhUe1ZkeKd5RaiEc1ZaB72 uo8luPBhZPDY/Gb/gR5fz1DN4o/m0GHjHEIBoqOnHyNDD+nxnDwcKhJ2QSJnaKXGR+ 2So+TMpaoW6sw== Date: Thu, 23 Nov 2023 14:47:35 +0000 From: Lee Jones To: Andy Shevchenko Cc: Linus Walleij , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Machek Subject: Re: [PATCH v1 2/4] leds: trigger: gpio: Convert to use kstrtox() Message-ID: <20231123144735.GB1354538@google.com> References: <20231103195310.948327-1-andriy.shevchenko@linux.intel.com> <20231103195310.948327-2-andriy.shevchenko@linux.intel.com> <20231123110538.GA1243364@google.com> Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, 23 Nov 2023, Andy Shevchenko wrote: > On Thu, Nov 23, 2023 at 11:05:38AM +0000, Lee Jones wrote: > > On Fri, 03 Nov 2023, Andy Shevchenko wrote: > > ... > > > > - ret = sscanf(buf, "%u", &desired_brightness); > > "%u" (see man sscanf() for the details) > > ... > > > > + ret = kstrtou8(buf, 10, &desired_brightness); > > > > Where does 10 come from? > > See above. Hmmm ... I see that this is generally accepted. Although is looks like a recipe for bugs to me. It's a shame we don't have something that can take a variable, derives its type, then calculates the maximum length if converted to a string. Anyway, I'm probably babbling now ... -- Lee Jones [李琼斯]