[Parted-commits] GNU Parted Official Repository: Changes to 'master'
Jim Meyering
meyering at alioth.debian.org
Sat Nov 7 17:42:56 UTC 2009
gnulib | 2 +-
libparted/arch/linux.c | 19 ++++++++++++++++---
libparted/fs/fat/table.c | 2 +-
libparted/labels/vtoc.c | 18 +++++++++---------
m4/parted.m4 | 4 ++--
parted/parted.c | 2 +-
parted/strlist.c | 4 ++--
parted/ui.c | 6 +++---
8 files changed, 35 insertions(+), 22 deletions(-)
New commits:
commit df09d9a0bc1b0a213031f14ade94379fb7028d09
Author: Jim Meyering <meyering at redhat.com>
Date: Sat Nov 7 17:02:50 2009 +0100
libparted: linux: don't deref NULL upon failed malloc or realloc
* libparted/arch/linux.c (_read_fd): Handle allocation failure.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index f7e6a5e..bf050c4 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -283,7 +283,14 @@ _read_fd (int fd, char **buf)
break;
filesize += s;
size += s;
- *buf = realloc (*buf, size);
+ char *new_buf = realloc (*buf, size);
+ if (new_buf == NULL) {
+ int saved_errno = errno;
+ free (*buf);
+ errno = saved_errno;
+ return -1;
+ }
+ *buf = new_buf;
} while (1);
if (filesize == 0 && s < 0) {
@@ -291,8 +298,14 @@ _read_fd (int fd, char **buf)
*buf = NULL;
return -1;
} else {
- /* there is always some excess memory left unused */
- *buf = realloc (*buf, filesize+1);
+ char *new_buf = realloc (*buf, filesize + 1);
+ if (new_buf == NULL) {
+ int saved_errno = errno;
+ free (*buf);
+ errno = saved_errno;
+ return -1;
+ }
+ *buf = new_buf;
(*buf)[filesize] = '\0';
}
commit 8a89fc682a21356933dfce7765f9e80c87c55639
Author: Jim Meyering <meyering at redhat.com>
Date: Sat Nov 7 16:32:37 2009 +0100
build: update gnulib submodule to latest
diff --git a/gnulib b/gnulib
index 7a73c53..453d6be 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 7a73c537bd0695870157c88dc5d7e9675c279015
+Subproject commit 453d6be7ea3ca6792fd28a71ccc0f1107a9239a4
commit 19d59bd32571cbd9c95486a216dc680799ce864a
Author: Jim Meyering <meyering at redhat.com>
Date: Sat Nov 7 16:47:37 2009 +0100
maint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 to exit
Convert all uses automatically, via these two commands:
git grep -l '\<exit *(1)'|xargs --no-run-if-empty \
perl -pi -e 's/\b(exit ?)\(1\)/$1(EXIT_FAILURE)/'
git grep -l '\<exit *(0)'|xargs --no-run-if-empty \
perl -pi -e 's/\b(exit ?)\(0\)/$1(EXIT_SUCCESS)/'
* libparted/fs/fat/table.c (fat_table_get): Use symbolic exit codes.
* libparted/labels/vtoc.c (vtoc_update_format5_label_add): Likewise.
(vtoc_update_format5_label_del): Likewise.
(vtoc_update_format7_label_add): Likewise.
(vtoc_update_format7_label_del): Likewise.
* m4/parted.m4 (PARTED_CHECK_LIBPARTED): Likewise.
* parted/parted.c (do_quit): Likewise.
* parted/strlist.c (gettext_to_wchar, wchar_to_str): Likewise.
* parted/ui.c (reset_env, help_msg, non_interactive_mode): Likewise.
diff --git a/libparted/fs/fat/table.c b/libparted/fs/fat/table.c
index 6ef208d..284250e 100644
--- a/libparted/fs/fat/table.c
+++ b/libparted/fs/fat/table.c
@@ -300,7 +300,7 @@ fat_table_get (const FatTable* ft, FatCluster cluster)
_("fat_table_get: cluster %ld outside "
"file system"),
(long) cluster);
- exit (1); /* FIXME */
+ exit (EXIT_FAILURE); /* FIXME */
}
switch (ft->fat_type) {
diff --git a/libparted/labels/vtoc.c b/libparted/labels/vtoc.c
index bdcb9f4..35b26e1 100644
--- a/libparted/labels/vtoc.c
+++ b/libparted/labels/vtoc.c
@@ -732,7 +732,7 @@ vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
{
puts ("BUG: overlapping free space extents "
"in FMT5 DSCB!\nexiting...");
- exit(1);
+ exit(EXIT_FAILURE);
}
if ((ext->t + ext->fc + ext->ft) == 0x0000) {
@@ -749,7 +749,7 @@ vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
if (tmp == NULL) {
/* BUG: no free extent found */
puts ("BUG: no free FMT5 DSCB extent found!\nexiting...");
- exit(1);
+ exit(EXIT_FAILURE);
}
for (i=0; i<26; i++) {
@@ -895,7 +895,7 @@ vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
puts ("BUG: corresponding free space extent "
"doesn't match free space currently shown "
"in FMT5 DSCB!\nexiting...");
- exit(1);
+ exit(EXIT_FAILURE);
}
if ((a > ext->t) && (a < ext->t + ext->fc*trk + ext->ft)
@@ -905,7 +905,7 @@ vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
"deleting doesn't match free space "
"currently shown in FMT5 DSCB!\n"
"exiting...");
- exit(1);
+ exit(EXIT_FAILURE);
}
}
@@ -915,7 +915,7 @@ vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
puts ("BUG: specified free space extent for "
"deleting not found in FMT5 DSCB!\n"
"exiting...");
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
@@ -976,7 +976,7 @@ vtoc_update_format7_label_add (format7_label_t *f7, int verbose,
{
puts ("BUG: overlapping free space extents "
"in FMT7 DSCB!\nexiting...");
- exit(1);
+ exit(EXIT_FAILURE);
}
if ((ext->a + ext->b) == 0x00000000) {
@@ -994,7 +994,7 @@ vtoc_update_format7_label_add (format7_label_t *f7, int verbose,
if (tmp == NULL) {
/* BUG: no free extent found */
puts ("BUG: no free FMT7 DSCB extent found!\nexiting...");
- exit(1);
+ exit(EXIT_FAILURE);
}
for (i=0; i<16; i++) {
@@ -1102,7 +1102,7 @@ vtoc_update_format7_label_del (format7_label_t *f7, int verbose,
"doesn't match free space currently shown in "
"FMT7 DSCB!\nexiting...");
printf ("%d %d %d %d\n", a, b, ext->a, ext->b);
- exit(1);
+ exit(EXIT_FAILURE);
}
}
@@ -1112,7 +1112,7 @@ vtoc_update_format7_label_del (format7_label_t *f7, int verbose,
puts ("BUG: specified free space extent for "
"deleting not found in FMT7 DSCB!\n"
"exiting...");
- exit(1);
+ exit(EXIT_FAILURE);
}
void
diff --git a/m4/parted.m4 b/m4/parted.m4
index 3f6e2e3..0dc7a7e 100644
--- a/m4/parted.m4
+++ b/m4/parted.m4
@@ -73,10 +73,10 @@ int main ()
const char *version;
if ( !(version = ped_get_version ()) )
- exit(1);
+ exit(EXIT_FAILURE);
if (sscanf(version, "%d.%d.%d", &major, &minor, µ) != 3) {
printf("%s, bad version string\n", version);
- exit(1);
+ exit(EXIT_FAILURE);
}
if ((major > $parted_config_major_version) ||
diff --git a/parted/parted.c b/parted/parted.c
index bc55bc9..d9c4333 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1616,7 +1616,7 @@ static int
do_quit (PedDevice** dev)
{
_done (*dev);
- exit (0);
+ exit (EXIT_SUCCESS);
}
static PedPartitionType
diff --git a/parted/strlist.c b/parted/strlist.c
index 4d173a9..5a9053a 100644
--- a/parted/strlist.c
+++ b/parted/strlist.c
@@ -128,7 +128,7 @@ gettext_to_wchar (const char* str)
error:
printf ("Error during translation: %s\n", strerror (errno));
- exit (1);
+ exit (EXIT_FAILURE);
}
#else /* ENABLE_NLS */
@@ -177,7 +177,7 @@ wchar_to_str (const wchar_t* str, size_t count)
error:
printf ("Error during translation: %s\n", strerror (errno));
- exit (1);
+ exit (EXIT_FAILURE);
}
#else /* ENABLE_NLS */
diff --git a/parted/ui.c b/parted/ui.c
index c63df8a..58fb80c 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -314,7 +314,7 @@ reset_env (int quit)
if (in_readline) {
putchar ('\n');
if (quit)
- exit (0);
+ exit (EXIT_SUCCESS);
siglongjmp (readline_state.jmp_state, 1);
}
@@ -1471,7 +1471,7 @@ help_msg ()
fputs (_("COMMANDs:"), stdout);
putchar ('\n');
print_commands_help ();
- exit (0);
+ exit (EXIT_SUCCESS);
}
void
@@ -1553,7 +1553,7 @@ non_interactive_mode (PedDevice** dev, Command* cmd_list[],
if (!(cmd->non_interactive)) {
fputs(_("This command does not make sense in "
"non-interactive mode.\n"), stdout);
- exit(1);
+ exit(EXIT_FAILURE);
goto error;
}
More information about the Parted-commits
mailing list