diff mbox series

[02/27] net/slirp: simplify checking for cmd: prefix

Message ID 20190117114359.5164-3-marcandre.lureau@redhat.com
State New
Headers show
Series slirp: make it again a standalone project (part 2) | expand

Commit Message

Marc-André Lureau Jan. 17, 2019, 11:43 a.m. UTC
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 net/slirp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Samuel Thibault Jan. 26, 2019, 11:49 p.m. UTC | #1
Marc-André Lureau, le jeu. 17 janv. 2019 15:43:34 +0400, a ecrit:
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

It's not strictly the same (g_str_has_prefix doesn't test that there are
characters after the prefix), but that should be fine, applied, thanks!
diff mbox series

Patch

diff --git a/net/slirp.c b/net/slirp.c
index ec07f662c00..b91741b8fc1 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -773,7 +773,7 @@  static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)
 
     snprintf(buf, sizeof(buf), "guestfwd.tcp.%d", port);
 
-    if ((strlen(p) > 4) && !strncmp(p, "cmd:", 4)) {
+    if (g_str_has_prefix(p, "cmd:")) {
         if (slirp_add_exec(s->slirp, &p[4], &server, port) < 0) {
             error_setg(errp, "Conflicting/invalid host:port in guest "
                        "forwarding rule '%s'", config_str);