* [Qemu-devel] [PATCH] net: Use g_strdup_printf instead of snprintf.
@ 2014-01-09 18:34 Hani Benhabiles
2014-01-13 5:22 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Hani Benhabiles @ 2014-01-09 18:34 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, stefanha, aliguori
assign_name() in net/net.c is using snprintf + g_strdup to get the same
result as g_strdup_printf.
Signed-off-by: Hani Benhabiles <kroosec@gmail.com>
---
net/net.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/net.c b/net/net.c
index 9db88cc..9363b35 100644
--- a/net/net.c
+++ b/net/net.c
@@ -164,7 +164,6 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr)
static char *assign_name(NetClientState *nc1, const char *model)
{
NetClientState *nc;
- char buf[256];
int id = 0;
QTAILQ_FOREACH(nc, &net_clients, next) {
@@ -176,9 +175,7 @@ static char *assign_name(NetClientState *nc1, const char *model)
}
}
- snprintf(buf, sizeof(buf), "%s.%d", model, id);
-
- return g_strdup(buf);
+ return g_strdup_printf("%s.%d", model, id);
}
static void qemu_net_client_destructor(NetClientState *nc)
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] net: Use g_strdup_printf instead of snprintf.
2014-01-09 18:34 [Qemu-devel] [PATCH] net: Use g_strdup_printf instead of snprintf Hani Benhabiles
@ 2014-01-13 5:22 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2014-01-13 5:22 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: qemu-trivial, qemu-devel, stefanha, aliguori
On Thu, Jan 09, 2014 at 07:34:27PM +0100, Hani Benhabiles wrote:
> assign_name() in net/net.c is using snprintf + g_strdup to get the same
> result as g_strdup_printf.
>
> Signed-off-by: Hani Benhabiles <kroosec@gmail.com>
> ---
> net/net.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-13 5:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-09 18:34 [Qemu-devel] [PATCH] net: Use g_strdup_printf instead of snprintf Hani Benhabiles
2014-01-13 5:22 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).