[PATCH] winebus.sys: Avoid an unneeded strlen() call.

Francois Gouget fgouget at free.fr
Tue Oct 23 08:51:32 CDT 2018


Signed-off-by: Francois Gouget <fgouget at free.fr>
---

It seems wasteful to compute the length of the string when all we care 
about is the first character. Plus the 'if (*str)' pattern is pretty 
common and used extensively in Wine already.

Note that this does not change handling of NULL pointers since strlen() 
does not check for them.

 dlls/winebus.sys/bus_udev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c
index dabda6a2705..64b245e630d 100644
--- a/dlls/winebus.sys/bus_udev.c
+++ b/dlls/winebus.sys/bus_udev.c
@@ -1084,7 +1084,7 @@ static int parse_uevent_info(const char *uevent, DWORD *vendor_id,
         else if (strcmp(key, "HID_UNIQ") == 0)
         {
             /* The caller has to free the serial number */
-            if (strlen(value))
+            if (*value)
             {
                 *serial_number = (WCHAR*)strdupAtoW(value);
                 found_serial = 1;
-- 
2.19.1



More information about the wine-devel mailing list