From patchwork Tue Jun 16 01:01:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 6612611 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 0F5FD9F399 for ; Tue, 16 Jun 2015 01:02:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21E8C20645 for ; Tue, 16 Jun 2015 01:02:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F37C62064F for ; Tue, 16 Jun 2015 01:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751953AbbFPBCD (ORCPT ); Mon, 15 Jun 2015 21:02:03 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:34948 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750857AbbFPBCC (ORCPT ); Mon, 15 Jun 2015 21:02:02 -0400 Received: by pdbnf5 with SMTP id nf5so1879456pdb.2 for ; Mon, 15 Jun 2015 18:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=rWYwYJDkXCPnz2IW7dxI16uN80h3LCiA6X5mcDgCEuE=; b=Ir1lYelFR9Uz3/qtwuOsDD3cYjP7ywxGS0BhoSnRlVey8m2Jv9z89Zp5zTIiwsXwQp 4oOk03mlszsZwvkU8ZpWYhvPQ0wRRV1YySJgqBrioQt1vXHLxS5gfer2aC6f4CUbh/FU KAyiaA2/dlTHgW4JLqMB1VZtoD997Nd+SHzgpxJCEC910y4ygpJ238VFLpZlo0q9F9Ku fiVKMmkt3vA/mgs4MjJk7MQLwd5kW9SXxt9jZKoBCN4HEqynQGS10jAzcxtfyAJ1WxSl aEZesBE7DPJeYmoO2h/DbzXzRqew6t3iGUXOG3JUZxHBqtaqnSgHTVhqq5JCiBSM3475 dBig== X-Received: by 10.70.52.103 with SMTP id s7mr52573901pdo.117.1434416521996; Mon, 15 Jun 2015 18:02:01 -0700 (PDT) Received: from wacom-arch2.localdomain ([67.51.163.2]) by mx.google.com with ESMTPSA id o3sm13487840pds.1.2015.06.15.18.01.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jun 2015 18:01:59 -0700 (PDT) From: Jason Gerecke To: Ping Cheng , Aaron Skomra , Benjamin Tissoires , Jiri Kosina Cc: linux-input@vger.kernel.org, Jason Gerecke , Jason Gerecke Subject: [PATCH v2 1/5] HID: wacom: Simplify 'wacom_update_name' Date: Mon, 15 Jun 2015 18:01:41 -0700 Message-Id: <1434416505-12685-1-git-send-email-killertofu@gmail.com> X-Mailer: git-send-email 2.4.2 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 A little bit of cleanup work for 'wacom_update_name' to make it easier on the eyes. Creates a temporary 'name' variable on which we'll perform our edits. Once the name is in its final form, it will be copied (with appropriate suffix) to 'wacom_wac->name' and 'wacom_wac->pad_name'. Signed-off-by: Jason Gerecke --- No changes from v1. drivers/hid/wacom_sys.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index eea18a6..bdf31c9 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -1417,6 +1417,7 @@ static void wacom_update_name(struct wacom *wacom) { struct wacom_wac *wacom_wac = &wacom->wacom_wac; struct wacom_features *features = &wacom_wac->features; + char name[WACOM_NAME_MAX]; /* Generic devices name unspecified */ if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) { @@ -1424,41 +1425,43 @@ static void wacom_update_name(struct wacom *wacom) strstr(wacom->hdev->name, "wacom") || strstr(wacom->hdev->name, "WACOM")) { /* name is in HID descriptor, use it */ - strlcpy(wacom_wac->name, wacom->hdev->name, - sizeof(wacom_wac->name)); + strlcpy(name, wacom->hdev->name, sizeof(name)); /* strip out excess whitespaces */ while (1) { - char *gap = strstr(wacom_wac->name, " "); + char *gap = strstr(name, " "); if (gap == NULL) break; /* shift everything including the terminator */ memmove(gap, gap+1, strlen(gap)); } /* get rid of trailing whitespace */ - if (wacom_wac->name[strlen(wacom_wac->name)-1] == ' ') - wacom_wac->name[strlen(wacom_wac->name)-1] = '\0'; + if (name[strlen(name)-1] == ' ') + name[strlen(name)-1] = '\0'; } else { /* no meaningful name retrieved. use product ID */ - snprintf(wacom_wac->name, sizeof(wacom_wac->name), + snprintf(name, sizeof(name), "%s %X", features->name, wacom->hdev->product); } } else { - strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); + strlcpy(name, features->name, sizeof(name)); } /* Append the device type to the name */ snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), - "%s Pad", wacom_wac->name); + "%s Pad", name); if (features->device_type == BTN_TOOL_PEN) { - strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX); + snprintf(wacom_wac->name, sizeof(wacom_wac->name), + "%s Pen", name); } else if (features->device_type == BTN_TOOL_FINGER) { if (features->touch_max) - strlcat(wacom_wac->name, " Finger", WACOM_NAME_MAX); + snprintf(wacom_wac->name, sizeof(wacom_wac->name), + "%s Finger", name); else - strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX); + snprintf(wacom_wac->name, sizeof(wacom_wac->name), + "%s Pad", name); } }