From patchwork Sat Nov 14 21:08:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 7617411 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B1AB29F1D3 for ; Sat, 14 Nov 2015 21:08:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D16A220616 for ; Sat, 14 Nov 2015 21:08:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E58132060B for ; Sat, 14 Nov 2015 21:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751787AbbKNVIU (ORCPT ); Sat, 14 Nov 2015 16:08:20 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:33896 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751655AbbKNVIT (ORCPT ); Sat, 14 Nov 2015 16:08:19 -0500 Received: by lffu14 with SMTP id u14so69138350lff.1 for ; Sat, 14 Nov 2015 13:08:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id; bh=EBsFyPBy3W/xBMA6db6PZ8kxaXNAXMF2PEVIRaTs6JA=; b=Zb39YkBeelELAFnIx0xf0J/Nw2XhO0biK2BJhbjbyH257hBmB7H53pEwVrvV5X4M4h udnBmNMbLcqkqcXmIQJgW8t6ZVM21uhWAId5gByWtdemBpSoj07odFQ/L3QieGnzql/F mHaJAbNfZExPGKegKBybQ5bx5ea/P+QppoiY4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EBsFyPBy3W/xBMA6db6PZ8kxaXNAXMF2PEVIRaTs6JA=; b=EceBHUrWa3uz7NHdLTyVqyhAE3iuUNJqYDs3eHaz3tZrE+Kmi9CwI7+yBrQdEslksN /EI8JS1tyhH/kjtNinJdTNLqNeIE2FSzyrqNrMtsBSxiMp0vHbAcNj7k3QrZPJGpuvP5 tAeLxmiGAKr1bGrsDua+Jn3NnCplcYSVHbDduQ/s1ejcSRVLcB+SacLo0cyXj6HiUngy FI9eDKfqCW0eyNa4UML3VqIoLb945l2aMWytnGX/iW6XBfyj3Yp6O+sYTW//WnPPrWyE UCzErcTn2pq8s5ALXvlvekfV8XSy+YMfAm/uLaKbud51wSPUuS75wZQGQUHimbj7EA+k 6rpQ== X-Gm-Message-State: ALoCoQmu81XiT9ka3LEx5cqzoroLdzNDveUDoAvZHu45mzLl1CpJiz8dWjV8Ao6enQ3paqNvpJsm X-Received: by 10.25.211.194 with SMTP id k185mr13377765lfg.119.1447535297682; Sat, 14 Nov 2015 13:08:17 -0800 (PST) Received: from garcia.imf.au.dk ([130.225.20.51]) by smtp.gmail.com with ESMTPSA id un3sm487708lbc.28.2015.11.14.13.08.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Nov 2015 13:08:17 -0800 (PST) From: Rasmus Villemoes To: Jiri Kosina Cc: Rasmus Villemoes , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: core: use scnprintf in modalias_show() Date: Sat, 14 Nov 2015 22:08:08 +0100 Message-Id: <1447535288-12523-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.6.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP scnprintf() exists to provide these semantics, so we might as well use it. Signed-off-by: Rasmus Villemoes --- drivers/hid/hid-core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index c6f7a694f67a..efa3660e23a0 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2223,12 +2223,9 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, char *buf) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); - int len; - - len = snprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n", - hdev->bus, hdev->group, hdev->vendor, hdev->product); - return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; + return scnprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n", + hdev->bus, hdev->group, hdev->vendor, hdev->product); } static DEVICE_ATTR_RO(modalias);