Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/sysinst - add printflike and fix the broken fo...



details:   https://anonhg.NetBSD.org/src/rev/15a927f24329
branches:  trunk
changeset: 772487:15a927f24329
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 05 21:22:49 2012 +0000

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

diffstat:

 distrib/utils/sysinst/defs.h         |  15 ++++++++-------
 distrib/utils/sysinst/disks.c        |   4 ++--
 distrib/utils/sysinst/savenewlabel.c |  11 ++++++++---
 distrib/utils/sysinst/target.c       |   6 +++---
 4 files changed, 21 insertions(+), 15 deletions(-)

diffs (128 lines):

diff -r ee8267b6820c -r 15a927f24329 distrib/utils/sysinst/defs.h
--- a/distrib/utils/sysinst/defs.h      Thu Jan 05 20:22:33 2012 +0000
+++ b/distrib/utils/sysinst/defs.h      Thu Jan 05 21:22:49 2012 +0000
@@ -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 @@
 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    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 @@
 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 *);
diff -r ee8267b6820c -r 15a927f24329 distrib/utils/sysinst/disks.c
--- a/distrib/utils/sysinst/disks.c     Thu Jan 05 20:22:33 2012 +0000
+++ b/distrib/utils/sysinst/disks.c     Thu Jan 05 21:22:49 2012 +0000
@@ -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 @@
 #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 = "";
diff -r ee8267b6820c -r 15a927f24329 distrib/utils/sysinst/savenewlabel.c
--- a/distrib/utils/sysinst/savenewlabel.c      Thu Jan 05 20:22:33 2012 +0000
+++ b/distrib/utils/sysinst/savenewlabel.c      Thu Jan 05 21:22:49 2012 +0000
@@ -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 @@
                (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 @@
        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,
diff -r ee8267b6820c -r 15a927f24329 distrib/utils/sysinst/target.c
--- a/distrib/utils/sysinst/target.c    Thu Jan 05 20:22:33 2012 +0000
+++ b/distrib/utils/sysinst/target.c    Thu Jan 05 21:22:49 2012 +0000
@@ -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 @@
 #ifdef DEBUG
        printf("collect real name %s\n", realname);
 #endif
-       return collect(kind, buffer, realname);
+       return collect(kind, buffer, "%s", realname);
 }
 
 /*



Home | Main Index | Thread Index | Old Index