On Friday 28 November 2014 14:31:01 Richard W.M. Jones wrote:
How about the attached patch? It's basically the same as your patch but I moved the code between files and tidied up some whitespace issues.
Present in both the patches:
+/* On *BSD systems, sometimes /dev/sda[1234] is a shadow of the real root + * filesystem that is probably /dev/sda5 + * (see: http://www.freebsd.org/doc/handbook/disk-organization.html) + */ +static void +check_for_duplicated_bsd_root (guestfs_h *g) +{ + size_t i; + bool is_primary, is_bsd; + struct inspect_fs *fs, *bsd_primary = NULL; + + for (i = 0; i < g->nr_fses; ++i) { + fs = &g->fses[i]; + + is_primary = match (g, fs->mountable, re_primary_partition); + is_bsd = + fs->type == OS_TYPE_FREEBSD || + fs->type == OS_TYPE_NETBSD || + fs->type == OS_TYPE_OPENBSD; + + if (fs->is_root && is_primary && is_bsd) { + bsd_primary = fs; + continue; + }
This will run the regexp matching for every filesystem found; what about inlining the match call as last part of the if, like: is_bsd = fs->type == OS_TYPE_FREEBSD || fs->type == OS_TYPE_NETBSD || fs->type == OS_TYPE_OPENBSD; if (fs->is_root && is_bsd && is_primary && match (g, fs->mountable, re_primary_partition)) { bsd_primary = fs; continue; } This way it is done only for *BSD filesystems, and is_primary is used only in that if anyway. Also, is_bsd and fs could be declared just inside the for, as they are not needed outside of it. -- Pino Toscano