* [PATCH 0/6] sfdisk: few maintenance patches
@ 2011-06-06 19:07 Sami Kerola
2011-06-06 19:07 ` [PATCH 1/6] sfdisk: declare unused function attributes Sami Kerola
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Sami Kerola @ 2011-06-06 19:07 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
I almost forgot these, mostly uninteresting, sfdisk patches. The
fifth patch is the only one which I'm interested to hear wherther
I got it right, or did I made a mess again. Priority / urgency of
the other patches is in somewhere between trivial and
unnecessary.
Also available from:
'sfdisk' of git://github.com/kerolasa/lelux-utiliteetit.git
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/6] sfdisk: declare unused function attributes
2011-06-06 19:07 [PATCH 0/6] sfdisk: few maintenance patches Sami Kerola
@ 2011-06-06 19:07 ` Sami Kerola
2011-06-06 19:07 ` [PATCH 2/6] sfdisk: help screen format Sami Kerola
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Sami Kerola @ 2011-06-06 19:07 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Add `__attribute__ ((__unused__))' where needed.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
fdisk/sfdisk.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index c38128a..8d8ccea 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -1590,17 +1590,29 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
}
static int
-osf_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
+osf_partition(char *dev __attribute__ ((__unused__)),
+ int fd __attribute__ ((__unused__)),
+ unsigned long start __attribute__ ((__unused__)),
+ struct disk_desc *z __attribute__ ((__unused__)))
+{
return 0;
}
static int
-sun_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
+sun_partition(char *dev __attribute__ ((__unused__)),
+ int fd __attribute__ ((__unused__)),
+ unsigned long start __attribute__ ((__unused__)),
+ struct disk_desc *z __attribute__ ((__unused__)))
+{
return 0;
}
static int
-amiga_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
+amiga_partition(char *dev __attribute__ ((__unused__)),
+ int fd __attribute__ ((__unused__)),
+ unsigned long start __attribute__ ((__unused__)),
+ struct disk_desc *z __attribute__ ((__unused__)))
+{
return 0;
}
@@ -2348,7 +2360,7 @@ activate_usage(char *progn) {
}
static void
-unhide_usage(char *progn) {
+unhide_usage(char *progn __attribute__ ((__unused__))) {
exit(1);
}
--
1.7.5.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/6] sfdisk: help screen format
2011-06-06 19:07 [PATCH 0/6] sfdisk: few maintenance patches Sami Kerola
2011-06-06 19:07 ` [PATCH 1/6] sfdisk: declare unused function attributes Sami Kerola
@ 2011-06-06 19:07 ` Sami Kerola
2011-06-06 19:07 ` [PATCH 3/6] sfdisk: previously undocumented options to usage Sami Kerola
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Sami Kerola @ 2011-06-06 19:07 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Readability improvement by making the help screen to look like
majority of command line utilities.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
fdisk/sfdisk.c | 93 +++++++++++++++++++++++++++++---------------------------
1 files changed, 48 insertions(+), 45 deletions(-)
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index 8d8ccea..1b35f66 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -2308,47 +2308,47 @@ read_input(char *dev, int interactive, struct disk_desc *z) {
/*
* G. The command line
*/
+static void usage(FILE * out)
+{
-static void version(void) {
- printf("sfdisk (%s)\n", PACKAGE_STRING);
+ fprintf(out, _("\nUsage:\n"
+ " %s [options] device [...]\n"),
+ program_invocation_short_name);
+ fprintf(out, _("Device is something like /dev/hda or /dev/sda\n"));
+
+ fprintf(out, _("\nOptions:\n"
+ " -s, --show-size list size of a partition\n"
+ " -c, --id change or print partition Id\n"
+ " -l, --list list partitions of each device\n"
+ " -d, --dump idem, but in a format suitable for later input\n"
+ " -i, --increment number cylinders etc. from 1 instead of from 0\n"
+ " -u, --unit=[SBCM] units in sectors, blocks, cylinders or MB\n"
+ " -T, --list-types list the known partition types\n"
+ " -D, --DOS for DOS-compatibility: waste a little space\n"
+ " -R, --re-read make kernel reread partition table\n"
+ " -N=NUM change only the partition with number NUM\n"
+ " -n do not actually write to disk\n"
+ " -O FILE save the sectors that will be overwritten to file\n"
+ " -I FILE restore sectors from file\n"
+ " -v, --version print version\n"
+ " -h, --help print this message\n"));
+
+ fprintf(out, _("\nDangerous options:\n"
+ " -f, --force disable all consistency checking\n"
+ " -g, --show-geometry print the kernel's idea of the geometry\n"
+ " -G, --show-pt-geometry print geometry guessed from the partition table\n"
+ " -x, --show-extended also list extended partitions on output\n"
+ " or expect descriptors for them on input\n"
+ " -L, --Linux do not complain about things irrelevant for Linux\n"
+ " -q, --quiet suppress warning messages\n"
+ "\n Override the detected geometry using:\n"
+ " -C, --cylinders=NUM set the number of cylinders to use\n"
+ " -H, --heads=NUM set the number of heads to use\n"
+ " -S, --sectors=NUM set the number of sectors to use\n\n"));
+
+ exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
-static void
-usage(void) {
- version();
- printf(_("Usage: %s [options] device ...\n"), PROGNAME);
- puts (_("device: something like /dev/hda or /dev/sda"));
- puts (_("useful options:"));
- puts (_(" -s [or --show-size]: list size of a partition"));
- puts (_(" -c [or --id]: print or change partition Id"));
- puts (_(" -l [or --list]: list partitions of each device"));
- puts (_(" -d [or --dump]: idem, but in a format suitable for later input"));
- puts (_(" -i [or --increment]: number cylinders etc. from 1 instead of from 0"));
- puts (_(" -uS, -uB, -uC, -uM: accept/report in units of sectors/blocks/cylinders/MB"));
- puts (_(" -T [or --list-types]:list the known partition types"));
- puts (_(" -D [or --DOS]: for DOS-compatibility: waste a little space"));
- puts (_(" -R [or --re-read]: make kernel reread partition table"));
- puts (_(" -N# : change only the partition with number #"));
- puts (_(" -n : do not actually write to disk"));
- puts (_(" -O file : save the sectors that will be overwritten to file"));
- puts (_(" -I file : restore these sectors again"));
- puts (_(" -v [or --version]: print version"));
- puts (_(" -? [or --help]: print this message"));
- puts (_("dangerous options:"));
- puts (_(" -g [or --show-geometry]: print the kernel's idea of the geometry"));
- puts (_(" -G [or --show-pt-geometry]: print geometry guessed from the partition table"));
- puts (_(" -x [or --show-extended]: also list extended partitions on output\n"
- " or expect descriptors for them on input"));
- puts (_(" -L [or --Linux]: do not complain about things irrelevant for Linux"));
- puts (_(" -q [or --quiet]: suppress warning messages"));
- puts (_(" You can override the detected geometry using:"));
- puts (_(" -C# [or --cylinders #]:set the number of cylinders to use"));
- puts (_(" -H# [or --heads #]: set the number of heads to use"));
- puts (_(" -S# [or --sectors #]: set the number of sectors to use"));
- puts (_("You can disable all consistency checking with:"));
- puts (_(" -f [or --force]: do what I say, even if it is stupid"));
- exit(1);
-}
static void
activate_usage(char *progn) {
@@ -2364,7 +2364,7 @@ unhide_usage(char *progn __attribute__ ((__unused__))) {
exit(1);
}
-static char short_opts[] = "cdfgilnqsu:vx?1A::C:DGH:I:LN:O:RS:TU::V";
+static const char short_opts[] = "cdfghilnqsu:vx1A::C:DGH:I:LN:O:RS:TU::V";
#define PRINT_ID 0400
#define CHANGE_ID 01000
@@ -2376,6 +2376,7 @@ static const struct option long_opts[] = {
{ "dump", no_argument, NULL, 'd' },
{ "force", no_argument, NULL, 'f' },
{ "show-geometry", no_argument, NULL, 'g' },
+ { "help", no_argument, NULL, 'h' },
{ "increment", no_argument, NULL, 'i' },
{ "list", no_argument, NULL, 'l' },
{ "quiet", no_argument, NULL, 'q' },
@@ -2383,7 +2384,6 @@ static const struct option long_opts[] = {
{ "unit", required_argument, NULL, 'u' },
{ "version", no_argument, NULL, 'v' },
{ "show-extended", no_argument, NULL, 'x' },
- { "help", no_argument, NULL, '?' },
{ "one-only", no_argument, NULL, '1' },
{ "cylinders", required_argument, NULL, 'C' },
{ "heads", required_argument, NULL, 'H' },
@@ -2556,8 +2556,12 @@ main(int argc, char **argv) {
case 'u':
set_format(*optarg); break;
case 'v':
- version();
- exit(0);
+ printf(_("%s from %s\n"), program_invocation_short_name,
+ PACKAGE_STRING);
+ return EXIT_SUCCESS;
+ case 'h':
+ usage(stdout);
+ return EXIT_SUCCESS;
case 'x':
show_extended = 1; break;
case 'A':
@@ -2591,9 +2595,8 @@ main(int argc, char **argv) {
unhide = 1; break;
case 'V':
verify = 1; break;
- case '?':
default:
- usage(); break;
+ usage(stderr); break;
/* undocumented flags */
case 128:
@@ -2659,7 +2662,7 @@ main(int argc, char **argv) {
else if (unhide)
unhide_usage(fdisk ? "sfdisk -U" : progn);
else
- usage();
+ usage(stderr);
}
if (opt_list || opt_out_geom || opt_out_pt_geom || opt_size || verify) {
--
1.7.5.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/6] sfdisk: previously undocumented options to usage
2011-06-06 19:07 [PATCH 0/6] sfdisk: few maintenance patches Sami Kerola
2011-06-06 19:07 ` [PATCH 1/6] sfdisk: declare unused function attributes Sami Kerola
2011-06-06 19:07 ` [PATCH 2/6] sfdisk: help screen format Sami Kerola
@ 2011-06-06 19:07 ` Sami Kerola
2011-06-06 19:07 ` [PATCH 4/6] docs: sfdisk manual update Sami Kerola
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Sami Kerola @ 2011-06-06 19:07 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
fdisk/sfdisk.c | 71 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 50 insertions(+), 21 deletions(-)
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index 1b35f66..d4dbcca 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -2319,26 +2319,43 @@ static void usage(FILE * out)
fprintf(out, _("\nOptions:\n"
" -s, --show-size list size of a partition\n"
" -c, --id change or print partition Id\n"
+ " --change-id change Id\n"
+ " --print-id print Id\n"
" -l, --list list partitions of each device\n"
" -d, --dump idem, but in a format suitable for later input\n"
" -i, --increment number cylinders etc. from 1 instead of from 0\n"
" -u, --unit=[SBCM] units in sectors, blocks, cylinders or MB\n"
+ " -1, --one-only reserved option that does nothing currently\n"
" -T, --list-types list the known partition types\n"
" -D, --DOS for DOS-compatibility: waste a little space\n"
+ " -E, --DOS-extended DOS extended partition compatibility\n"
" -R, --re-read make kernel reread partition table\n"
" -N=NUM change only the partition with number NUM\n"
" -n do not actually write to disk\n"
" -O FILE save the sectors that will be overwritten to file\n"
" -I FILE restore sectors from file\n"
+ " -V, --verify check that listed partition is reasonable\n"
" -v, --version print version\n"
" -h, --help print this message\n"));
fprintf(out, _("\nDangerous options:\n"
" -f, --force disable all consistency checking\n"
" -g, --show-geometry print the kernel's idea of the geometry\n"
+ " -A, --activate[=device] activate bootable flag\n"
" -G, --show-pt-geometry print geometry guessed from the partition table\n"
+ " -U, --unhide[=device] set partition unhidden\n"
+ " --no-reread skip partition re-read at boot\n"
" -x, --show-extended also list extended partitions on output\n"
" or expect descriptors for them on input\n"
+ " --leave-last do not allocate the last cylinder\n"
+ " --IBM same as --leave-last\n"
+ " --in-order partitions are in order\n"
+ " --not-in-order partitions are not in order\n"
+ " --inside-order all logicals inside outermost extended\n"
+ " --not-inside-order not all logicals inside outermost extended\n"
+ " --nested every partition is disjoint from all others\n"
+ " --chained like nested, but extended partitions may lie outside\n"
+ " --onesector partitions are mutually disjoint\n"
" -L, --Linux do not complain about things irrelevant for Linux\n"
" -q, --quiet suppress warning messages\n"
"\n Override the detected geometry using:\n"
@@ -2369,6 +2386,18 @@ static const char short_opts[] = "cdfghilnqsu:vx1A::C:DGH:I:LN:O:RS:TU::V";
#define PRINT_ID 0400
#define CHANGE_ID 01000
+enum {
+ OPT_NO_REREAD = CHAR_MAX + 1,
+ OPT_LEAVE_LAST,
+ OPT_IN_ORDER,
+ OPT_NOT_IN_ORDER,
+ OPT_INSIDE_OUTER,
+ OPT_NOT_INSIDE_OUTER,
+ OPT_NESTED,
+ OPT_CHAINED,
+ OPT_ONESECTOR
+};
+
static const struct option long_opts[] = {
{ "change-id", no_argument, NULL, 'c' + CHANGE_ID },
{ "print-id", no_argument, NULL, 'c' + PRINT_ID },
@@ -2396,17 +2425,17 @@ static const struct option long_opts[] = {
{ "re-read", no_argument, NULL, 'R' },
{ "list-types", no_argument, NULL, 'T' },
{ "unhide", optional_argument, NULL, 'U' },
- { "no-reread", no_argument, NULL, 160 },
- { "IBM", no_argument, NULL, 161 },
- { "leave-last", no_argument, NULL, 161 },
-/* undocumented flags - not all completely implemented */
- { "in-order", no_argument, NULL, 128 },
- { "not-in-order", no_argument, NULL, 129 },
- { "inside-outer", no_argument, NULL, 130 },
- { "not-inside-outer", no_argument, NULL, 131 },
- { "nested", no_argument, NULL, 132 },
- { "chained", no_argument, NULL, 133 },
- { "onesector", no_argument, NULL, 134 },
+ { "no-reread", no_argument, NULL, OPT_NO_REREAD },
+ { "IBM", no_argument, NULL, OPT_LEAVE_LAST },
+ { "leave-last", no_argument, NULL, OPT_LEAVE_LAST },
+/* dangerous flags - not all completely implemented */
+ { "in-order", no_argument, NULL, OPT_IN_ORDER },
+ { "not-in-order", no_argument, NULL, OPT_NOT_IN_ORDER },
+ { "inside-outer", no_argument, NULL, OPT_INSIDE_OUTER },
+ { "not-inside-outer", no_argument, NULL, OPT_NOT_INSIDE_OUTER },
+ { "nested", no_argument, NULL, OPT_NESTED },
+ { "chained", no_argument, NULL, OPT_CHAINED },
+ { "onesector", no_argument, NULL, OPT_ONESECTOR },
{ NULL, 0, NULL, 0 }
};
@@ -2598,26 +2627,26 @@ main(int argc, char **argv) {
default:
usage(stderr); break;
- /* undocumented flags */
- case 128:
+ /* dangerous flags */
+ case OPT_IN_ORDER:
partitions_in_order = 1; break;
- case 129:
+ case OPT_NOT_IN_ORDER:
partitions_in_order = 0; break;
- case 130:
+ case OPT_INSIDE_OUTER:
all_logicals_inside_outermost_extended = 1; break;
- case 131:
+ case OPT_NOT_INSIDE_OUTER:
all_logicals_inside_outermost_extended = 0; break;
- case 132:
+ case OPT_NESTED:
boxes = NESTED; break;
- case 133:
+ case OPT_CHAINED:
boxes = CHAINED; break;
- case 134:
+ case OPT_ONESECTOR:
boxes = ONESECTOR; break;
/* more flags */
- case 160:
+ case OPT_NO_REREAD:
no_reread = 1; break;
- case 161:
+ case OPT_LEAVE_LAST:
leave_last = 1; break;
}
}
--
1.7.5.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/6] docs: sfdisk manual update
2011-06-06 19:07 [PATCH 0/6] sfdisk: few maintenance patches Sami Kerola
` (2 preceding siblings ...)
2011-06-06 19:07 ` [PATCH 3/6] sfdisk: previously undocumented options to usage Sami Kerola
@ 2011-06-06 19:07 ` Sami Kerola
2011-06-06 19:07 ` [PATCH 5/6] sfdisk: fix implicit overflow Sami Kerola
2011-06-06 19:07 ` [PATCH 6/6] sfdisk: fix for data type mismatches Sami Kerola
5 siblings, 0 replies; 10+ messages in thread
From: Sami Kerola @ 2011-06-06 19:07 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Add to manual page previously unmentioned options and few missing
long options.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
fdisk/sfdisk.8 | 53 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/fdisk/sfdisk.8 b/fdisk/sfdisk.8
index f6e98c1..c3f06b3 100644
--- a/fdisk/sfdisk.8
+++ b/fdisk/sfdisk.8
@@ -165,7 +165,7 @@ Print version number of
.B sfdisk
and exit immediately.
.TP
-.BR \-? " or " \-\-help
+.BR \-h " or " \-\-help
Print a usage message and exit immediately.
.TP
.BR \-T " or " \-\-list\-types
@@ -184,7 +184,7 @@ the partition table.
.BR \-l " or " \-\-list
List the partitions of a device.
.TP
-.BR \-d
+.BR \-d " or " \-\-dump
Dump the partitions of a device in a format useful as input
to sfdisk. For example,
.br
@@ -218,7 +218,7 @@ and change nothing else. (Probably this fifth partition
is called /dev/hdb5, but you are free to call it something else,
like `/my_equipment/disks/2/5' or so).
.TP
-.BI \-A " number"
+.BI \-A " or " \-\-activate " number"
Make the indicated partition(s) active, and all others inactive.
.TP
.BI \-c "\fR or " \-\-id " number [Id]"
@@ -238,22 +238,22 @@ For example:
.fi
first reports that /dev/hdb5 has Id 6, and then changes that into 83.
.TP
-.BR \-uS " or " \-uB " or " \-uC " or " \-uM
-Accept or report in units of sectors (blocks, cylinders, megabytes,
-respectively). The default is cylinders, at least when the geometry
-is known.
+.BR \-u " or " \-\-unit " SBCM"
+Accept as input, or when reporting show, in units of Sectors
+(Blocks, Cylinders, Megabytes, respectively). The default is
+cylinders, at least when the geometry is known.
.TP
.BR \-x " or " \-\-show\-extended
Also list non-primary extended partitions on output,
and expect descriptors for them on input.
.TP
-.BI \-C " cylinders"
+.BI \-C " or " \-\-cylinders " cylinders"
Specify the number of cylinders, possibly overriding what the kernel thinks.
.TP
-.BI \-H " heads"
+.BI \-H " or " \-\-heads " heads"
Specify the number of heads, possibly overriding what the kernel thinks.
.TP
-.BI \-S " sectors"
+.BI \-S " or " \-\-sectors " sectors"
Specify the number of sectors, possibly overriding what the kernel thinks.
.TP
.BR \-f " or " \-\-force
@@ -301,7 +301,7 @@ Sometimes the last cylinder contains a bad sector table.
.B \-n
Go through all the motions, but do not actually write to disk.
.TP
-.B \-R
+.B \-R " or " \-\-re-read
Only execute the BLKRRPART ioctl (to make the kernel re-read
the partition table). This can be useful for checking in advance
that the final BLKRRPART will be successful, and also when you
@@ -316,6 +316,33 @@ is not mounted, or in use as a swap device, and refuses to continue
if it is. This option suppresses the test. (On the other hand, the \-f
option would force sfdisk to continue even when this test fails.)
.TP
+.B \-\-in\-order
+Caution, see warning section. To be documented.
+.TP
+.B \-\-not\-in\-order
+Caution, see warning section. To be documented.
+.TP
+.B \-\-inside\-order
+Caution, see warning section. Chaining order.
+.TP
+.B \-\-not\-inside\-order
+Caution, see warning section. Chaining order.
+.TP
+.B \-\-nested
+Caution, see warning section. Every partition is contained in the
+surrounding partitions and is disjoint from all others.
+.TP
+.B \-\-chained
+Caution, see warning section. Every data partition is contained in
+the surrounding partitions and disjoint from all others, but
+extended partitions may lie outside (insofar as allowed by
+all_logicals_inside_outermost_extended).
+.TP
+.B \-\-onesector
+Caution, see warning section. All data partitions are mutually
+disjoint; extended partitions each use one sector only (except
+perhaps for the outermost one).
+.TP
.BI \-O " file"
Just before writing the new partition, output the sectors
that are going to be overwritten to
@@ -479,7 +506,11 @@ and terminate with end-of-file (^D).
.B sfdisk
will assume that your input line represents the first of four,
that the second one is extended, and the 3rd and 4th are empty.)
+.SH "CAUTION WARNIGNS"
+The options marked with caution in the manual page are dangerous.
+For example all functionality is not completely implemented,
+which can be a reason for unexpected results.
.SH "DOS 6.x WARNING"
The DOS 6.x FORMAT command looks for some information in the first
--
1.7.5.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/6] sfdisk: fix implicit overflow
2011-06-06 19:07 [PATCH 0/6] sfdisk: few maintenance patches Sami Kerola
` (3 preceding siblings ...)
2011-06-06 19:07 ` [PATCH 4/6] docs: sfdisk manual update Sami Kerola
@ 2011-06-06 19:07 ` Sami Kerola
2011-06-06 19:07 ` [PATCH 6/6] sfdisk: fix for data type mismatches Sami Kerola
5 siblings, 0 replies; 10+ messages in thread
From: Sami Kerola @ 2011-06-06 19:07 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
sfdisk.c:1650:6: warning: overflow in implicit constant conversion [-Woverflow]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
fdisk/sfdisk.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index d4dbcca..afecb93 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -1647,7 +1647,7 @@ write_partitions(char *dev, int fd, struct disk_desc *z) {
if (p->ptype == DOS_TYPE) {
copy_from_part(&(p->p), s->data + p->offset);
s->data[510] = 0x55;
- s->data[511] = 0xaa;
+ s->data[511] = (unsigned char) 0xaa;
}
}
if (save_sector_file) {
--
1.7.5.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/6] sfdisk: fix for data type mismatches
2011-06-06 19:07 [PATCH 0/6] sfdisk: few maintenance patches Sami Kerola
` (4 preceding siblings ...)
2011-06-06 19:07 ` [PATCH 5/6] sfdisk: fix implicit overflow Sami Kerola
@ 2011-06-06 19:07 ` Sami Kerola
2011-06-14 11:29 ` Karel Zak
5 siblings, 1 reply; 10+ messages in thread
From: Sami Kerola @ 2011-06-06 19:07 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
fdisk/sfdisk.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index afecb93..d761032 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -1409,7 +1409,7 @@ extended_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z)
cp = s->data + 0x1be;
- if (pno+4 >= ARRAY_SIZE(z->partitions)) {
+ if ((unsigned long) pno+4 >= ARRAY_SIZE(z->partitions)) {
do_warn(_("too many partitions - ignoring those past nr (%d)\n"),
pno-1);
break;
@@ -1486,7 +1486,7 @@ bsd_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z) {
bp = bp0 = &l->d_partitions[0];
while (bp - bp0 < BSD_MAXPARTITIONS && bp - bp0 < l->d_npartitions) {
- if (pno+1 >= ARRAY_SIZE(z->partitions)) {
+ if ((unsigned long) pno+1 >= ARRAY_SIZE(z->partitions)) {
do_warn(_("too many partitions - ignoring those "
"past nr (%d)\n"), pno-1);
break;
@@ -1762,7 +1762,7 @@ read_stdin(char **fields, char *line, int fieldssize, int linesize) {
ip++;
if (*ip == 0)
return fno;
- for(d = dumpflds; d-dumpflds < ARRAY_SIZE(dumpflds); d++) {
+ for(d = dumpflds; d-dumpflds < (long) ARRAY_SIZE(dumpflds); d++) {
if (!strncmp(ip, d->fldname, strlen(d->fldname))) {
ip += strlen(d->fldname);
while(isspace(*ip))
@@ -1957,7 +1957,7 @@ compute_start_sect(struct part_desc *p, struct part_desc *ep) {
p->size += delta;
if (is_extended(p->p.sys_type) && boxes == ONESECTOR)
p->size = inc;
- else if (old_size <= -delta) {
+ else if ((ssize_t) old_size <= (ssize_t) -delta) {
my_warn(_("no room for partition descriptor\n"));
return 0;
}
@@ -2256,7 +2256,7 @@ read_partition_chain(char *dev, int interactive, struct part_desc *ep,
eob = 0;
while (1) {
base = z->partno;
- if (base+4 > ARRAY_SIZE(z->partitions)) {
+ if ((unsigned long) base+4 > ARRAY_SIZE(z->partitions)) {
do_warn(_("too many partitions\n"));
break;
}
@@ -2285,7 +2285,7 @@ read_input(char *dev, int interactive, struct disk_desc *z) {
int i;
struct part_desc *partitions = &(z->partitions[0]), *ep;
- for (i=0; i < ARRAY_SIZE(z->partitions); i++)
+ for (i=0; (unsigned long) i < ARRAY_SIZE(z->partitions); i++)
partitions[i] = zero_part_desc;
z->partno = 0;
--
1.7.5.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 6/6] sfdisk: fix for data type mismatches
2011-06-06 19:07 ` [PATCH 6/6] sfdisk: fix for data type mismatches Sami Kerola
@ 2011-06-14 11:29 ` Karel Zak
2011-06-14 20:00 ` Sami Kerola
0 siblings, 1 reply; 10+ messages in thread
From: Karel Zak @ 2011-06-14 11:29 UTC (permalink / raw)
To: Sami Kerola; +Cc: util-linux
On Mon, Jun 06, 2011 at 09:07:19PM +0200, Sami Kerola wrote:
> + if ((unsigned long) pno+4 >= ARRAY_SIZE(z->partitions)) {
Why 'unsigned long'? I guess that ARRAY_SIZE returns size_t. Maybe it
would be better to use size_t for partno numbers rather than add the
cast.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 6/6] sfdisk: fix for data type mismatches
2011-06-14 11:29 ` Karel Zak
@ 2011-06-14 20:00 ` Sami Kerola
2011-06-29 10:50 ` Karel Zak
0 siblings, 1 reply; 10+ messages in thread
From: Sami Kerola @ 2011-06-14 20:00 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
On Tue, Jun 14, 2011 at 13:29, Karel Zak <kzak@redhat.com> wrote:
> On Mon, Jun 06, 2011 at 09:07:19PM +0200, Sami Kerola wrote:
>> + =A0 =A0 if ((unsigned long) pno+4 >=3D ARRAY_SIZE(z->partitions)) {
>
> =A0Why 'unsigned long'? I guess that ARRAY_SIZE returns size_t. Maybe it
> =A0would be better to use size_t for partno numbers rather than add the
> =A0cast.
Yes are right, that was silly. I reviewed the patch and changed data
types to size_t. The fix is pushed with force to my git.
p.s. The style in the file is really horrible. How about doing the
following, which will unify the style within the file without changing
everything.
indent -linux -i4 -psl -brf sfdisk.c
--=20
=A0=A0 Sami Kerola
=A0=A0 http://www.iki.fi/kerolasa/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 6/6] sfdisk: fix for data type mismatches
2011-06-14 20:00 ` Sami Kerola
@ 2011-06-29 10:50 ` Karel Zak
0 siblings, 0 replies; 10+ messages in thread
From: Karel Zak @ 2011-06-29 10:50 UTC (permalink / raw)
To: kerolasa; +Cc: util-linux
On Tue, Jun 14, 2011 at 10:00:56PM +0200, Sami Kerola wrote:
> Yes are right, that was silly. I reviewed the patch and changed data
> types to size_t. The fix is pushed with force to my git.
Merged.
> p.s. The style in the file is really horrible. How about doing the
> following, which will unify the style within the file without changing
> everything.
>
> indent -linux -i4 -psl -brf sfdisk.c
Hmm.. I don't like such patches, but you're right that the file is
horrible. Fixed....
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-06-29 10:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-06 19:07 [PATCH 0/6] sfdisk: few maintenance patches Sami Kerola
2011-06-06 19:07 ` [PATCH 1/6] sfdisk: declare unused function attributes Sami Kerola
2011-06-06 19:07 ` [PATCH 2/6] sfdisk: help screen format Sami Kerola
2011-06-06 19:07 ` [PATCH 3/6] sfdisk: previously undocumented options to usage Sami Kerola
2011-06-06 19:07 ` [PATCH 4/6] docs: sfdisk manual update Sami Kerola
2011-06-06 19:07 ` [PATCH 5/6] sfdisk: fix implicit overflow Sami Kerola
2011-06-06 19:07 ` [PATCH 6/6] sfdisk: fix for data type mismatches Sami Kerola
2011-06-14 11:29 ` Karel Zak
2011-06-14 20:00 ` Sami Kerola
2011-06-29 10:50 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox