*/
#define RESOLVE_DEVICE(path,fail_stmt) \
do { \
- if (strncmp ((path), "/dev/", 5) != 0) { \
+ if (STRNEQLEN ((path), "/dev/", 5)) { \
reply_with_error ("%s: %s: expecting a device name", __func__, (path)); \
fail_stmt; \
} \
}
/* If the name begins with "/dev/sd" then try the alternatives. */
- if (strncmp (device, "/dev/sd", 7) != 0)
+ if (STRNEQLEN (device, "/dev/sd", 7))
goto error;
device[5] = 'h'; /* /dev/hd (old IDE driver) */
* That's a limitation of sorts of the Linux kernel. (Actually,
* we could do this if we add the kpartx program to libguestfs).
*/
- if (strncmp (dev, "/dev/sd", 7) != 0 || isdigit (dev[strlen(dev)-1])) {
+ if (STRNEQLEN (dev, "/dev/sd", 7) || isdigit (dev[strlen(dev)-1])) {
printf ("<vm-image dev=\"%s\"/>\n", dev);
return;
}
pr " fprintf (stderr, \"%s: returned size of buffer wrong, expected %d but got %%zu\\n\", size);\n" test_name len;
pr " return -1;\n";
pr " }\n";
- pr " if (strncmp (r, expected, size) != 0) {\n";
+ pr " if (STRNEQLEN (r, expected, size)) {\n";
pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r);\n" test_name;
pr " return -1;\n";
pr " }\n"