Received: by 10.213.65.68 with SMTP id h4csp1135318imn; Sat, 24 Mar 2018 04:29:26 -0700 (PDT) X-Google-Smtp-Source: AG47ELuS3j+Z9vY0sToUNAHOAdzZ9MasfoowBB/deZK4Vg8P4h1NT2eLLTn6AFBRmIixQo6X9QAu X-Received: by 10.98.56.131 with SMTP id f125mr26989212pfa.190.1521890966663; Sat, 24 Mar 2018 04:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521890966; cv=none; d=google.com; s=arc-20160816; b=JJgCREYTin2cbTloss+RF1b7fE7WdVlU9KuQ0W1HvZ5dZFNYDma/ngma19Bj5RV5R6 zxrg52JvARN49UfLBm6e0VVWj68OMfOpMxksSUeySe8IEFrPHJNkJYbgGP9oHX482Qzl MUuezDeN7GK9hCuY76RNjgPs4hLUEG3/sIpBGLff96KSoWcdlfXjrS4YyS9/Tk3CNTgn PDj2EAPAgraLntNTm8F9JCQkGINwH+rJSBptKZ3L49oFZt5LvaxkuVi/bf94J3LF7+GV R7HucXgi1zwguxh81JWbwDQSBTd3fdEgHA+aO4vC+4hqi+7s4yWrbNYzeDqoF3YSWAvs qcXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7zrMSY1Wi+vIndKKMIIUV2njqohpBgvYt+3SGcR74hk=; b=y299vSsqYBHLf3ZMZ/4ySPvLQABweReE+YjK/3BbQqZs1yuSEs+C7L3fD1Dg+BAgpV nuZWAxGUJGPmvbyUM7fPOow0mJaRdnrpHN6hF+Es9EXHb7c7XHcogRtHXIqktqpOloAk lc9v34zV63GAXHavd+jlHJOr9Zzyoce3caiFTY3vk4+Q1kBxJnYdr2RAmdswjw3t+WK/ rEjICN7cJyvQmv96Z5Mj2WnriwX8BieHk7UqKY3mLXYOGuuvUA1s9fSXY8MTONK0TCFg 7ggS0OPB3UKIhlQTJq2xWwKDWlVHYa16AuBE8TLhcCCA7fm6zm2PAHFMJ8HtkE8CcP1h 0/Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JKfLSr3Q; 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 i74si7255875pgc.262.2018.03.24.04.29.12; Sat, 24 Mar 2018 04:29:26 -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=JKfLSr3Q; 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 S1752088AbeCXL1l (ORCPT + 99 others); Sat, 24 Mar 2018 07:27:41 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:34298 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752017AbeCXL1j (ORCPT ); Sat, 24 Mar 2018 07:27:39 -0400 Received: by mail-pl0-f67.google.com with SMTP id u11-v6so9026505plq.1 for ; Sat, 24 Mar 2018 04:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7zrMSY1Wi+vIndKKMIIUV2njqohpBgvYt+3SGcR74hk=; b=JKfLSr3QqDbiGbMqvxrILZgJr+rKRcI88M23/5IwUxm3veomWHDEjDUCKdgDWpiLZj +k1UOjMgl33g2KM0rCfJeKOlLqQRw/cTWmJD6KVuctdjaLTcl4lr38hmaXkgOiw9NT1p r4IiKIebUnhRS/Mzcyq74C+CZxfxM0eUhfiPUopfG8VhCADhEl5zWBTwGnl8Q+on1VUH yEtHHbsl90YqEqDgirNwlzZMCahkHcaxgQVBaugTO25JNgMeAFhZ8wjKGCJMg14QyUb1 TRrbZWE8/A/MgFX3ZogIjnx9NyCHyEhUOanYhmhaxgvTZM4sOan1irTU3B1x/fwy0OwI KN2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7zrMSY1Wi+vIndKKMIIUV2njqohpBgvYt+3SGcR74hk=; b=aWojgSmkSTBCDkOzQoNPSQYg1FZrNr4tXSZL6a96wFXPr5aKyZqlXbOCxDtnylaaxW 1Tf8PFw18FWtl/v4cDB08LE6viTLs2YUGkmaG/LbMULvmsO5X5qC7PCzbo+aoM3VtOIa D4TXaT08KosD4/qJYlcqy7f8pm4iIeFj8QL7z2e85yY04Lq0TtlFllS1vxqhkrzatiQk Gb8jSOGN/n3n/nA1wFKc0zMbNrQ/FpigMzZo65i/EHS0wlA++v6aEUXG0yfGkYaNV8wA 4j27udIBeeH9F29DbwldJI71xsWSCsWimsfeXSFVtaby3lULBoya+xlbIzl38JH4N5xy sjgg== X-Gm-Message-State: AElRT7HA2N+k9i3vKZaDTzk46bFkOqJv1Iusdn9E5M3/OleyYMSgEppo FipVoqDpGMHHwo8TSfFCZqkeJA== X-Received: by 2002:a17:902:7790:: with SMTP id o16-v6mr8593595pll.106.1521890858899; Sat, 24 Mar 2018 04:27:38 -0700 (PDT) Received: from nibbler.alyptik.lan ([2605:e000:1117:c19a:2e0:1bff:fe70:ea]) by smtp.gmail.com with ESMTPSA id s7sm19383899pfb.150.2018.03.24.04.27.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Mar 2018 04:27:37 -0700 (PDT) From: Joey Pabalinas To: linux-kernel@vger.kernel.org Cc: Joey Pabalinas , Greg Kroah-Hartman , Arnd Bergmann , Jiri Slaby , Tomasz Kramkowsk Subject: [PATCH v2 1/4] tty/nozomi: cleanup DUMP() macro Date: Sat, 24 Mar 2018 01:27:29 -1000 Message-Id: <20180324112732.29424-2-joeypabalinas@gmail.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180324112732.29424-1-joeypabalinas@gmail.com> References: <20180324112732.29424-1-joeypabalinas@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace snprint() with strscpy() and use max_t() instead of the conditional operator. Signed-off-by: Joey Pabalinas 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c index b57b35066ebea94639..f26bf1d1e9ee0e74eb 100644 --- a/drivers/tty/nozomi.c +++ b/drivers/tty/nozomi.c @@ -72,19 +72,19 @@ do { \ #define TMP_BUF_MAX 256 -#define DUMP(buf__,len__) \ - do { \ - char tbuf[TMP_BUF_MAX] = {0};\ - if (len__ > 1) {\ - snprintf(tbuf, len__ > TMP_BUF_MAX ? TMP_BUF_MAX : len__, "%s", buf__);\ - if (tbuf[len__-2] == '\r') {\ - tbuf[len__-2] = 'r';\ - } \ - DBG1("SENDING: '%s' (%d+n)", tbuf, len__);\ - } else {\ - DBG1("SENDING: '%s' (%d)", tbuf, len__);\ - } \ -} while (0) +#define DUMP(buf__, len__) \ + do { \ + char tbuf[TMP_BUF_MAX] = {0}; \ + if (len__ > 1) { \ + u32 data_len = min_t(u32, len__, TMP_BUF_MAX); \ + strscpy(tbuf, buf__, data_len); \ + if (tbuf[data_len - 2] == '\r') \ + tbuf[data_len - 2] = 'r'; \ + DBG1("SENDING: '%s' (%d+n)", tbuf, len__); \ + } else { \ + DBG1("SENDING: '%s' (%d)", tbuf, len__); \ + } \ + } while (0) /* Defines */ #define NOZOMI_NAME "nozomi" -- 2.16.3