From 5dd95bd511d8f45a588ba465cf9448bd2da1c1e3 Mon Sep 17 00:00:00 2001 From: Michal Soltys Date: Thu, 14 Feb 2013 16:51:46 +0100 Subject: [PATCH] com32/chain: use single value for partiter related options (flags) Also use enum instead of #defines for flags. Signed-off-by: Michal Soltys --- com32/chain/chain.c | 10 +++++----- com32/chain/mangle.c | 4 ++-- com32/chain/options.c | 8 ++++---- com32/chain/options.h | 3 +-- com32/chain/partiter.h | 4 +--- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/com32/chain/chain.c b/com32/chain/chain.c index 9379602..bcc6468 100644 --- a/com32/chain/chain.c +++ b/com32/chain/chain.c @@ -71,7 +71,7 @@ static int find_by_sig(uint32_t mbr_sig, for (drive = 0x80; drive < 0x80 + fixed_cnt; drive++) { if (disk_get_params(drive, &diskinfo)) continue; /* Drive doesn't exist */ - if (!(boot_part = pi_begin(&diskinfo, opt.relax | opt.prefmbr))) + if (!(boot_part = pi_begin(&diskinfo, opt.piflags))) continue; /* Check for a MBR disk */ if (boot_part->type != typedos) { @@ -102,7 +102,7 @@ static int find_by_guid(const struct guid *gpt_guid, for (drive = 0x80; drive < 0x80 + fixed_cnt; drive++) { if (disk_get_params(drive, &diskinfo)) continue; /* Drive doesn't exist */ - if (!(boot_part = pi_begin(&diskinfo, opt.relax | opt.prefmbr))) + if (!(boot_part = pi_begin(&diskinfo, opt.piflags))) continue; /* Check for a GPT disk */ if (boot_part->type != typegpt) { @@ -134,7 +134,7 @@ static int find_by_label(const char *label, struct part_iter **_boot_part) for (drive = 0x80; drive < 0x80 + fixed_cnt; drive++) { if (disk_get_params(drive, &diskinfo)) continue; /* Drive doesn't exist */ - if (!(boot_part = pi_begin(&diskinfo, opt.relax | opt.prefmbr))) + if (!(boot_part = pi_begin(&diskinfo, opt.piflags))) continue; /* Check for a GPT disk */ if (!(boot_part->type == typegpt)) { @@ -321,7 +321,7 @@ int find_dp(struct part_iter **_iter) if (disk_get_params(drive, &diskinfo)) goto bail; /* this will start iteration over FDD, possibly raw */ - if (!(iter = pi_begin(&diskinfo, opt.relax | opt.prefmbr))) + if (!(iter = pi_begin(&diskinfo, opt.piflags))) goto bail; } else if (!strcmp(opt.drivename, "boot") || !strcmp(opt.drivename, "fs")) { @@ -341,7 +341,7 @@ int find_dp(struct part_iter **_iter) if (disk_get_params(drive, &diskinfo)) goto bail; /* this will start iteration over disk emulation, possibly raw */ - if (!(iter = pi_begin(&diskinfo, opt.relax | opt.prefmbr))) + if (!(iter = pi_begin(&diskinfo, opt.piflags))) goto bail; /* 'fs' => we should lookup the syslinux partition number and use it */ diff --git a/com32/chain/mangle.c b/com32/chain/mangle.c index a49fcfb..0c7319b 100644 --- a/com32/chain/mangle.c +++ b/com32/chain/mangle.c @@ -540,7 +540,7 @@ int manglepe_hide(struct part_iter *miter) if (miter->index > 4 && !(opt.hide & HIDE_EXT)) warn("Specified partition is logical, so it can't be unhidden without 'unhideall'."); - if (!(iter = pi_begin(&miter->di, PIF_STEPALL | opt.relax | opt.prefmbr))) + if (!(iter = pi_begin(&miter->di, PIF_STEPALL | opt.piflags))) return -1; while (!pi_next(iter) && !werr) { @@ -642,7 +642,7 @@ int manglepe_fixchs(struct part_iter *miter) return -1; } - if (!(iter = pi_begin(&miter->di, PIF_STEPALL | opt.relax | opt.prefmbr))) + if (!(iter = pi_begin(&miter->di, PIF_STEPALL | opt.piflags))) return -1; while (!pi_next(iter) && !werr) { diff --git a/com32/chain/options.c b/com32/chain/options.c index 531caf8..38881e7 100644 --- a/com32/chain/options.c +++ b/com32/chain/options.c @@ -336,17 +336,17 @@ int opt_parse_args(int argc, char *argv[]) } else if (!strcmp(argv[i], "nofixchs")) { opt.fixchs = false; } else if (!strcmp(argv[i], "relax")) { - opt.relax = PIF_RELAX; + opt.piflags |= PIF_RELAX; } else if (!strcmp(argv[i], "norelax")) { - opt.relax = 0; + opt.piflags &= ~PIF_RELAX; } else if (!strcmp(argv[i], "warn")) { opt.warn = true; } else if (!strcmp(argv[i], "nowarn")) { opt.warn = false; } else if (!strcmp(argv[i], "prefmbr")) { - opt.prefmbr = PIF_PREFMBR; + opt.piflags |= PIF_PREFMBR; } else if (!strcmp(argv[i], "noprefmbr")) { - opt.prefmbr = 0; + opt.piflags &= ~PIF_PREFMBR; } else if (!strcmp(argv[i], "nobreak")) { opt.brkchain = false; } else if (!strcmp(argv[i], "break")) { diff --git a/com32/chain/options.h b/com32/chain/options.h index 7b62582..df96e2d 100644 --- a/com32/chain/options.h +++ b/com32/chain/options.h @@ -49,8 +49,7 @@ struct options { addr_t soff; addr_t sip; int hide; - int relax; - int prefmbr; + int piflags; uint16_t keeppxe; bool isolinux; bool cmldr; diff --git a/com32/chain/partiter.h b/com32/chain/partiter.h index 3d2a151..ab4922c 100644 --- a/com32/chain/partiter.h +++ b/com32/chain/partiter.h @@ -46,9 +46,7 @@ enum {PI_OK, PI_DONE, PI_INSANE, PI_ERRLOAD}; /* flags */ -#define PIF_STEPALL 0b001 -#define PIF_RELAX 0b010 -#define PIF_PREFMBR 0b100 +enum {PIF_STEPALL = 1, PIF_RELAX = 2, PIF_PREFMBR = 4}; struct itertype; struct part_iter; -- 2.7.4