Module Name:    src
Committed By:   christos
Date:           Thu Jan  5 21:22:49 UTC 2012

Modified Files:
        src/distrib/utils/sysinst: defs.h disks.c savenewlabel.c target.c

Log Message:
- add printflike and fix the broken formats
- make sure we don't exceed the number of partitions we have


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/distrib/utils/sysinst/defs.h
cvs rdiff -u -r1.119 -r1.120 src/distrib/utils/sysinst/disks.c
cvs rdiff -u -r1.9 -r1.10 src/distrib/utils/sysinst/savenewlabel.c
cvs rdiff -u -r1.52 -r1.53 src/distrib/utils/sysinst/target.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/utils/sysinst/defs.h
diff -u src/distrib/utils/sysinst/defs.h:1.157 src/distrib/utils/sysinst/defs.h:1.158
--- src/distrib/utils/sysinst/defs.h:1.157	Thu Jan  5 15:21:35 2012
+++ src/distrib/utils/sysinst/defs.h	Thu Jan  5 16:22:49 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.157 2012/01/05 20:21:35 christos Exp $	*/
+/*	$NetBSD: defs.h,v 1.158 2012/01/05 21:22:49 christos Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -384,8 +384,8 @@ int	config_network(void);
 void	mnt_net_config(void);
 
 /* From run.c */
-int	collect(int, char **, const char *, ...);
-int	run_program(int, const char *, ...);
+int	collect(int, char **, const char *, ...) __printflike(3, 4);
+int	run_program(int, const char *, ...) __printflike(2, 3);
 void	do_logging(void);
 int	do_system(const char *);
 
@@ -416,10 +416,10 @@ int	sanity_check(void);
 int	set_timezone(void);
 int	set_root_password(void);
 int	set_root_shell(void);
-void	scripting_fprintf(FILE *, const char *, ...);
-void	scripting_vfprintf(FILE *, const char *, va_list);
+void	scripting_fprintf(FILE *, const char *, ...) __printflike(2, 3);
+void	scripting_vfprintf(FILE *, const char *, va_list) __printflike(2, 0);
 void	add_rc_conf(const char *, ...);
-void	add_sysctl_conf(const char *, ...);
+void	add_sysctl_conf(const char *, ...) __printflike(1, 2);
 void	enable_rc_conf(void);
 void	set_sizemultname_cyl(void);
 void	set_sizemultname_meg(void);
@@ -437,7 +437,8 @@ const	char *target_expand(const char *);
 void	make_target_dir(const char *);
 void	append_to_target_file(const char *, const char *);
 void	echo_to_target_file(const char *, const char *);
-void	sprintf_to_target_file(const char *, const char *, ...);
+void	sprintf_to_target_file(const char *, const char *, ...)
+    __printflike(2, 3);
 void	trunc_target_file(const char *);
 const	char *target_prefix(void);
 int	target_chdir(const char *);

Index: src/distrib/utils/sysinst/disks.c
diff -u src/distrib/utils/sysinst/disks.c:1.119 src/distrib/utils/sysinst/disks.c:1.120
--- src/distrib/utils/sysinst/disks.c:1.119	Thu Jan  5 15:21:35 2012
+++ src/distrib/utils/sysinst/disks.c	Thu Jan  5 16:22:49 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: disks.c,v 1.119 2012/01/05 20:21:35 christos Exp $ */
+/*	$NetBSD: disks.c,v 1.120 2012/01/05 21:22:49 christos Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -668,7 +668,7 @@ make_fstab(void)
 #endif
 	}
 
-	scripting_fprintf(f, "# NetBSD /etc/fstab\n# See /usr/share/examples/"
+	scripting_fprintf(f, "# NetBSD %s/etc/fstab\n# See /usr/share/examples/"
 		"fstab/ for more examples.\n", target_prefix());
 	for (i = 0; i < getmaxpartitions(); i++) {
 		const char *s = "";

Index: src/distrib/utils/sysinst/savenewlabel.c
diff -u src/distrib/utils/sysinst/savenewlabel.c:1.9 src/distrib/utils/sysinst/savenewlabel.c:1.10
--- src/distrib/utils/sysinst/savenewlabel.c:1.9	Thu Jan  5 15:21:35 2012
+++ src/distrib/utils/sysinst/savenewlabel.c	Thu Jan  5 16:22:49 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: savenewlabel.c,v 1.9 2012/01/05 20:21:35 christos Exp $	*/
+/*	$NetBSD: savenewlabel.c,v 1.10 2012/01/05 21:22:49 christos Exp $	*/
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: savenewlabel.c,v 1.9 2012/01/05 20:21:35 christos Exp $");
+__RCSID("$NetBSD: savenewlabel.c,v 1.10 2012/01/05 21:22:49 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -76,7 +76,7 @@ savenewlabel(partinfo *lp, int nparts)
 		(void)fprintf(stderr, "Could not open /etc/disktab");
 		if (logging)
 			(void)fprintf(logfp,
-			    "Failed to open /etc/diskabel for appending.\n");
+			    "Failed to open /etc/disktab for appending.\n");
 		exit (1);
 	}
 	scripting_fprintf(f, "%s|NetBSD installation generated:\\\n", bsddiskname);
@@ -85,6 +85,11 @@ savenewlabel(partinfo *lp, int nparts)
 	scripting_fprintf(f, "\t:sc#%d:su#%" PRIu32 ":\\\n", dlhead*dlsec,
 	    (uint32_t)dlsize);
 	scripting_fprintf(f, "\t:se#%d:%s\\\n", sectorsize, doessf);
+	if ((size_t)nparts > __arraycount(bsdlabel)) {
+		nparts = __arraycount(bsdlabel);
+		if (logging)
+			(void)fprintf(logfp, "nparts limited to %d.\n", nparts);
+	}
 	for (i = 0; i < nparts; i++) {
 		scripting_fprintf(f, "\t:p%c#%" PRIu32 ":o%c#%" PRIu32
 		    ":t%c=%s:", 'a'+i, (uint32_t)bsdlabel[i].pi_size,

Index: src/distrib/utils/sysinst/target.c
diff -u src/distrib/utils/sysinst/target.c:1.52 src/distrib/utils/sysinst/target.c:1.53
--- src/distrib/utils/sysinst/target.c:1.52	Sat Sep 19 10:57:27 2009
+++ src/distrib/utils/sysinst/target.c	Thu Jan  5 16:22:49 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: target.c,v 1.52 2009/09/19 14:57:27 abs Exp $	*/
+/*	$NetBSD: target.c,v 1.53 2012/01/05 21:22:49 christos Exp $	*/
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -71,7 +71,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: target.c,v 1.52 2009/09/19 14:57:27 abs Exp $");
+__RCSID("$NetBSD: target.c,v 1.53 2012/01/05 21:22:49 christos Exp $");
 #endif
 
 /*
@@ -465,7 +465,7 @@ target_collect_file(int kind, char **buf
 #ifdef	DEBUG
 	printf("collect real name %s\n", realname);
 #endif
-	return collect(kind, buffer, realname);
+	return collect(kind, buffer, "%s", realname);
 }
 
 /*

Reply via email to