[Slirp] [Git][slirp/libslirp][master] 4 commits: misc: improve error report
Marc-André Lureau
gitlab at gitlab.freedesktop.org
Mon Feb 3 14:32:02 UTC 2020
Marc-André Lureau pushed to branch master at slirp / libslirp
Commits:
79ea9d8f by Marc-André Lureau at 2020-01-27T14:13:45+01:00
misc: improve error report
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
- - - - -
436c53ce by Marc-André Lureau at 2020-01-27T14:14:21+01:00
Use g_snprintf()
The GLib impl guarantees GNU compatible format strings, which fixes
the horror of Windows platform format strings.
Suggested-by: Daniel P. Berrangé <berrange at redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
- - - - -
3526e0bd by Marc-André Lureau at 2020-01-27T15:23:24+01:00
util: add gnuc format function attribute to slirp_fmt*
Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
Suggested-by: Daniel P. Berrangé <berrange at redhat.com>
- - - - -
296faab4 by Marc-André Lureau at 2020-02-03T14:31:56+00:00
Merge branch 'slirp-fmt' into 'master'
misc: slirp_fmt*() improvements
See merge request slirp/libslirp!28
- - - - -
3 changed files:
- src/tcp_subr.c
- src/util.c
- src/util.h
Changes:
=====================================
src/tcp_subr.c
=====================================
@@ -642,7 +642,7 @@ int tcp_emu(struct socket *so, struct mbuf *m)
}
NTOHS(n1);
NTOHS(n2);
- m_inc(m, snprintf(NULL, 0, "%d,%d\r\n", n1, n2) + 1);
+ m_inc(m, g_snprintf(NULL, 0, "%d,%d\r\n", n1, n2) + 1);
m->m_len = slirp_fmt(m->m_data, M_ROOM(m), "%d,%d\r\n", n1, n2);
} else {
*eol = '\r';
=====================================
src/util.c
=====================================
@@ -368,10 +368,10 @@ void slirp_pstrcpy(char *buf, int buf_size, const char *str)
static int slirp_vsnprintf(char *str, size_t size,
const char *format, va_list args)
{
- int rv = vsnprintf(str, size, format, args);
+ int rv = g_vsnprintf(str, size, format, args);
if (rv < 0) {
- g_error("vsnprintf() failed: %s", g_strerror(errno));
+ g_error("g_vsnprintf() failed: %s", g_strerror(errno));
}
return rv;
@@ -393,7 +393,7 @@ int slirp_fmt(char *str, size_t size, const char *format, ...)
va_end(args);
if (rv > size) {
- g_critical("vsnprintf() truncation");
+ g_critical("slirp_fmt() truncation");
}
return MIN(rv, size);
@@ -416,7 +416,7 @@ int slirp_fmt0(char *str, size_t size, const char *format, ...)
va_end(args);
if (rv >= size) {
- g_critical("vsnprintf() truncation");
+ g_critical("slirp_fmt0() truncation");
if (size > 0)
str[size - 1] = '\0';
rv = size;
=====================================
src/util.h
=====================================
@@ -24,6 +24,8 @@
#ifndef UTIL_H_
#define UTIL_H_
+#include <glib.h>
+
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
@@ -181,7 +183,7 @@ static inline int slirp_socket_set_fast_reuse(int fd)
void slirp_pstrcpy(char *buf, int buf_size, const char *str);
-int slirp_fmt(char *str, size_t size, const char *format, ...);
-int slirp_fmt0(char *str, size_t size, const char *format, ...);
+int slirp_fmt(char *str, size_t size, const char *format, ...) G_GNUC_PRINTF(3, 4);
+int slirp_fmt0(char *str, size_t size, const char *format, ...) G_GNUC_PRINTF(3, 4);
#endif
View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/compare/00ea58dcaba26863807c7a02a9f3666104b7f1a1...296faab4cfd1955bc37fff885985a5b2c0a1fc40
--
View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/compare/00ea58dcaba26863807c7a02a9f3666104b7f1a1...296faab4cfd1955bc37fff885985a5b2c0a1fc40
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/slirp/attachments/20200203/03e8f70b/attachment-0001.htm>
More information about the Slirp
mailing list