From: Alex Elder <elder@linaro.org>
To: akpm@linux-foundation.org
Cc: pmladek@suse.cz, jack@suse.cz, joe@perches.com,
john.stultz@linaro.org, linux-kernel@vger.kernel.org
Subject: [PATCH] printk: tweak do_syslog() to match comments
Date: Fri, 27 Jun 2014 14:11:01 -0500 [thread overview]
Message-ID: <1403896261-15464-1-git-send-email-elder@linaro.org> (raw)
In do_syslog() there's a path used by kmsg_poll() and kmsg_read()
that only needs to know whether there's any data available to read
(and not its size). These callers only check for non-zero return.
As a shortcut, do_syslog() returns the difference between what
has been logged and what has been "seen."
The comments say that the "count of records" should be returned but
it's not. Instead it returns (log_next_idx - syslog_idx), which is
a difference between buffer offsets--and the result could be negative.
The behavior is the same (it'll be zero or not in the same cases),
but the count of records is more meaningful and it matches what the
comments say. So change the code to return that.
Signed-off-by: Alex Elder <elder@linaro.org>
---
This patch is also available here:
http://git.linaro.org/landing-teams/working/broadcom/kernel.git
Branch review/do_syslog_tweak
kernel/printk/printk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index ea2d5f6..f4a92e8 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1310,7 +1310,7 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
* for pending data, not the size; return the count of
* records, not the length.
*/
- error = log_next_idx - syslog_idx;
+ error = log_next_seq - syslog_seq;
} else {
u64 seq = syslog_seq;
u32 idx = syslog_idx;
--
1.9.1
reply other threads:[~2014-06-27 19:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403896261-15464-1-git-send-email-elder@linaro.org \
--to=elder@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=joe@perches.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).