[PATCH] split fdisk.c
Denis Vlasenko
vda at ilport.com.ua
Mon Feb 27 14:49:27 UTC 2006
Hi,
This patch removes aix/osf/sgi/sun related code from fdisk.c
into fdisk_aix.c etc. These files are included from fdisk.c,
like this:
static void bselect(void);
static void xbsd_print_disklabel(int);
#include "fdisk_osf.c"
This is a temporary solution, I think it will look cleaner
if they will be properly separated into modules. Later.
Patches:
fdisk_split.patch - groups code within fdisk.c so that it can be split.
Many ifdefs are gone, we rely on gcc to eliminate unreachable code:
#ifdef CONFIG_FEATURE_SUN_LABEL
#define LABEL_IS_SUN (label_sun == current_label_type)
#else
#define LABEL_IS_SUN 0
#endif
...
if (LABEL_IS_SUN)
eliminated_if_not_CONFIG_FEATURE_SUN_LABEL();
fdisk_split2.patch - actually does the split
patch is huge, but only moves code around, no changes
fdisk_split3.patch - fixes
I didn't test all .config options, minor breakage
happened at step 1. Fixing...
End result:
# size fdisk.o fdisk_org.o
text data bss dec hex filename
48418 32 11388 59838 e9be fdisk.o
49559 32 11388 60979 ee33 fdisk_org.o
# ls -l fdisk*.c
-rw-r--r-- 1 root 1002 77181 Feb 27 16:32 fdisk.c
-rw-r--r-- 1 root 1002 1954 Feb 27 14:10 fdisk_aix.c
-rw-r--r-- 1 root 1002 31366 Feb 27 16:32 fdisk_osf.c
-rw-r--r-- 1 root 1002 25265 Feb 27 16:26 fdisk_sgi.c
-rw-r--r-- 1 root 1002 20910 Feb 27 16:29 fdisk_sun.c
I've discovered a bug:
@@ -5864,53 +5797,45 @@ int fdisk_main(int argc, char **argv)
else
sgi_set_bootfile(line_ptr);
} else
#ifdef CONFIG_FEATURE_OSF_LABEL
bselect();
#endif
+
+/* BUG!? Think what will happen if !CONFIG_FEATURE_OSF_LABEL !!! */
+
break;
case 'c':
Not fixing yet...
Please apply or comment.
Patches will be sent in separate mails.
--
vda
More information about the busybox
mailing list