mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Markus Pargmann <mpa@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2 4/9] vsprintf: Add scnprintf from kernel
Date: Tue,  8 Dec 2015 10:39:27 +0100	[thread overview]
Message-ID: <1449567572-21758-5-git-send-email-mpa@pengutronix.de> (raw)
In-Reply-To: <1449567572-21758-1-git-send-email-mpa@pengutronix.de>

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 include/stdio.h |  1 +
 lib/vsprintf.c  | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/stdio.h b/include/stdio.h
index f1909117621d..d0817bd0715a 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -13,6 +13,7 @@ void	serial_printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2
 
 int	sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
 int	snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
+int	scnprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
 int	vsprintf(char *buf, const char *fmt, va_list args);
 char	*asprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
 char	*vasprintf(const char *fmt, va_list ap);
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 800ded7939eb..9b8e8cf5f8e3 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -595,6 +595,30 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
 }
 EXPORT_SYMBOL(snprintf);
 
+/**
+ * scnprintf - Format a string and place it in a buffer
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @...: Arguments for the format string
+ *
+ * The return value is the number of characters written into @buf not including
+ * the trailing '\0'. If @size is == 0 the function returns 0.
+ */
+
+int scnprintf(char *buf, size_t size, const char *fmt, ...)
+{
+	va_list args;
+	int i;
+
+	va_start(args, fmt);
+	i = vscnprintf(buf, size, fmt, args);
+	va_end(args);
+
+	return i;
+}
+EXPORT_SYMBOL(scnprintf);
+
 /* Simplified asprintf. */
 char *vasprintf(const char *fmt, va_list ap)
 {
-- 
2.6.2


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

  parent reply	other threads:[~2015-12-08  9:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08  9:39 [PATCH v2 0/9] RAMOOPS read support for Barebox Markus Pargmann
2015-12-08  9:39 ` [PATCH v2 1/9] arm: boards: karo-tx6x remove definition of DIV_ROUND_UP Markus Pargmann
2015-12-08  9:39 ` [PATCH v2 2/9] log2: Add missing __rounddown_pow_of_two() Markus Pargmann
2015-12-08  9:39 ` [PATCH v2 3/9] printk: Add missing include/declaration Markus Pargmann
2015-12-08  9:39 ` Markus Pargmann [this message]
2015-12-08  9:39 ` [PATCH v2 5/9] lib: Import reed solomon code from kernel Markus Pargmann
2015-12-08  9:39 ` [PATCH v2 6/9] arm: Clarify memory layout calculation Markus Pargmann
2015-12-08  9:39 ` [PATCH v2 7/9] arm: start: Add visible sdram region for barebox board data Markus Pargmann
2015-12-08  9:39 ` [PATCH v2 8/9] arm: Add RAMOOPS memory area Markus Pargmann
2015-12-08  9:39 ` [PATCH v2 9/9] fs: Add pstore filesystem Markus Pargmann
2015-12-08 10:35   ` Antony Pavlov
2015-12-08 10:38     ` Markus Pargmann
2015-12-10  7:50 ` [PATCH v2 0/9] RAMOOPS read support for Barebox Sascha Hauer

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=1449567572-21758-5-git-send-email-mpa@pengutronix.de \
    --to=mpa@pengutronix.de \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox