From patchwork Fri Jul 18 14:14:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 33868 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f69.google.com (mail-oi0-f69.google.com [209.85.218.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 141D220CA0 for ; Fri, 18 Jul 2014 14:16:20 +0000 (UTC) Received: by mail-oi0-f69.google.com with SMTP id h136sf6148312oig.8 for ; Fri, 18 Jul 2014 07:16:19 -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=VU2PUWKaB/wrMOXrRTnmiQEQfK9YcpWDSyUy8DASSJk=; b=ZZ5WPfM7RAQwUEn1pfLkg/7TDaifGJ2o3/JV9N0gMIJMVRQR7XT5MwoLNBbrj6X7Qi tLfFbECZr/Eg0x9Ppx5ecxSWQjcxzD9llHl1dflBk4e5GHS7rKVHd6tEbBqnbqD3CxmP mF95P07Svl/Ti8xqi90e48fp54uyXxfeZGflCZoXx4KmE5eeaSYv9806eNaaCQEfiqhV p19O9KYa14NrcBwEwHNGAWKE04Bp8PcNDlgtjLeeE4hSYXH/olZPV0v9wO6i/WEHVG4E sfFauF/8cygTaWfE+AUp5iw25aIeDCjOwFFxLA6/U5IeEzEPpluH4iINRvvrFhBI8CEg D5lw== X-Gm-Message-State: ALoCoQlsKitVZRwQDNkybagMTFmt9QdLjDb5mv3sU8toAf9XoWTGhTjEKduXzgTr9M3WGdpttkd+ X-Received: by 10.182.33.35 with SMTP id o3mr2504704obi.8.1405692979684; Fri, 18 Jul 2014 07:16:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.132 with SMTP id 4ls992451qgj.12.gmail; Fri, 18 Jul 2014 07:16:19 -0700 (PDT) X-Received: by 10.220.144.147 with SMTP id z19mr6348333vcu.26.1405692979593; Fri, 18 Jul 2014 07:16:19 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id sb6si5824263veb.66.2014.07.18.07.16.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Jul 2014 07:16:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so7376518vcb.29 for ; Fri, 18 Jul 2014 07:16:18 -0700 (PDT) X-Received: by 10.220.203.134 with SMTP id fi6mr6409959vcb.18.1405692978892; Fri, 18 Jul 2014 07:16:18 -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 tc5csp14829vcb; Fri, 18 Jul 2014 07:16:18 -0700 (PDT) X-Received: by 10.70.25.67 with SMTP id a3mr5462448pdg.47.1405692977512; Fri, 18 Jul 2014 07:16:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kn11si6085855pbd.215.2014.07.18.07.16.16; Fri, 18 Jul 2014 07:16:16 -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 S1761812AbaGROQN (ORCPT + 25 others); Fri, 18 Jul 2014 10:16:13 -0400 Received: from mail-ie0-f180.google.com ([209.85.223.180]:64638 "EHLO mail-ie0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935097AbaGROOV (ORCPT ); Fri, 18 Jul 2014 10:14:21 -0400 Received: by mail-ie0-f180.google.com with SMTP id at20so4430538iec.25 for ; Fri, 18 Jul 2014 07:14:20 -0700 (PDT) X-Received: by 10.42.80.81 with SMTP id u17mr7751744ick.64.1405692860720; Fri, 18 Jul 2014 07:14:20 -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 ga11sm6234171igd.8.2014.07.18.07.14.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Jul 2014 07:14:20 -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 v3 2/7] printk: initialize syslog_prev and console_prev Date: Fri, 18 Jul 2014 09:14:14 -0500 Message-Id: <1405692859-32500-3-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405692859-32500-1-git-send-email-elder@linaro.org> References: <1405692859-32500-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.170 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 bed8f09..f2a069e 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; }