From patchwork Thu Jul 17 14:09:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 33787 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6A95F20CA0 for ; Thu, 17 Jul 2014 14:10:58 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id at20sf21335988iec.7 for ; Thu, 17 Jul 2014 07:10:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=OjyfhJIo1EScKVm/nh+45m4H4uvBMMHlqsKt92ICtFg=; b=kc/Wwt4BQNzA7aWnDgxit0ttU9wjy6GAKFDBeN2YZoQMcYBifQlL42KIuVHvKiBKlx Dy97s/vxQRyLlaMIKMWypRBoseOT29PCASCYnZRmr4yd6KM80iX7GaGEp3Tx90GaRAUD x9iXwByXxjLgzIH2CNj0u73UL9MxqZr1qcIZ9GKe/ilWlwr34kV7muz5VIhIsXfif+Tx V2Q0wNR1ssJ1dIBug9dVqLiFxkIGMN0OaDC1jnKo40yRH5ymJzqVSwxvRhW8pzQHclyJ E2IoOZpUeHTbgn0UjMnSPWkBHsgE6IJMObBqgXk0jFwUCiRtEKE2Y+0hDo4a5aC4Zp60 06sg== X-Gm-Message-State: ALoCoQl8wMZyxH5xxOEcI5pR4KZUvrxch0Z9rn87oyIvdpmgZBxMyACLH4RjhQe8uquMMI3GNgck X-Received: by 10.182.51.228 with SMTP id n4mr18718375obo.28.1405606257944; Thu, 17 Jul 2014 07:10:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.50.66.208 with SMTP id h16ls1731062igt.18.gmail; Thu, 17 Jul 2014 07:10:57 -0700 (PDT) X-Received: by 10.70.35.169 with SMTP id i9mr26976324pdj.36.1405606257796; Thu, 17 Jul 2014 07:10:57 -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 yq7si2471777veb.28.2014.07.17.07.10.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Jul 2014 07:10:57 -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 hu12so4545629vcb.20 for ; Thu, 17 Jul 2014 07:10:57 -0700 (PDT) X-Received: by 10.53.5.230 with SMTP id cp6mr465498vdd.25.1405606256877; Thu, 17 Jul 2014 07:10:56 -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 tc5csp39523vcb; Thu, 17 Jul 2014 07:10:56 -0700 (PDT) X-Received: by 10.66.255.38 with SMTP id an6mr36947101pad.43.1405606255947; Thu, 17 Jul 2014 07:10:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gu3si2497777pbb.232.2014.07.17.07.10.54; Thu, 17 Jul 2014 07:10:54 -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 S933555AbaGQOKp (ORCPT + 23 others); Thu, 17 Jul 2014 10:10:45 -0400 Received: from mail-ie0-f179.google.com ([209.85.223.179]:35821 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932361AbaGQOJN (ORCPT ); Thu, 17 Jul 2014 10:09:13 -0400 Received: by mail-ie0-f179.google.com with SMTP id rl12so2956317iec.38 for ; Thu, 17 Jul 2014 07:09:13 -0700 (PDT) X-Received: by 10.50.142.99 with SMTP id rv3mr24391284igb.48.1405606153078; Thu, 17 Jul 2014 07:09:13 -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 hu10sm55538179igb.22.2014.07.17.07.09.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Jul 2014 07:09:12 -0700 (PDT) From: Alex Elder To: akpm@linux-foundation.org Cc: pmladek@suse.cz, bp@suse.de, john.stultz@linaro.org, jack@suse.cz, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] printk: initialize syslog_prev and console_prev Date: Thu, 17 Jul 2014 09:09:06 -0500 Message-Id: <1405606151-19875-2-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405606151-19875-1-git-send-email-elder@linaro.org> References: <1405606151-19875-1-git-send-email-elder@linaro.org> 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: , 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 Mladek --- 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 13e839d..ff1c7ad 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) { @@ -2148,7 +2148,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; }