summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2013-09-16 16:26:52 +0200
committerKarel Zak2013-09-16 16:47:10 +0200
commit1f75d1ce6ffeb741b6d5b1e080d11fd32b0fb01e (patch)
treeaca69e6a915fefc9e4e771c3420f1a6ed5e1548e
parentlibfdisk: make default geom usage more robust (diff)
downloadkernel-qcow2-util-linux-1f75d1ce6ffeb741b6d5b1e080d11fd32b0fb01e.tar.gz
kernel-qcow2-util-linux-1f75d1ce6ffeb741b6d5b1e080d11fd32b0fb01e.tar.xz
kernel-qcow2-util-linux-1f75d1ce6ffeb741b6d5b1e080d11fd32b0fb01e.zip
fdisk: remove unused code, coding style changes
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--fdisks/fdisk-menu.c2
-rw-r--r--fdisks/fdisk.c22
-rw-r--r--fdisks/fdisk.h15
-rw-r--r--libfdisk/src/alignment.c2
4 files changed, 11 insertions, 30 deletions
diff --git a/fdisks/fdisk-menu.c b/fdisks/fdisk-menu.c
index e381c34f3..10450cc65 100644
--- a/fdisks/fdisk-menu.c
+++ b/fdisks/fdisk-menu.c
@@ -312,7 +312,7 @@ static int menu_detect_collisions(struct fdisk_context *cxt)
return 0;
}
-int print_fdisk_menu(struct fdisk_context *cxt)
+static int print_fdisk_menu(struct fdisk_context *cxt)
{
struct menu_context mc = MENU_CXT_EMPTY;
const struct menu_entry *e;
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
index 3ee32d28b..8bd6c4edb 100644
--- a/fdisks/fdisk.c
+++ b/fdisks/fdisk.c
@@ -53,8 +53,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
fprintf(out,
_(" %1$s [options] <disk> change partition table\n"
- " %1$s [options] -l <disk> list partition table(s)\n"
- " %1$s -s <partition> give partition size(s) in blocks (deprecated)\n"),
+ " %1$s [options] -l <disk> list partition table(s)\n"),
program_invocation_short_name);
fputs(USAGE_OPTIONS, out);
@@ -162,7 +161,7 @@ void toggle_dos_compatibility_flag(struct fdisk_context *cxt)
void change_partition_type(struct fdisk_context *cxt)
{
size_t i;
- struct fdisk_parttype *t, *org_t;
+ struct fdisk_parttype *t = NULL, *org_t = NULL;
assert(cxt);
assert(cxt->label);
@@ -173,25 +172,22 @@ void change_partition_type(struct fdisk_context *cxt)
org_t = t = fdisk_get_partition_type(cxt, i);
if (!t)
fdisk_warnx(cxt, _("Partition %zu does not exist yet!"), i + 1);
+ else {
+ do {
+ t = ask_partition_type(cxt);
+ } while (!t);
- else do {
- t = ask_partition_type(cxt);
- if (!t)
- continue;
-
- if (fdisk_set_partition_type(cxt, i, t) == 0) {
+ if (fdisk_set_partition_type(cxt, i, t) == 0)
fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
_("Changed type of partition '%s' to '%s'."),
org_t ? org_t->name : _("Unknown"),
t ? t->name : _("Unknown"));
- } else {
+ else
fdisk_info(cxt,
_("Type of partition %zu is unchanged: %s."),
i + 1,
org_t ? org_t->name : _("Unknown"));
- }
- break;
- } while (1);
+ }
fdisk_free_parttype(t);
fdisk_free_parttype(org_t);
diff --git a/fdisks/fdisk.h b/fdisks/fdisk.h
index c97bf9435..15df8e41d 100644
--- a/fdisks/fdisk.h
+++ b/fdisks/fdisk.h
@@ -13,20 +13,9 @@
#include "blkdev.h"
#include "colors.h"
-extern void toggle_units(struct fdisk_context *cxt);
-
-static inline unsigned long
-scround(struct fdisk_context *cxt, unsigned long num)
-{
- unsigned long un = fdisk_context_get_units_per_sector(cxt);
- return (num + un - 1) / un;
-}
-
-
extern int get_user_reply(struct fdisk_context *cxt,
const char *prompt,
char *buf, size_t bufsz);
-extern int print_fdisk_menu(struct fdisk_context *cxt);
extern int process_fdisk_menu(struct fdisk_context **cxt);
extern int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
@@ -40,11 +29,7 @@ extern void list_partition_types(struct fdisk_context *cxt);
extern void list_disk_geometry(struct fdisk_context *cxt);
extern void change_partition_type(struct fdisk_context *cxt);
extern struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt);
-extern void reread_partition_table(struct fdisk_context *cxt, int leave);
-extern char *partition_type(struct fdisk_context *cxt, unsigned char type);
-extern int warn_geometry(struct fdisk_context *cxt);
extern void toggle_dos_compatibility_flag(struct fdisk_context *cxt);
-extern void warn_limits(struct fdisk_context *cxt);
#endif /* UTIL_LINUX_FDISK_H */
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c
index 9c29767f8..ae6d30cef 100644
--- a/libfdisk/src/alignment.c
+++ b/libfdisk/src/alignment.c
@@ -301,7 +301,7 @@ int fdisk_discover_geometry(struct fdisk_context *cxt)
cxt->total_sectors = (nsects / (cxt->sector_size >> 9));
/* what the kernel/bios thinks the geometry is */
- blkdev_get_geometry(cxt->dev_fd, &cxt->geom.heads, &cxt->geom.sectors);
+ blkdev_get_geometry(cxt->dev_fd, &cxt->geom.heads, (unsigned int *) &cxt->geom.sectors);
/* obtained heads and sectors */
recount_geometry(cxt);