All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@mandrakesoft.com>
To: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
Cc: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH]: remove warnings on promlib
Date: 19 Dec 2002 11:17:18 +0100	[thread overview]
Message-ID: <m2r8cemhxt.fsf@demo.mitica> (raw)
In-Reply-To: <Pine.GSO.3.96.1021218174743.5977E-100000@delta.ds2.pg.gda.pl>

>>>>> "maciej" == Maciej W Rozycki <macro@ds2.pg.gda.pl> writes:

maciej> On 18 Dec 2002, Juan Quintela wrote:
>> Index: arch/mips/lib/promlib.c
>> ===================================================================
>> RCS file: /home/cvs/linux/arch/mips/lib/promlib.c,v
>> retrieving revision 1.1.2.1
>> diff -u -r1.1.2.1 promlib.c
>> --- arch/mips/lib/promlib.c	28 Sep 2002 22:28:38 -0000	1.1.2.1
>> +++ arch/mips/lib/promlib.c	18 Dec 2002 00:49:18 -0000
>> @@ -1,3 +1,7 @@
>> +
>> +#include <asm/sgialib.h>
>> +#include <linux/kernel.h>
>> +
>> #include <stdarg.h>
>> 
>> void prom_printf(char *fmt, ...)

maciej> A few comments:

maciej> 1. <linux> includes first, <asm> ones following (hmm, shouldn't that be
maciej> obvious...).

maciej> 2. <linux/kernel.h> is obviously OK for vsprintf().

maciej> 3. I would hesitate using <asm/sgialib.h> here being too much platform
maciej> specific.  Either a separate generic <asm/prom.h> should be created for
maciej> primitives like prom_putchar(), prom_getchar(), etc. or a private
maciej> conservative declaration should be used here.  The reason is the functions
maciej> are much platform-specific, e.g. they may be pointers or even macros --
maciej> see <asm/dec/prom.h> for a not-so-trivial example (luckily, DECstations
maciej> support prom_printf() directly, so they don't have to use promlib.c).

Something like that?

Once there, s/vsprintf/vsnprintf/.

If anybody calls prom_printf with more than 1024 chars, we were b0rked
:((

I didn't did the changes for the other users of prom_* that was using 
asm/sgialib.h, but change is trivial.

Later, Juan.

diff -uNp build/include/asm-mips/prom.h.orig build/include/asm-mips/prom.h
--- build/include/asm-mips/prom.h.orig	1970-01-01 01:00:00.000000000 +0100
+++ build/include/asm-mips/prom.h	2002-12-18 19:00:47.000000000 +0100
@@ -0,0 +1,21 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Interface with the low level prom consoles.
+ *
+ * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
+ * Copyright (C) 2001, 2002 Ralf Baechle (ralf@gnu.org)
+ */
+#ifndef _ASM_PROM_H
+#define _ASM_PROM_H
+
+/* Simple char-by-char console I/O. */
+extern void prom_putchar(char c);
+extern char prom_getchar(void);
+
+/* Generic printf() console I/O. */
+extern void prom_printf(char *fmt, ...);
+
+#endif /* _ASM_PROM_H */
Index: arch/mips/arc/init.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/arc/init.c,v
retrieving revision 1.10.2.3
diff -u -r1.10.2.3 init.c
--- arch/mips/arc/init.c	1 Aug 2002 22:26:40 -0000	1.10.2.3
+++ arch/mips/arc/init.c	19 Dec 2002 09:21:07 -0000
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 
 #include <asm/sgialib.h>
+#include <asm/prom.h>
 
 #undef DEBUG_PROM_INIT
 
Index: arch/mips/lib/promlib.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/lib/promlib.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 promlib.c
--- arch/mips/lib/promlib.c	28 Sep 2002 22:28:38 -0000	1.1.2.1
+++ arch/mips/lib/promlib.c	19 Dec 2002 09:21:08 -0000
@@ -1,13 +1,20 @@
+
+
+#include <linux/kernel.h>
+#include <asm/prom.h>
+
 #include <stdarg.h>
 
+#define BUFSIZE 1024
+
 void prom_printf(char *fmt, ...)
 {
 	va_list args;
-	char ppbuf[1024];
+	char ppbuf[BUFSIZE];
 	char *bptr;
 
 	va_start(args, fmt);
-	vsprintf(ppbuf, fmt, args);
+	vsnprintf(ppbuf, BUFSIZE, fmt, args);
 
 	bptr = ppbuf;
 

Index: arch/mips/sgi-ip22/ip22-system.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip22/ip22-system.c,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 ip22-system.c
--- arch/mips/sgi-ip22/ip22-system.c	18 Dec 2002 19:11:09 -0000	1.1.2.8
+++ arch/mips/sgi-ip22/ip22-system.c	19 Dec 2002 09:21:09 -0000
@@ -11,6 +11,7 @@
 #include <asm/cpu.h>
 #include <asm/sgi/sgi.h>
 #include <asm/sgialib.h>
+#include <asm/prom.h>
 
 enum sgi_mach sgimach;
 
Index: include/asm-mips/sgialib.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/sgialib.h,v
retrieving revision 1.10.2.3
diff -u -r1.10.2.3 sgialib.h
--- include/asm-mips/sgialib.h	1 Aug 2002 22:26:40 -0000	1.10.2.3
+++ include/asm-mips/sgialib.h	19 Dec 2002 09:21:15 -0000
@@ -30,13 +30,6 @@
 /* Init the PROM library and it's internal data structures. */
 extern void prom_init(int argc, char **argv, char **envp, int *prom_vec);
 
-/* Simple char-by-char console I/O. */
-extern void prom_putchar(char c);
-extern char prom_getchar(void);
-
-/* Generic printf() using ARCS console I/O. */
-extern void prom_printf(char *fmt, ...);
-
 /* Memory descriptor management. */
 #define PROM_MAX_PMEMBLOCKS    32
 struct prom_pmemblock {

-- 
In theory, practice and theory are the same, but in practice they 
are different -- Larry McVoy

  reply	other threads:[~2002-12-19 10:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-18  1:43 [PATCH]: remove warnings on promlib Juan Quintela
2002-12-18 17:00 ` Maciej W. Rozycki
2002-12-19 10:17   ` Juan Quintela [this message]
2002-12-19 11:07     ` Juan Quintela
2002-12-19 12:04     ` Maciej W. Rozycki

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=m2r8cemhxt.fsf@demo.mitica \
    --to=quintela@mandrakesoft.com \
    --cc=linux-mips@linux-mips.org \
    --cc=macro@ds2.pg.gda.pl \
    --cc=ralf@linux-mips.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.