Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.cz>
To: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Cc: "kexec@lists.infradead.org" <kexec@lists.infradead.org>
Subject: Re: [PATCH] dump_log_entry: replace magic constant with a variable
Date: Mon, 1 Sep 2014 09:17:28 +0200	[thread overview]
Message-ID: <20140901091728.7f724ff2@hananiah.suse.cz> (raw)
In-Reply-To: <0910DD04CBD6DE4193FCF86B9C00BE97251486@BPXM01GP.gisp.nec.co.jp>

On Mon, 1 Sep 2014 06:37:10 +0000
Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp> wrote:

> >If the buffer space requirements are changed, the magic constant is
> >hard to spot, and the failure is easily overlooked, because it may
> >fail only under special conditions.
> 
> Good change, I'll push it to devel soon.

Thank you!

Petr Tesarik

> Thanks
> Atsushi Kumagai
> 
> >Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
> >---
> > makedumpfile.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> >diff --git a/makedumpfile.c b/makedumpfile.c
> >index b4b6eca..37dea37 100644
> >--- a/makedumpfile.c
> >+++ b/makedumpfile.c
> >@@ -3949,7 +3949,7 @@ static int
> > dump_log_entry(char *logptr, int fp)
> > {
> > 	char *msg, *p, *bufp;
> >-	unsigned int i, text_len;
> >+	unsigned int i, text_len, buf_need;
> > 	unsigned long long ts_nsec;
> > 	char buf[BUFSIZE];
> > 	ulonglong nanos;
> >@@ -3966,9 +3966,11 @@ dump_log_entry(char *logptr, int fp)
> > 	bufp = buf;
> > 	bufp += sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
> >
> >+	/* How much buffer space is needed in the worst case */
> >+	buf_need = sizeof("\\xXX\n");
> >+
> > 	for (i = 0, p = msg; i < text_len; i++, p++) {
> >-		/* 6bytes = "\\x%02x" + '\n' + '\0' */
> >-		if (bufp - buf >= sizeof(buf) - 6) {
> >+		if (bufp - buf >= sizeof(buf) - buf_need) {
> > 			if (write(info->fd_dumpfile, buf, bufp - buf) < 0)
> > 				return FALSE;
> > 			bufp = buf;
> >--


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

      reply	other threads:[~2014-09-01  7:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-29  8:36 [PATCH] dump_log_entry: replace magic constant with a variable Petr Tesarik
2014-09-01  6:37 ` Atsushi Kumagai
2014-09-01  7:17   ` Petr Tesarik [this message]

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=20140901091728.7f724ff2@hananiah.suse.cz \
    --to=ptesarik@suse.cz \
    --cc=kexec@lists.infradead.org \
    --cc=kumagai-atsushi@mxc.nes.nec.co.jp \
    /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