From patchwork Fri Jul 18 21:28:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 33915 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6617A208CF for ; Fri, 18 Jul 2014 21:29:44 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id y10sf28811466pdj.0 for ; Fri, 18 Jul 2014 14:29:42 -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:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=IpP/dBn2eZugBIk22vrXGogQJQYitrGrJ7JPzclQwD8=; b=ZHoleMJrY89z4wkFLdipzvvVN8MIZ7kJpth9hgt72pAj/wnecmAA8cE3E60XJkKPYu mhqQskg38eU84TU4GPnud5RlTEH9Q8yiVtPnQ+tI9khbll4rFWMNkZH0ozgmDPF1UUf8 MZrbgCpdMJrMYmr1LF1lBrzWw9wQHc6crodv1/IClPQb08DbweIElMFpvj0Q51IrCStn H1FjOVeMHwwHr3Kak39kUV3bes6flRmBED4RkrgYavbkZf7yrBJHX7xVzV2VNSlmnLU+ OQ9HAiZcyfTTRaYYy5VduxnW4ya9pjKlThGit4p/aNPTXyQEN302iH+W2DuEC0fnss9Y fFGQ== X-Gm-Message-State: ALoCoQlIrwi7cbS9jozkErbW7JVx+UhHveLYl9ovZg1uwfeIRmfKnNXixFi8V1Qp5YPPSntCToG7 X-Received: by 10.66.145.33 with SMTP id sr1mr3656628pab.18.1405718982569; Fri, 18 Jul 2014 14:29:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.203 with SMTP id v69ls1129569qgd.6.gmail; Fri, 18 Jul 2014 14:29:42 -0700 (PDT) X-Received: by 10.52.172.5 with SMTP id ay5mr8265674vdc.38.1405718982347; Fri, 18 Jul 2014 14:29:42 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id qq7si6949862vcb.65.2014.07.18.14.29.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Jul 2014 14:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so8384637vcb.37 for ; Fri, 18 Jul 2014 14:29:42 -0700 (PDT) X-Received: by 10.53.5.230 with SMTP id cp6mr1341977vdd.25.1405718982250; Fri, 18 Jul 2014 14:29:42 -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 tc5csp42403vcb; Fri, 18 Jul 2014 14:29:41 -0700 (PDT) X-Received: by 10.70.52.138 with SMTP id t10mr8465432pdo.90.1405718981016; Fri, 18 Jul 2014 14:29:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id df3si7169083pbb.203.2014.07.18.14.29.40; Fri, 18 Jul 2014 14:29:40 -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 S1946184AbaGRV3b (ORCPT + 23 others); Fri, 18 Jul 2014 17:29:31 -0400 Received: from mail-ig0-f177.google.com ([209.85.213.177]:42210 "EHLO mail-ig0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935238AbaGRV2M (ORCPT ); Fri, 18 Jul 2014 17:28:12 -0400 Received: by mail-ig0-f177.google.com with SMTP id hn18so1075104igb.16 for ; Fri, 18 Jul 2014 14:28:11 -0700 (PDT) X-Received: by 10.42.83.81 with SMTP id g17mr11045688icl.45.1405718891114; Fri, 18 Jul 2014 14:28:11 -0700 (PDT) Received: from localhost.localdomain (c-24-245-18-91.hsd1.mn.comcast.net. [24.245.18.91]) by mx.google.com with ESMTPSA id vk3sm9535840igb.17.2014.07.18.14.28.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Jul 2014 14:28:10 -0700 (PDT) From: Alex Elder To: akpm@linux-foundation.org Cc: kay@vrfy.org, pmladek@suse.cz, bp@suse.de, john.stultz@linaro.org, jack@suse.cz, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/7] printk: initialize syslog_prev and console_prev Date: Fri, 18 Jul 2014 16:28:00 -0500 Message-Id: <1405718885-11227-3-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405718885-11227-1-git-send-email-elder@linaro.org> References: <1405718885-11227-1-git-send-email-elder@linaro.org> MIME-Version: 1.0 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.178 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: , Two global variables, "syslog_prev" and "console_prev", maintain a copy of the flags value used in the log record most recently formatted for syslog or the console, respectively. Initially there is no previous formatted log record, and these variables simply have an initial value 0. And occasionally log records can get consumed at a rate such that syslog or the console can't keep up, in which case those variables (along with their corresponding position variables) must be reset. Here too, they're reset to 0. This patch changes it so the initial value used is LOG_NEWLINE. That is, if we know nothing about the prevously-formatted log record, we can assume it was complete, and ended with a newline. This is being done to support the next patch. Initializing these variables this way makes LOG_NEWLINE and LOG_CONT be mutually exclusive, and the next patch uses that fact to simplify some logic. Signed-off-by: Alex Elder Reviewed-by: Petr Mládek --- kernel/printk/printk.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index ffc9928..4034a88 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -236,7 +236,7 @@ DECLARE_WAIT_QUEUE_HEAD(log_wait); /* the next printk record to read by syslog(READ) or /proc/kmsg */ static u64 syslog_seq; static u32 syslog_idx; -static enum log_flags syslog_prev; +static enum log_flags syslog_prev = LOG_NEWLINE; static size_t syslog_partial; /* index and sequence number of the first record stored in the buffer */ @@ -250,7 +250,7 @@ static u32 log_next_idx; /* the next printk record to write to the console */ static u64 console_seq; static u32 console_idx; -static enum log_flags console_prev; +static enum log_flags console_prev = LOG_NEWLINE; /* the next printk record to read after the last 'clear' command */ static u64 clear_seq; @@ -1071,7 +1071,7 @@ static int syslog_print(char __user *buf, int size) /* messages are gone, move to first one */ syslog_seq = log_first_seq; syslog_idx = log_first_idx; - syslog_prev = 0; + syslog_prev = LOG_NEWLINE; syslog_partial = 0; } if (syslog_seq == log_next_seq) { @@ -1301,7 +1301,7 @@ int do_syslog(int type, char __user *buf, int len, bool from_file) /* messages are gone, move to first one */ syslog_seq = log_first_seq; syslog_idx = log_first_idx; - syslog_prev = 0; + syslog_prev = LOG_NEWLINE; syslog_partial = 0; } if (from_file) { @@ -2149,7 +2149,7 @@ again: /* messages are gone, move to first one */ console_seq = log_first_seq; console_idx = log_first_idx; - console_prev = 0; + console_prev = LOG_NEWLINE; } else { len = 0; }