From patchwork Wed Jul 9 16:03:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 33332 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 65F8E208CF for ; Wed, 9 Jul 2014 16:03:54 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id j17sf43506879oag.8 for ; Wed, 09 Jul 2014 09:03:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:in-reply-to:user-agent:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-disposition; bh=YgDuubZ+SuUkQsIYpVnL5YS8hyLaKZ6kXtFWbrS0nzk=; b=QrY0MJ75Hao1X+pTxfcmKUMRlRakvW4VfsvJWzaAj8wpBru5ty/Ur+pxO04NgDHH/B HNJBDqSdLHKd/Mcd+DlnRyLrOyPzBPYeU1n59Ltg9RxY9JL8q39bJl+gMUPEYMj0fqTn sd1HKRpRhdzu7y6SepZ/JSr8zBpyFQZgv5z4PkJIKmVUlKyjAkoJVO1cdkR7zeZvK9nj OPBQY0+1ZE2nMx0XnZSJ3NrLtu7y8BMqH9589WOkGgKFrdy0XXLMz0BkWp7NMIuLD5dQ nhpy49t5FFREaPx5MSlVNQv6rLmxoRqvuveUoz37txRbjgWSRw2ALEABKc6StNCCCza9 EGVg== X-Gm-Message-State: ALoCoQmMK8Tp5ne4SH0bzv66FJ95W3oouOrEpJaUlN6trTIjE8vz29r2DInnNF9xVwLvc6vHjfzt X-Received: by 10.42.151.67 with SMTP id d3mr10026039icw.6.1404921834003; Wed, 09 Jul 2014 09:03:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.50 with SMTP id i47ls2579776qgd.38.gmail; Wed, 09 Jul 2014 09:03:53 -0700 (PDT) X-Received: by 10.220.145.74 with SMTP id c10mr918205vcv.73.1404921833849; Wed, 09 Jul 2014 09:03:53 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id w4si8563891vev.44.2014.07.09.09.03.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 09:03:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hy4so7206318vcb.20 for ; Wed, 09 Jul 2014 09:03:53 -0700 (PDT) X-Received: by 10.58.18.211 with SMTP id y19mr1178288ved.58.1404921833768; Wed, 09 Jul 2014 09:03:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp59511vcb; Wed, 9 Jul 2014 09:03:53 -0700 (PDT) X-Received: by 10.70.43.132 with SMTP id w4mr11760540pdl.42.1404921832822; Wed, 09 Jul 2014 09:03:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bu17si7502550pdb.462.2014.07.09.09.03.52; Wed, 09 Jul 2014 09:03:52 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755813AbaGIQDm (ORCPT + 28 others); Wed, 9 Jul 2014 12:03:42 -0400 Received: from cantor2.suse.de ([195.135.220.15]:48005 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755711AbaGIQDl (ORCPT ); Wed, 9 Jul 2014 12:03:41 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 23461ABE3; Wed, 9 Jul 2014 16:03:40 +0000 (UTC) Date: Wed, 9 Jul 2014 18:03:39 +0200 From: Alex Elder To: akpm@linux-foundation.org Cc: ak@linux.intel.com, bp@suse.de, jack@suse.cz, john.stultz@linaro.org, pmladek@suse.cz, rostedt@goodmis.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] printk: miscellaneous cleanups Message-ID: <20140709160337.GB6774@pathway.suse.cz> References: <1404911056-29064-1-git-send-email-elder@linaro.org> MIME-Version: 1.0 In-Reply-To: <1404911056-29064-1-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-Disposition: inline This patch contains some small cleanups to kernel/printk/printk.c. None of them should cause any change in behavior. - When CONFIG_PRINTK is defined, parenthesize the value of LOG_LINE_MAX. - When CONFIG_PRINTK is *not* defined, there is an extra LOG_LINE_MAX definition; delete it. - Pull an assignment out of a conditional expression in console_setup(). - Use isdigit() in console_setup() rather than open coding it. - In update_console_cmdline(), drop a NUL-termination assignment; the strlcpy() call that precedes it guarantees it's not needed. - Simplify some logic in printk_timed_ratelimit(). Signed-off-by: Alex Elder --- kernel/printk/printk.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) + if (*caller_jiffies && elapsed <= msecs_to_jiffies(interval_msecs)) + return false; + + *caller_jiffies = jiffies; + return true; } EXPORT_SYMBOL(printk_timed_ratelimit); Best Regards, Petr -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 6f75e8a..909029e 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -257,7 +258,7 @@ static u64 clear_seq; static u32 clear_idx; #define PREFIX_MAX 32 -#define LOG_LINE_MAX 1024 - PREFIX_MAX +#define LOG_LINE_MAX (1024 - PREFIX_MAX) /* record buffer */ #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) @@ -1794,7 +1795,7 @@ EXPORT_SYMBOL(printk); #define LOG_LINE_MAX 0 #define PREFIX_MAX 0 -#define LOG_LINE_MAX 0 + static u64 syslog_seq; static u32 syslog_idx; static u64 console_seq; @@ -1895,7 +1896,8 @@ static int __init console_setup(char *str) strncpy(buf, str, sizeof(buf) - 1); } buf[sizeof(buf) - 1] = 0; - if ((options = strchr(str, ',')) != NULL) + options = strchr(str, ','); + if (options) *(options++) = 0; #ifdef __sparc__ if (!strcmp(str, "ttya")) @@ -1904,7 +1906,7 @@ static int __init console_setup(char *str) strcpy(buf, "ttyS1"); #endif for (s = buf; *s; s++) - if ((*s >= '0' && *s <= '9') || *s == ',') + if (isdigit(*s) || *s == ',') break; idx = simple_strtoul(s, NULL, 10); *s = 0; @@ -1943,7 +1945,6 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha i++, c++) if (strcmp(c->name, name) == 0 && c->index == idx) { strlcpy(c->name, name_new, sizeof(c->name)); - c->name[sizeof(c->name) - 1] = 0; c->options = options; c->index = idx_new; return i; @@ -2611,14 +2612,13 @@ EXPORT_SYMBOL(__printk_ratelimit); bool printk_timed_ratelimit(unsigned long *caller_jiffies, unsigned int interval_msecs) { - if (*caller_jiffies == 0 - || !time_in_range(jiffies, *caller_jiffies, - *caller_jiffies - + msecs_to_jiffies(interval_msecs))) { - *caller_jiffies = jiffies; - return true; - } - return false; + unsigned long elapsed = jiffies - *caller_jiffies; I wondered if the deduction might be negative. Well, it should not be if none manipulates *caller_jiffies a strange way. If it happens, the following condition will most likely fail and *caller_jiffies will get reset to jiffies. It looks reasonable to me. Reviewed-by: Petr Mladek +