--- src/sbin/gpt/remove.c 2007/06/16 22:29:27 1.1 +++ src/sbin/gpt/remove.c 2007/06/17 08:34:59 1.2 @@ -42,7 +42,7 @@ static int all; static uuid_t type; static off_t block, size; -static unsigned int entry; +static unsigned int entry = NOENTRY; static void usage_remove(void) @@ -89,16 +89,16 @@ rem(int fd) /* Remove all matching entries in the map. */ for (m = map_first(); m != NULL; m = m->map_next) { - if (m->map_type != MAP_TYPE_GPT_PART || m->map_index < 1) + if (m->map_type != MAP_TYPE_GPT_PART || m->map_index == NOENTRY) continue; - if (entry > 0 && entry != m->map_index) + if (entry != NOENTRY && entry != m->map_index) continue; if (block > 0 && block != m->map_start) continue; if (size > 0 && size != m->map_size) continue; - i = m->map_index - 1; + i = m->map_index; hdr = gpt->map_data; ent = (void*)((char*)tbl->map_data + i * @@ -134,7 +134,7 @@ rem(int fd) gpt_write(fd, lbt); gpt_write(fd, tpg); - printf("%sp%u removed\n", device_name, m->map_index); + printf("%ss%u removed\n", device_name, m->map_index); } } @@ -160,10 +160,10 @@ cmd_remove(int argc, char *argv[]) usage_remove(); break; case 'i': - if (entry > 0) + if (entry != NOENTRY) usage_remove(); - entry = strtol(optarg, &p, 10); - if (*p != 0 || entry < 1) + entry = strtoul(optarg, &p, 10); + if (*p != 0 || entry == NOENTRY) usage_remove(); break; case 's': @@ -185,7 +185,8 @@ cmd_remove(int argc, char *argv[]) } if (!all ^ - (block > 0 || entry > 0 || size > 0 || !uuid_is_nil(&type, NULL))) + (block > 0 || entry != NOENTRY || size > 0 || + !uuid_is_nil(&type, NULL))) usage_remove(); if (argc == optind)