mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Sergey S. Kostyliov" <rathamahata@php4.ru>
To: linux-kernel@vger.kernel.org
Cc: Will Dyson <will_dyson@pobox.com>
Subject: [PATCH] befs (5/5): debugging code cleanup
Date: Thu, 13 May 2004 22:30:37 +0400	[thread overview]
Message-ID: <E1BOL04-0003ou-00@mail.ehouse.ru> (raw)

- Reduce stack usage.
- Kill useless duplication of error and warning messages when debug is on. Old
	behaviour was:
...
BeFS(hda1): ---> befs_fill_super()
BeFS(hda1): No write support. Marking filesystem read-only
BeFS(hda1): No write support. Marking filesystem read-only
...

===== fs/befs/debug.c 1.2 vs edited =====
--- 1.2/fs/befs/debug.c	Thu Mar 20 21:47:37 2003
+++ edited/fs/befs/debug.c	Thu May 13 20:58:26 2004
@@ -29,22 +29,29 @@
 befs_error(const struct super_block *sb, const char *fmt, ...)
 {
 	va_list args;
-	char err_buf[ERRBUFSIZE];
-
+	char *err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL);
+	if (err_buf == NULL) {
+		printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
+		return;
+	}
+		
 	va_start(args, fmt);
 	vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
 	va_end(args);
 
 	printk(KERN_ERR "BeFS(%s): %s\n", sb->s_id, err_buf);
-
-	befs_debug(sb, err_buf);
+	kfree(err_buf);
 }
 
 void
 befs_warning(const struct super_block *sb, const char *fmt, ...)
 {
 	va_list args;
-	char err_buf[ERRBUFSIZE];
+	char *err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL);
+	if (err_buf == NULL) {
+		printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
+		return;
+	}
 
 	va_start(args, fmt);
 	vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
@@ -52,7 +59,7 @@
 
 	printk(KERN_WARNING "BeFS(%s): %s\n", sb->s_id, err_buf);
 
-	befs_debug(sb, err_buf);
+	kfree(err_buf);
 }
 
 void
@@ -61,15 +68,25 @@
 #ifdef CONFIG_BEFS_DEBUG
 
 	va_list args;
-	char err_buf[ERRBUFSIZE];
+	char *err_buf = NULL;
 
 	if (BEFS_SB(sb)->mount_opts.debug) {
+		err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL);
+		if (err_buf == NULL) {
+			printk(KERN_ERR "could not allocate %d bytes\n",
+				ERRBUFSIZE);
+			return;
+		}
+
 		va_start(args, fmt);
 		vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
 		va_end(args);
 
 		printk(KERN_DEBUG "BeFS(%s): %s\n", sb->s_id, err_buf);
+
+		kfree(err_buf);
 	}
+
 #endif				//CONFIG_BEFS_DEBUG
 }
 

-- 
                   Best regards,
                   Sergey S. Kostyliov <rathamahata@php4.ru>
                   Public PGP key: http://sysadminday.org.ru/rathamahata.asc


                 reply	other threads:[~2004-05-13 18:32 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=E1BOL04-0003ou-00@mail.ehouse.ru \
    --to=rathamahata@php4.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will_dyson@pobox.com \
    /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

all inboxes | Powered by JetHome®