[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Jim Meyering meyering at alioth.debian.org
Mon Jan 14 19:35:18 UTC 2008


 include/parted/natmath.h    |   18 ++++++----
 libparted/cs/natmath.c      |   14 -------
 libparted/fs/fat/traverse.c |   18 +++++-----
 libparted/fs/fat/traverse.h |    4 +-
 parted/ui.c                 |   79 ++++++++++++++++++++++----------------------
 5 files changed, 66 insertions(+), 67 deletions(-)

New commits:
commit 8bd3645d7c184ac6a4076414b469ece15fbcccde
Author: Jim Meyering <meyering at redhat.com>
Date:   Mon Jan 14 20:01:39 2008 +0100

    Avoid new error detected by very latest gcc.
    
    * libparted/fs/fat/traverse.c (fat_dir_entry_get_name): Don't reference
    ->extension[3] via a pointer into the prior ->name[8] struct member.
    gcc detected the reference beyond end of name[8].
    Declare first parameter to be "const".
    * libparted/fs/fat/traverse.c: Update prototype.

diff --git a/libparted/fs/fat/traverse.c b/libparted/fs/fat/traverse.c
index 3d2e2b5..367f511 100644
--- a/libparted/fs/fat/traverse.c
+++ b/libparted/fs/fat/traverse.c
@@ -1,6 +1,6 @@
 /*
     libparted
-    Copyright (C) 1998, 1999, 2000, 2005, 2007 Free Software Foundation, Inc.
+    Copyright (C) 1998-2000, 2005, 2007-2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -340,22 +340,24 @@ fat_dir_entry_has_first_cluster (FatDirEntry* dir_entry, PedFileSystem* fs)
     decrypts silly DOS names to FILENAME.EXT
 */
 void
-fat_dir_entry_get_name (FatDirEntry*dir_entry, char *result) {
+fat_dir_entry_get_name (const FatDirEntry *dir_entry, char *result) {
 	int     i;
-	char   *src;
+	const char *src;
+	const char *ext;
 
 	src = dir_entry->name;
 
-	for (i=0; i<8; i++) {
+	for (i=0; i < sizeof dir_entry->name; i++) {
 		if (src[i] == ' ' || src[i] == 0) break;
 		*result++ = src[i];
 	}
 
-	if (src[8] != ' ' && src[8] != 0) {
+	ext = (const char *) dir_entry->extension;
+	if (ext[0] != ' ' && ext[0] != 0) {
 		*result++ = '.';
-		for (i=8; i<11; i++) {
-			if (src[i] == ' ' || src[i] == 0) break;
-			*result++ = src[i];
+		for (i=0; i < sizeof dir_entry->extension; i++) {
+			if (ext[i] == ' ' || ext[i] == 0) break;
+			*result++ = ext[i];
 		}
 	}
 
diff --git a/libparted/fs/fat/traverse.h b/libparted/fs/fat/traverse.h
index 21e4c27..17e4580 100644
--- a/libparted/fs/fat/traverse.h
+++ b/libparted/fs/fat/traverse.h
@@ -1,6 +1,6 @@
 /*
     libparted
-    Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc.
+    Copyright (C) 1998, 1999, 2000, 2007-2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -65,7 +65,7 @@ extern int fat_dir_entry_is_null_term (const FatDirEntry* dir_entry);
 extern int fat_dir_entry_is_file (FatDirEntry* dir_entry);
 extern int fat_dir_entry_is_system_file (FatDirEntry* dir_entry);
 extern int fat_dir_entry_is_directory (FatDirEntry* dir_entry);
-extern void fat_dir_entry_get_name (FatDirEntry* dir_entry, char* result);
+extern void fat_dir_entry_get_name (const FatDirEntry* dir_entry, char* result);
 extern int fat_dir_entry_is_active (FatDirEntry* dir_entry);
 extern int fat_dir_entry_has_first_cluster (FatDirEntry* dir_entry,
 					    PedFileSystem* fs);

commit 05942c0b1c7ae91a86ef3561124705d295d5dd24
Author: Jim Meyering <meyering at redhat.com>
Date:   Mon Jan 14 18:50:54 2008 +0100

    #ifdef function definitions to match uses, to avoid compiler warnings.
    
    * parted/ui.c (mask_signal, s_sigint_handler, s_sigsegv_handler)
    (s_sigfpe_handler):
    
    Signed-off-by: Jim Meyering <meyering at redhat.com>

diff --git a/parted/ui.c b/parted/ui.c
index a53643f..370c2be 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -1,6 +1,6 @@
 /*
     parted - a frontend to libparted
-    Copyright (C) 1999, 2000, 2001, 2002, 2006, 2007
+    Copyright (C) 1999, 2000, 2001, 2002, 2006, 2007, 2008
     Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
@@ -297,16 +297,6 @@ _dump_history (void)
 
 #endif /* HAVE_LIBREADLINE */
 
-static void
-mask_signal()
-{
-        sigset_t    curr;
-        sigset_t    prev;
-  
-        sigfillset(&curr);
-        sigprocmask(SIG_SETMASK, &curr, &prev);
-}
-
 /* Resets the environment by jumping to the initial state
  * saved during ui intitialisation.
  * Pass 1 as the parameter if you want to quit parted, 
@@ -339,15 +329,6 @@ sa_sigint_handler (int signum, siginfo_t* info, void *ucontext)
         reset_env (0);
 }
 
-/* Signal handler for SIGINT using 'signal'. */
-static void
-s_sigint_handler (int signum)
-{
-        signal (SIGINT, &s_sigint_handler);
-        mask_signal ();
-        sa_sigint_handler (signum, NULL, NULL);
-}
-
 /* Signal handler for SIGSEGV using 'sigaction'. */
 static void
 sa_sigsegv_handler (int signum, siginfo_t* info, void* ucontext)
@@ -383,15 +364,6 @@ sa_sigsegv_handler (int signum, siginfo_t* info, void* ucontext)
         abort ();
 }
 
-/* Signal handler for SIGSEGV using 'signal'. */
-static void
-s_sigsegv_handler (int signum)
-{
-        signal (SIGSEGV, &s_sigsegv_handler);
-        mask_signal ();
-        sa_sigsegv_handler (signum, NULL, NULL);
-}
-
 /* Signal handler for SIGFPE using 'sigaction'. */
 static void
 sa_sigfpe_handler (int signum, siginfo_t* info, void* ucontext)
@@ -456,15 +428,6 @@ sa_sigfpe_handler (int signum, siginfo_t* info, void* ucontext)
         abort ();
 }
 
-/* Signal handler for SIGFPE using 'signal'. */
-static void
-s_sigfpe_handler (int signum)
-{
-        signal (SIGFPE, &s_sigfpe_handler);
-        mask_signal ();
-        sa_sigfpe_handler (signum, NULL, NULL);
-}
-
 /* Signal handler for SIGILL using 'sigaction'. */
 static void
 sa_sigill_handler (int signum, siginfo_t* info, void* ucontext)
@@ -528,6 +491,27 @@ sa_sigill_handler (int signum, siginfo_t* info, void* ucontext)
         abort ();
 }
 
+#ifndef SA_SIGINFO
+
+static void
+mask_signal()
+{
+        sigset_t    curr;
+        sigset_t    prev;
+
+        sigfillset(&curr);
+        sigprocmask(SIG_SETMASK, &curr, &prev);
+}
+
+/* Signal handler for SIGINT using 'signal'. */
+static void
+s_sigint_handler (int signum)
+{
+        signal (SIGINT, &s_sigint_handler);
+        mask_signal ();
+        sa_sigint_handler (signum, NULL, NULL);
+}
+
 /* Signal handler for SIGILL using 'signal'. */
 static void
 s_sigill_handler (int signum)
@@ -537,6 +521,25 @@ s_sigill_handler (int signum)
         sa_sigill_handler (signum, NULL, NULL);
 }
 
+/* Signal handler for SIGSEGV using 'signal'. */
+static void
+s_sigsegv_handler (int signum)
+{
+        signal (SIGSEGV, &s_sigsegv_handler);
+        mask_signal ();
+        sa_sigsegv_handler (signum, NULL, NULL);
+}
+
+/* Signal handler for SIGFPE using 'signal'. */
+static void
+s_sigfpe_handler (int signum)
+{
+        signal (SIGFPE, &s_sigfpe_handler);
+        mask_signal ();
+        sa_sigfpe_handler (signum, NULL, NULL);
+}
+#endif
+
 static char*
 _readline (const char* prompt, const StrList* possibilities)
 {

commit d1d48d3af403ae623b0aee2d2068f980c86105fd
Author: Jim Meyering <meyering at redhat.com>
Date:   Mon Jan 14 18:48:38 2008 +0100

    Change two "extern inline" functions to "static inline".
    
    * include/parted/natmath.h (ped_div_round_up): This makes
    it compilable with bleeding-edge gcc.
    (ped_div_round_to_nearest): Likewise.
    * libparted/cs/natmath.c (ped_div_round_up, ped_div_round_to_nearest):
    Remove definitions.
    
    Signed-off-by: Jim Meyering <meyering at redhat.com>

diff --git a/include/parted/natmath.h b/include/parted/natmath.h
index e387833..596d98a 100644
--- a/include/parted/natmath.h
+++ b/include/parted/natmath.h
@@ -1,6 +1,6 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 2000, 2007 Free Software Foundation, Inc.
+    Copyright (C) 2000, 2007, 2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -87,15 +87,21 @@ ped_alignment_is_aligned (const PedAlignment* align, const PedGeometry* geom,
 extern const PedAlignment* ped_alignment_any;
 extern const PedAlignment* ped_alignment_none;
 
-extern inline PedSector
-ped_div_round_up (PedSector numerator, PedSector divisor);
+static inline PedSector
+ped_div_round_up (PedSector numerator, PedSector divisor)
+{
+	return (numerator + divisor - 1) / divisor;
+}
 
-extern inline PedSector
-ped_div_round_to_nearest (PedSector numerator, PedSector divisor);
+
+static inline PedSector
+ped_div_round_to_nearest (PedSector numerator, PedSector divisor)
+{
+	return (numerator + divisor/2) / divisor;
+}
 
 #endif /* PED_NATMATH_H_INCLUDED */
 
 /**
  * @}
  */
-
diff --git a/libparted/cs/natmath.c b/libparted/cs/natmath.c
index fd376cd..3821593 100644
--- a/libparted/cs/natmath.c
+++ b/libparted/cs/natmath.c
@@ -1,6 +1,6 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 2000, 2007 Free Software Foundation, Inc.
+    Copyright (C) 2000, 2007, 2008 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -74,18 +74,6 @@ ped_round_down_to (PedSector sector, PedSector grain_size)
 	return sector - abs_mod (sector, grain_size);
 }
 
-PedSector
-ped_div_round_up (PedSector numerator, PedSector divisor)
-{
-	return (numerator + divisor - 1) / divisor;
-}
-
-PedSector
-ped_div_round_to_nearest (PedSector numerator, PedSector divisor)
-{
-	return (numerator + divisor/2) / divisor;
-}
-
 /* Rounds a number up to the closest number that is a multiple of
  * grain_size.
  */



More information about the Parted-commits mailing list