Date: Sun, 9 Sep 2001 21:40:08 +0400 From: "Sergey A. Osokin" <osa@freebsd.org.ru> To: audit@FreeBSD.org Subject: libdevstat patch - WARNS=2 Message-ID: <20010909214008.A76698@freebsd.org.ru>
next in thread | raw e-mail | index | archive | help
--GvXjxJ+pjyke8COw Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello. Please review WARNS=2 patch for libdevstat. Thanks. -- Rgdz, /"\ Sergey Osokin aka oZZ, \ / ASCII RIBBON CAMPAIGN osa@freebsd.org.ru X AGAINST HTML MAIL http://freebsd.org.ru/~osa/ / \ --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=koi8-r Content-Disposition: attachment; filename=patch-libdevstat Content-Transfer-Encoding: 8bit diff -ruN libdevstat.old/Makefile libdevstat/Makefile --- libdevstat.old/Makefile Fri Sep 7 17:23:34 2001 +++ libdevstat/Makefile Fri Sep 7 17:23:18 2001 @@ -34,4 +34,6 @@ CFLAGS+=-I${.CURDIR} +WARNS?= 2 + .include <bsd.lib.mk> diff -ruN libdevstat.old/devstat.c libdevstat/devstat.c --- libdevstat.old/devstat.c Fri Sep 7 17:23:34 2001 +++ libdevstat/devstat.c Fri Sep 7 18:24:49 2001 @@ -114,7 +114,7 @@ { DSM_SKIP, DEVSTAT_ARG_SKIP } }; -static char *namelist[] = { +static const char *namelist[] = { #define X_NUMDEVS 0 "_devstat_num_devs", #define X_GENERATION 1 @@ -131,7 +131,7 @@ */ static int compare_select(const void *arg1, const void *arg2); static int readkmem(kvm_t *kd, unsigned long addr, void *buf, size_t nbytes); -static int readkmem_nl(kvm_t *kd, char *name, void *buf, size_t nbytes); +static int readkmem_nl(kvm_t *kd, const char *name, void *buf, size_t nbytes); static char *get_devstat_kvm(kvm_t *kd); #define KREADNL(kd, var, val) \ @@ -142,7 +142,7 @@ { size_t numdevsize; int numdevs; - char *func_name = "devstat_getnumdevs"; + const char *func_name = "devstat_getnumdevs"; numdevsize = sizeof(int); @@ -160,6 +160,7 @@ } else return(numdevs); } else { + if (KREADNL(kd, X_NUMDEVS, numdevs) == -1) return(-1); else @@ -179,7 +180,7 @@ { size_t gensize; long generation; - char *func_name = "devstat_getgeneration"; + const char *func_name = "devstat_getgeneration"; gensize = sizeof(long); @@ -214,7 +215,7 @@ { size_t versize; int version; - char *func_name = "devstat_getversion"; + const char *func_name = "devstat_getversion"; versize = sizeof(int); @@ -246,7 +247,7 @@ int devstat_checkversion(kvm_t *kd) { - char *func_name = "devstat_checkversion"; + const char *func_name = "devstat_checkversion"; int buflen, res, retval = 0, version; version = devstat_getversion(kd); @@ -312,7 +313,7 @@ long oldgeneration; int retval = 0; struct devinfo *dinfo; - char *func_name = "devstat_getdevs"; + const char *func_name = "devstat_getdevs"; dinfo = stats->dinfo; @@ -899,7 +900,7 @@ * device at index i in the old array. */ else { - int found = 0; + found = 0; /* * Search through the old selection array @@ -950,17 +951,17 @@ static int compare_select(const void *arg1, const void *arg2) { - if ((((struct device_selection *)arg1)->selected) - && (((struct device_selection *)arg2)->selected == 0)) + if ((((const struct device_selection *)arg1)->selected) + && (((const struct device_selection *)arg2)->selected == 0)) return(-1); - else if ((((struct device_selection *)arg1)->selected == 0) - && (((struct device_selection *)arg2)->selected)) + else if ((((const struct device_selection *)arg1)->selected == 0) + && (((const struct device_selection *)arg2)->selected)) return(1); - else if (((struct device_selection *)arg2)->bytes < - ((struct device_selection *)arg1)->bytes) + else if (((const struct device_selection *)arg2)->bytes < + ((const struct device_selection *)arg1)->bytes) return(-1); - else if (((struct device_selection *)arg2)->bytes > - ((struct device_selection *)arg1)->bytes) + else if (((const struct device_selection *)arg2)->bytes > + ((const struct device_selection *)arg1)->bytes) return(1); else return(0); @@ -978,7 +979,7 @@ char **tempstr; int num_args; register int i, j; - char *func_name = "devstat_buildmatch"; + const char *func_name = "devstat_buildmatch"; /* We can't do much without a string to parse */ if (match_str == NULL) { @@ -1162,7 +1163,7 @@ devstat_compute_statistics(struct devstat *current, struct devstat *previous, long double etime, ...) { - char *func_name = "devstat_compute_statistics"; + const char *func_name = "devstat_compute_statistics"; u_int64_t totalbytes, totalbytesread, totalbyteswrite; u_int64_t totaltransfers, totaltransfersread, totaltransferswrite; u_int64_t totaltransfersother, totalblocks, totalblocksread; @@ -1449,7 +1450,7 @@ static int readkmem(kvm_t *kd, unsigned long addr, void *buf, size_t nbytes) { - char *func_name = "readkmem"; + const char *func_name = "readkmem"; if (kvm_read(kd, addr, buf, nbytes) == -1) { snprintf(devstat_errbuf, sizeof(devstat_errbuf), @@ -1461,10 +1462,13 @@ } static int -readkmem_nl(kvm_t *kd, char *name, void *buf, size_t nbytes) +readkmem_nl(kvm_t *kd, const char *name, void *buf, size_t nbytes) { - char *func_name = "readkmem_nl"; - struct nlist nl[2] = { { name }, { NULL } }; + const char *func_name = "readkmem_nl"; + struct nlist nl[2]; + + *((const char **)&nl[0].n_name) = name; + nl[1].n_name = NULL; if (kvm_nlist(kd, nl) == -1) { snprintf(devstat_errbuf, sizeof(devstat_errbuf), @@ -1489,7 +1493,7 @@ struct devstatlist dhead; int num_devs; char *rv = NULL; - char *func_name = "get_devstat_kvm"; + const char *func_name = "get_devstat_kvm"; if ((num_devs = getnumdevs()) <= 0) return(NULL); diff -ruN libdevstat.old/devstat.h libdevstat/devstat.h --- libdevstat.old/devstat.h Fri Sep 7 17:23:34 2001 +++ libdevstat/devstat.h Fri Sep 7 17:23:18 2001 @@ -85,7 +85,7 @@ }; struct devstat_match_table { - char *match_str; + const char * match_str; devstat_type_flags type; devstat_match_flags match_field; }; --GvXjxJ+pjyke8COw-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010909214008.A76698>