[PATCH spice-server 1/3] reds: Reuse strspn and strcspn functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These functions are in the standard C library, not well known
but quite useful for parsing strings.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/reds.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 4b2c9919..4d343b25 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3549,19 +3549,14 @@ static const char* parse_video_codecs(const char *codecs, char **encoder,
     if (!codecs) {
         return NULL;
     }
-    while (*codecs == ';') {
-        codecs++;
-    }
+    codecs += strspn(codecs, ";");
     if (!*codecs) {
         return NULL;
     }
     int n;
     *encoder = *codec = NULL;
     if (sscanf(codecs, "%m[0-9a-zA-Z_]:%m[0-9a-zA-Z_]%n", encoder, codec, &n) != 2) {
-        while (*codecs != '\0' && *codecs != ';') {
-            codecs++;
-        }
-        return codecs;
+        return codecs + strcspn(codecs, ";");
     }
     return codecs + n;
 }
-- 
2.17.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]