diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2013-10-27 18:54:04 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2013-10-27 18:54:04 +0000 |
commit | b35c729f43162448de4df55f1d522a1c4951d26d (patch) | |
tree | ec3f37d2193ccff1fbc234d172cefe9f7e015bf4 | |
parent | 60db32ed1676283ef0f262aa485d22e9d0954ffc (diff) |
If a constant string needs a name, use a static const array instead of a
pointer or non-const array, as that minimizes the symbols, maximizes the
placement into read-only memory, and avoids warnings from gcc -Wformat=2
when they're used as format strings.
ok deraadt@
-rw-r--r-- | sbin/isakmpd/x509.c | 6 | ||||
-rw-r--r-- | sbin/newfs_ext2fs/newfs_ext2fs.c | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/sbin/isakmpd/x509.c b/sbin/isakmpd/x509.c index 7c954d4edb1..73fe4fa5306 100644 --- a/sbin/isakmpd/x509.c +++ b/sbin/isakmpd/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.113 2010/06/29 19:50:16 reyk Exp $ */ +/* $OpenBSD: x509.c,v 1.114 2013/10/27 18:54:03 guenther Exp $ */ /* $EOM: x509.c,v 1.54 2001/01/16 18:42:16 ho Exp $ */ /* @@ -102,11 +102,11 @@ static int bucket_mask; int x509_generate_kn(int id, X509 *cert) { - char *fmt = "Authorizer: \"rsa-hex:%s\"\nLicensees: \"rsa-hex:%s" + static const char fmt[] = "Authorizer: \"rsa-hex:%s\"\nLicensees: \"rsa-hex:%s" "\"\nConditions: %s >= \"%s\" && %s <= \"%s\";\n"; char *ikey = NULL, *skey = NULL, *buf = NULL; char isname[256], subname[256]; - char *fmt2 = "Authorizer: \"DN:%s\"\nLicensees: \"DN:%s\"\n" + static const char fmt2[] = "Authorizer: \"DN:%s\"\nLicensees: \"DN:%s\"\n" "Conditions: %s >= \"%s\" && %s <= \"%s\";\n"; X509_NAME *issuer, *subject; struct keynote_deckey dc; diff --git a/sbin/newfs_ext2fs/newfs_ext2fs.c b/sbin/newfs_ext2fs/newfs_ext2fs.c index e1b99c2292d..49776178cd4 100644 --- a/sbin/newfs_ext2fs/newfs_ext2fs.c +++ b/sbin/newfs_ext2fs/newfs_ext2fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs_ext2fs.c,v 1.7 2012/12/04 02:27:00 deraadt Exp $ */ +/* $OpenBSD: newfs_ext2fs.c,v 1.8 2013/10/27 18:54:03 guenther Exp $ */ /* $NetBSD: newfs_ext2fs.c,v 1.8 2009/03/02 10:38:13 tsutsui Exp $ */ /* @@ -478,8 +478,6 @@ usage(void) exit(EXIT_FAILURE); } -char lmsg[] = "%s: can't read disk label; disk type must be specified"; - struct disklabel * getdisklabel(const char *s, int fd) { @@ -497,7 +495,9 @@ getdisklabel(const char *s, int fd) return (lp); } warn("ioctl (GDINFO)"); - errx(EXIT_FAILURE, lmsg, s); + errx(EXIT_FAILURE, + "%s: can't read disk label; disk type must be specified", + s); } return (&lab); } |