On Tuesday 04 February 2014 15:56:54 Richard W.M. Jones wrote:
On Tue, Feb 04, 2014 at 04:01:31PM +0100, Pino Toscano wrote:
@@ -832,28 +835,22 @@ do_part_get_gpt_type(const char *device, int partnum)> /* Split the line in 2 at the colon */ char *colon = strchr (line, ':'); if (colon) {
-#define SEARCH "Partition GUID code" - if (colon - line == strlen(SEARCH) && - memcmp (line, SEARCH, strlen(SEARCH)) == 0) + if (colon - line == fieldlen && + memcmp (line, field, fieldlen) == 0)
Maybe use STRPREFIX macro here?
STRPREFIX calls strlen every time it is used, and uses strncmp. While not a big deal, the code above is used in a loop, so doing strlen once and comparing bits using memcmp should be faster. Yes, I know it is not performance-critical code, but since it was already there and working fine, IMHO could continue to do so :) -- Pino Toscano