Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp718420ybh; Wed, 18 Mar 2020 07:56:13 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs9RPNR5Aaa8Kshsa3O04EEOkNwAdmhnhENcY3exdfRASIs2K1W/oncE/F4NKs4Zkde569U X-Received: by 2002:aca:4d13:: with SMTP id a19mr3350324oib.105.1584543373393; Wed, 18 Mar 2020 07:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584543373; cv=none; d=google.com; s=arc-20160816; b=wmKUwzRnNxN24aXK/3/45sU/P7vGjncGk9J4z4yq6D023V/qSNMd1ejRXsE1UmfsNx sFSWJZpNyddYz7yb/ne2sjWcVKt9zB+hihwnHUMdJdiFFgcV6Bo9QF+TiEEMDWHemuI0 zzOI6cWYjORQOnnHCSElrVXuMHuR5EXajbIC3y41tUKS+bdWIqlArhlQ3MpC9mLrGm3m yWeWgXv5CAGjqoqLX9mvDumeBeBhlqxGCsYp7L74li5KmdtUEehE8pQH+QDdBGfSlD2Q aqZx1oq8PsspIkmUAEmUToX2j7P+mQj80udtifgqCS8kpttKu/AjnG00USTNYVYgWhh+ Kz3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:subject:cc:to:from:date:message-id:dkim-signature; bh=K/Y339cjUVl/X/gAfLYDhApN5kiIl0QX/F4UwUPxkPo=; b=IO9TcPnbXPBLlB0QBmlxDBEVNXduTTm4NVF9ZGgY6+sUtCJ8dIHiEgf7zrBLBqthnB 5MOiHehZGMvFf6es4bh1BSLPe1zOikTEDCTXkO/qdH4S2+QDWJFoYJZiOAK5GkKB+gnD OvUMk7bP1I+5SKzleDwI2GR5thyWlQjT+nF2aBplB3+8WKDt+we2kzSgHPlEFgynkhPu I953VYkNb9py1HnmFhtL9pbxzdvmcMlcV/y2fSSlE57JvOfmKJ9PQU13NwCNt5QhX/EZ P1oH0uNtBcZ71SRclxKa+crWMgRwZlQeb6uz20pZOE7ed+B/uJq6gpT92oLBejhshHfu 9Igg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dkLLYf1X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h192si3267184oib.166.2020.03.18.07.56.00; Wed, 18 Mar 2020 07:56:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dkLLYf1X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726777AbgCROzh (ORCPT + 99 others); Wed, 18 Mar 2020 10:55:37 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36134 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbgCROzg (ORCPT ); Wed, 18 Mar 2020 10:55:36 -0400 Received: by mail-pl1-f195.google.com with SMTP id g2so8783724plo.3; Wed, 18 Mar 2020 07:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:to:cc:subject:mime-version:content-disposition :user-agent; bh=K/Y339cjUVl/X/gAfLYDhApN5kiIl0QX/F4UwUPxkPo=; b=dkLLYf1XuBtBB0cr+RAmVC2P30NOhT0B9wQTmx6gLUZ4ZIW+fqxffEdI5wtPsMvN6b LarULhRV2iou62gQ+/KsPgVjNk4bjRk4JOojhfToE7utMecARpXRCwKn/QEIABAVApec GlEtyWd3fk9lUrDZIOXgZcjXF2Kc/LfC6KLyFqk8nT0FZ9nj5Jbmw+US1n4zNJGoDTVK dKUH9/8XmdPgQKro0Ad9203CL52+lh/zb9o9BlpEmv+CMiO+KhwuESVFyiVzsWbrrHqA 58HLZVpeaOIqZzWbzrfbiWvmzPzM97DZynJTXNueLTZx96bDrjUJFZslhr+6Cf4rI9qg XGMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:to:cc:subject:mime-version :content-disposition:user-agent; bh=K/Y339cjUVl/X/gAfLYDhApN5kiIl0QX/F4UwUPxkPo=; b=gjbLY20ycW+hW2Cwbvstt0K8llSLByijJwM1+p33CXpMlWGb+roegy6/LAQl77ngAE lk3VcWrfdf0S1Dl7QaRwlD6qdRZvLK4/pwFIO9rbiwyPdG++pZh+QJ9sJv5w1BwPCajD dOaD3zQ/siYzRptv8lRmOwlKJWCRNyX+HB8/UzfQlcgBc/w8A2KioFXQHrmNusw7lKZ9 YvuWvZUmLIff7TxeqLbWbI8KSPSI6GauObfjNnqvnnNV1dZ8LbysGkrulUGlGnXQMAQQ GGXn2q3pMmCuxN33zOhW9FPCJalKLtkviIAsapAZsHEwopwx/t3CEoOYbD4R086oyqn7 CGZw== X-Gm-Message-State: ANhLgQ3khnwFhkNxjq+lmY6QWuHcGaFFmCPsJZfDDCG/H2M9TIojdDj+ qsTrg6g1cbmRQz0MjqZN4n4= X-Received: by 2002:a17:90a:32d0:: with SMTP id l74mr5154984pjb.61.1584543335235; Wed, 18 Mar 2020 07:55:35 -0700 (PDT) Received: from SARKAR ([43.224.157.42]) by smtp.gmail.com with ESMTPSA id x16sm6532676pfn.42.2020.03.18.07.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 07:55:34 -0700 (PDT) Message-ID: <5e723666.1c69fb81.3545b.79c3@mx.google.com> X-Google-Original-Message-ID: <20200318145522.GA21528@rohitsarkar5398@gmail.com> Date: Wed, 18 Mar 2020 20:25:22 +0530 From: Rohit Sarkar To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, rohitsarkar5398@gmail.com, dragos.bogdan@analog.com, Lars-Peter Clausen , Michael Hennerich , Stefan Popa , knaack.h@gmx.de, pmeerw@pmeerw.net Subject: [PATCH] iio: gyro: adis16136: use scnprintf instead of snprintf MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org scnprintf returns the actual number of bytes written into the buffer as opposed to snprintf which returns the number of bytes that would have been written if the buffer was big enough. Using the output of snprintf may lead to difficult to detect bugs. Thanks, Rohit Signed-off-by: Rohit Sarkar --- drivers/iio/gyro/adis16136.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c index a4c967a5fc5c..0a8bb02dc4b9 100644 --- a/drivers/iio/gyro/adis16136.c +++ b/drivers/iio/gyro/adis16136.c @@ -96,7 +96,7 @@ static ssize_t adis16136_show_serial(struct file *file, if (ret) return ret; - len = snprintf(buf, sizeof(buf), "%.4x%.4x%.4x-%.4x\n", lot1, lot2, + len = scnprintf(buf, sizeof(buf), "%.4x%.4x%.4x-%.4x\n", lot1, lot2, lot3, serial); return simple_read_from_buffer(userbuf, count, ppos, buf, len); -- 2.23.0.385.gbc12974a89