diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-11-19 20:28:57 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-11-19 20:28:57 +0000 |
commit | 5184884c8610edc12e505d668681d8d45a5f1176 (patch) | |
tree | 7ce1cc7eda73ec1d9bee113cb90ac09e39269e6e /sys/lib/libsa | |
parent | 488bb12fd0af706881e23eb57ed2b9cc00113500 (diff) |
Sprinkle const whenever possible.
Diffstat (limited to 'sys/lib/libsa')
-rw-r--r-- | sys/lib/libsa/dkcksum.c | 4 | ||||
-rw-r--r-- | sys/lib/libsa/ether.c | 8 | ||||
-rw-r--r-- | sys/lib/libsa/getfile.c | 6 | ||||
-rw-r--r-- | sys/lib/libsa/in_cksum.c | 8 | ||||
-rw-r--r-- | sys/lib/libsa/net.c | 14 | ||||
-rw-r--r-- | sys/lib/libsa/net.h | 14 | ||||
-rw-r--r-- | sys/lib/libsa/nfs.c | 11 | ||||
-rw-r--r-- | sys/lib/libsa/nfs.h | 4 | ||||
-rw-r--r-- | sys/lib/libsa/readdir.c | 5 | ||||
-rw-r--r-- | sys/lib/libsa/saerrno.h | 4 | ||||
-rw-r--r-- | sys/lib/libsa/stand.h | 6 | ||||
-rw-r--r-- | sys/lib/libsa/strerror.c | 4 |
12 files changed, 44 insertions, 44 deletions
diff --git a/sys/lib/libsa/dkcksum.c b/sys/lib/libsa/dkcksum.c index f46cecb3f9c..07127cce49e 100644 --- a/sys/lib/libsa/dkcksum.c +++ b/sys/lib/libsa/dkcksum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkcksum.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: dkcksum.c,v 1.6 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: disklabel.c,v 1.3 1994/10/26 05:44:42 cgd Exp $ */ /*- @@ -40,7 +40,7 @@ * Compute checksum for disk label. */ u_int -dkcksum(struct disklabel *lp) +dkcksum(const struct disklabel *lp) { u_short *start, *end; u_short sum = 0; diff --git a/sys/lib/libsa/ether.c b/sys/lib/libsa/ether.c index 20b5e8f6e67..621fc7ce243 100644 --- a/sys/lib/libsa/ether.c +++ b/sys/lib/libsa/ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ether.c,v 1.9 2014/11/19 19:59:39 miod Exp $ */ +/* $OpenBSD: ether.c,v 1.10 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: ether.c,v 1.8 1996/10/13 02:29:00 christos Exp $ */ /* @@ -123,9 +123,9 @@ readether(struct iodesc *d, void *pkt, size_t len, time_t tleft, /* * Convert Ethernet address to printable (loggable) representation. */ -static char digits[] = "0123456789abcdef"; -char * -ether_sprintf(u_char *ap) +static const char digits[] = "0123456789abcdef"; +const char * +ether_sprintf(const u_char *ap) { int i; static char etherbuf[18]; diff --git a/sys/lib/libsa/getfile.c b/sys/lib/libsa/getfile.c index ff9bcee9073..f6131d1e4f1 100644 --- a/sys/lib/libsa/getfile.c +++ b/sys/lib/libsa/getfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getfile.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: getfile.c,v 1.6 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: getfile.c,v 1.6 1996/10/14 04:49:21 cgd Exp $ */ /*- @@ -35,10 +35,10 @@ #define CTRL(x) (x&037) -int getfile(char *, int); +int getfile(const char *, int); int -getfile(char *prompt, int mode) +getfile(const char *prompt, int mode) { int fd; char buf[100]; diff --git a/sys/lib/libsa/in_cksum.c b/sys/lib/libsa/in_cksum.c index e33781ff965..d3f2e6ac978 100644 --- a/sys/lib/libsa/in_cksum.c +++ b/sys/lib/libsa/in_cksum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_cksum.c,v 1.4 2014/07/13 15:31:20 mpi Exp $ */ +/* $OpenBSD: in_cksum.c,v 1.5 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: in_cksum.c,v 1.3 1995/04/22 13:53:48 cgd Exp $ */ /* @@ -57,10 +57,10 @@ * In particular, it should not be this one. */ int -in_cksum(void *p, int len) +in_cksum(const void *p, int len) { int sum = 0, oddbyte = 0, v = 0; - u_char *cp = p; + const u_char *cp = p; /* we assume < 2^16 bytes being summed */ while (len > 0) { @@ -70,7 +70,7 @@ in_cksum(void *p, int len) } if (((long)cp & 1) == 0) { while ((len -= 2) >= 0) { - sum += *(u_short *)cp; + sum += *(const u_short *)cp; cp += 2; } } else { diff --git a/sys/lib/libsa/net.c b/sys/lib/libsa/net.c index f3d19c7b901..068a28a9768 100644 --- a/sys/lib/libsa/net.c +++ b/sys/lib/libsa/net.c @@ -1,4 +1,4 @@ -/* $OpenBSD: net.c,v 1.16 2014/11/19 20:01:33 miod Exp $ */ +/* $OpenBSD: net.c,v 1.17 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: net.c,v 1.14 1996/10/13 02:29:02 christos Exp $ */ /* @@ -117,7 +117,7 @@ sendrecv(struct iodesc *d, ssize_t (*sproc)(struct iodesc *, void *, size_t), * Return values are in network order. */ u_int32_t -inet_addr(char *cp) +inet_addr(const char *cp) { u_long val; int n; @@ -193,14 +193,14 @@ inet_addr(char *cp) return (htonl(INADDR_NONE)); } -char * +const char * inet_ntoa(struct in_addr ia) { return (intoa(ia.s_addr)); } /* Similar to inet_ntoa() */ -char * +const char * intoa(u_int32_t addr) { char *cp; @@ -230,8 +230,8 @@ intoa(u_int32_t addr) return (cp+1); } -static char * -number(char *s, int *n) +static const char * +number(const char *s, int *n) { for (*n = 0; isdigit(*s); s++) *n = (*n * 10) + *s - '0'; @@ -239,7 +239,7 @@ number(char *s, int *n) } u_int32_t -ip_convertaddr(char *p) +ip_convertaddr(const char *p) { #define IP_ANYADDR 0 u_int32_t addr = 0, n; diff --git a/sys/lib/libsa/net.h b/sys/lib/libsa/net.h index c93d7ecb1a9..48e21dadf17 100644 --- a/sys/lib/libsa/net.h +++ b/sys/lib/libsa/net.h @@ -1,4 +1,4 @@ -/* $OpenBSD: net.h,v 1.9 2014/07/13 15:31:20 mpi Exp $ */ +/* $OpenBSD: net.h,v 1.10 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: net.h,v 1.10 1995/10/20 00:46:30 cgd Exp $ */ /* @@ -98,7 +98,7 @@ extern struct iodesc sockets[SOPEN_MAX]; u_char *arpwhohas(struct iodesc *, struct in_addr); void arp_reply(struct iodesc *, void *); int rarp_getipaddress(int); -u_int32_t ip_convertaddr(char *); +u_int32_t ip_convertaddr(const char *); /* Link functions: */ ssize_t sendether(struct iodesc *d, void *pkt, size_t len, @@ -114,11 +114,11 @@ ssize_t sendrecv(struct iodesc *, void *, size_t); /* Utilities: */ -char *ether_sprintf(u_char *); -int in_cksum(void *, int); -char *inet_ntoa(struct in_addr); -char *intoa(u_int32_t); /* similar to inet_ntoa */ -u_int32_t inet_addr(char *); +const char *ether_sprintf(const u_char *); +int in_cksum(const void *, int); +const char *inet_ntoa(struct in_addr); +const char *intoa(u_int32_t); /* similar to inet_ntoa */ +u_int32_t inet_addr(const char *); /* Machine-dependent functions: */ time_t getsecs(void); diff --git a/sys/lib/libsa/nfs.c b/sys/lib/libsa/nfs.c index 08b059d34ab..e80a35be669 100644 --- a/sys/lib/libsa/nfs.c +++ b/sys/lib/libsa/nfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs.c,v 1.11 2014/07/13 15:31:20 mpi Exp $ */ +/* $OpenBSD: nfs.c,v 1.12 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: nfs.c,v 1.19 1996/10/13 02:29:04 christos Exp $ */ /*- @@ -102,7 +102,7 @@ struct nfs_iodesc nfs_root_node; * On error, return non-zero and set errno. */ static int -nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp) +nfs_getrootfh(struct iodesc *d, const char *path, u_char *fhp) { int len; struct args { @@ -326,7 +326,7 @@ nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len) * On error, return non-zero and set errno. */ int -nfs_mount(int sock, struct in_addr ip, char *path) +nfs_mount(int sock, struct in_addr ip, const char *path) { struct iodesc *desc; struct nfsv2_fattrs *fa; @@ -583,8 +583,9 @@ nfs_seek(struct open_file *f, off_t offset, int where) } /* NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 */ -int nfs_stat_types[8] = { - 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, 0 }; +const int nfs_stat_types[8] = { + 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, 0 +}; int nfs_stat(struct open_file *f, struct stat *sb) diff --git a/sys/lib/libsa/nfs.h b/sys/lib/libsa/nfs.h index b020a75e1b0..bca87843dcc 100644 --- a/sys/lib/libsa/nfs.h +++ b/sys/lib/libsa/nfs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs.h,v 1.7 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: nfs.h,v 1.8 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: nfs.h,v 1.5 1996/07/10 18:32:33 cgd Exp $ */ /*- @@ -38,5 +38,5 @@ int nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid); off_t nfs_seek(struct open_file *f, off_t offset, int where); int nfs_stat(struct open_file *f, struct stat *sb); -int nfs_mount(int, struct in_addr, char *); +int nfs_mount(int, struct in_addr, const char *); int nfs_readdir(struct open_file *f, char *name); diff --git a/sys/lib/libsa/readdir.c b/sys/lib/libsa/readdir.c index fe925047fc7..76ff973950e 100644 --- a/sys/lib/libsa/readdir.c +++ b/sys/lib/libsa/readdir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readdir.c,v 1.8 2006/10/11 20:56:59 deraadt Exp $ */ +/* $OpenBSD: readdir.c,v 1.9 2014/11/19 20:28:56 miod Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -36,9 +36,8 @@ #undef _KERNEL #include "stand.h" - int -opendir(char *name) +opendir(const char *name) { struct stat sb; int fd; diff --git a/sys/lib/libsa/saerrno.h b/sys/lib/libsa/saerrno.h index 486334b98a8..f1f7b79e483 100644 --- a/sys/lib/libsa/saerrno.h +++ b/sys/lib/libsa/saerrno.h @@ -1,4 +1,4 @@ -/* $OpenBSD: saerrno.h,v 1.8 2014/11/19 19:59:25 miod Exp $ */ +/* $OpenBSD: saerrno.h,v 1.9 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: saerrno.h,v 1.6 1995/09/18 21:19:45 pk Exp $ */ /* @@ -48,4 +48,4 @@ extern int errno; #define EHER (ELAST+9) /* hard error */ #define ESALAST (ELAST+9) -char *strerror(int err); +const char *strerror(int err); diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h index 40273a5ed3f..d1e34b1b843 100644 --- a/sys/lib/libsa/stand.h +++ b/sys/lib/libsa/stand.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stand.h,v 1.58 2014/07/13 09:26:08 jasper Exp $ */ +/* $OpenBSD: stand.h,v 1.59 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: stand.h,v 1.18 1996/11/30 04:35:51 gwr Exp $ */ /*- @@ -128,7 +128,7 @@ void *alloca(size_t); void free(void *, u_int); struct disklabel; char *getdisklabel(const char *, struct disklabel *); -u_int dkcksum(struct disklabel *); +u_int dkcksum(const struct disklabel *); #define BOOTRANDOM "/etc/random.seed" #define BOOTRANDOM_MAX 512 @@ -163,7 +163,7 @@ ssize_t read(int, void *, size_t); ssize_t write(int, void *, size_t); int stat(const char *path, struct stat *sb); int fstat(int fd, struct stat *sb); -int opendir(char *); +int opendir(const char *); int readdir(int, char *); void closedir(int); int nodev(void); diff --git a/sys/lib/libsa/strerror.c b/sys/lib/libsa/strerror.c index 897de08b694..f48c62e8911 100644 --- a/sys/lib/libsa/strerror.c +++ b/sys/lib/libsa/strerror.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strerror.c,v 1.9 2011/09/20 22:26:05 miod Exp $ */ +/* $OpenBSD: strerror.c,v 1.10 2014/11/19 20:28:56 miod Exp $ */ /* $NetBSD: strerror.c,v 1.11 1996/10/13 02:29:08 christos Exp $ */ /*- @@ -34,7 +34,7 @@ #include "saerrno.h" #include "stand.h" -char * +const char * strerror(int err) { static char ebuf[64]; |