From: Pavel Machek <pavel@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] puts() and newlines (was Re: Discussion topics / issues)
Date: Wed, 15 Oct 2014 11:42:00 +0200 [thread overview]
Message-ID: <20141015094200.GA26232@amd> (raw)
In-Reply-To: <20141015084012.GA20015@amd>
On Wed 2014-10-15 10:40:12, Pavel Machek wrote:
> Hi!
>
> > First, we have a compatibility problem here. GCC assumes that puts()
> > will add a newline character after the string; U-Boot puts() does NOT
> > do this. So the GCC auto-converted printf()s will all be wrong, as
> > they are missing the newline. [1]
>
> > [1] One might argue that this is a bug in U-Boot and should be fixed,
> > but that is another topic.
>
> I believe we should fix that, yes.
>
> I did quick grep,
>
> pavel at duo:~/wagabuibui/u-boot$ grep -ri puts . | wc -l
> 4287
>
> and that is probably too much to change in one go. So what about
> this?
Next step is probably
diff --git a/include/common.h b/include/common.h
index d5020c8..95b2377 100644
--- a/include/common.h
+++ b/include/common.h
@@ -836,6 +836,9 @@ int tstc(void);
/* stdout */
void putc(const char c);
void puts(const char *s);
+static inline void __puts(const char *s) { puts(s); }
+static inline void putsnl(const char *s) { puts(s); putc('\n'); }
+
int printf(const char *fmt, ...)
__attribute__ ((format (__printf__, 1, 2)));
int vprintf(const char *fmt, va_list args);
Then run
sed 's/puts(\(.*\)\\n")/putsnl(\1")/' `find . -name "*.[ch]"`
... to get existing users converted. Then we can convert the rest to
to either __puts or putsnl, and finally get rid of putsnl and convert
it back to puts.
(Patch is >400KB, so I'll not post it here).
Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2014-10-15 9:42 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-07 12:45 [U-Boot] [SoCFPGA] next steps Marek Vasut
2014-10-08 8:58 ` Michal Simek
2014-10-08 10:39 ` Marek Vasut
2014-10-08 11:17 ` Pavel Machek
2014-10-08 20:09 ` Tom Rini
2014-10-09 8:37 ` Michal Simek
2014-10-09 11:20 ` Jagan Teki
2014-10-09 13:42 ` Marek Vasut
2014-10-09 16:11 ` Jagan Teki
2014-10-09 16:15 ` [U-Boot] Discussion topics / issues Marek Vasut
2014-10-09 16:41 ` Jagan Teki
2014-10-09 14:03 ` Marek Vasut
2014-10-09 14:45 ` Michal Simek
2014-10-09 15:57 ` Tom Rini
2014-10-09 16:10 ` Marek Vasut
2014-10-09 16:25 ` Tom Rini
2014-10-09 16:29 ` Marek Vasut
2014-10-09 22:11 ` Pavel Machek
2014-10-09 22:24 ` Wolfgang Denk
2014-10-09 23:00 ` Pavel Machek
2014-10-10 12:22 ` Wolfgang Denk
2014-10-10 14:04 ` Jeroen Hofstee
2014-10-10 14:26 ` Marek Vasut
2014-10-10 14:35 ` Fabio Estevam
2014-10-10 16:09 ` Jeroen Hofstee
2014-10-10 19:51 ` Albert ARIBAUD
2014-10-10 20:40 ` Jeroen Hofstee
2014-10-10 21:13 ` Albert ARIBAUD
2014-10-11 15:03 ` Wolfgang Denk
2014-10-11 15:16 ` Wolfgang Denk
2014-10-15 8:40 ` [U-Boot] puts() and newlines (was Re: Discussion topics / issues) Pavel Machek
2014-10-15 9:42 ` Pavel Machek [this message]
2014-10-20 15:51 ` Tom Rini
2014-10-11 14:44 ` [U-Boot] Discussion topics / issues Wolfgang Denk
2014-10-12 15:06 ` Jeroen Hofstee
2014-10-09 23:05 ` Pavel Machek
2014-10-10 11:05 ` Albert ARIBAUD
2014-10-10 12:34 ` Wolfgang Denk
2014-10-10 0:12 ` Tom Rini
2014-10-08 13:18 ` [U-Boot] [SoCFPGA] next steps Dinh Nguyen
2014-10-08 19:05 ` Marek Vasut
2014-10-11 18:22 ` Masahiro YAMADA
2014-10-19 21:19 ` Marek Vasut
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=20141015094200.GA26232@amd \
--to=pavel@denx.de \
--cc=u-boot@lists.denx.de \
/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