]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
modify parse_size_and_unit() to support percentage
authorJuergen Gross <jgross@suse.com>
Tue, 11 Dec 2018 08:42:20 +0000 (09:42 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 11 Dec 2018 08:42:20 +0000 (09:42 +0100)
Modify parse_size_and_unit() to support a value followed by a '%'
character. In this case ps is required to be non-NULL to ensure the
caller can detect that case. The returned value will be the integer
value s was pointing to and *ps will point to the '%' character.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/lib.c

index 62330205fe88a5e057e4be2233cda4510cb79d87..8ebec811b3345f2004433302bba0a9756d36fa79 100644 (file)
@@ -476,6 +476,10 @@ unsigned long long parse_size_and_unit(const char *s, const char **ps)
     case 'B': case 'b':
         s1++;
         break;
+    case '%':
+        if ( ps )
+            break;
+        /* fallthrough */
     default:
         ret <<= 10; /* default to kB */
         break;