From a17bf58c08edcda0cb09f20e2e9f9a41105085e0 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sun, 31 Oct 2010 00:52:06 +0100 Subject: [PATCH] Replace bits of libutil with libroken Replace all of the bits of libutil that were originally culled from libroken with libroken originals. Change-Id: I361d7a8d134a361caa2da16963408c74c55a1d4e Reviewed-on: http://gerrit.openafs.org/3211 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- Makefile.in | 6 ++-- src/afs/UKERNEL/sysincludes.h | 1 + src/afsd/Makefile.in | 2 +- src/afsd/afsd_kernel.c | 2 ++ src/budb/struct_ops.c | 1 + src/libafsauthent/Makefile.in | 8 ----- src/libafsrpc/Makefile.in | 10 +----- src/libuafs/Makefile.common.in | 1 - src/shlibafsauthent/Makefile.in | 14 +++----- src/shlibafsrpc/Makefile.in | 10 +----- src/tsalvaged/salvsync-debug.c | 4 ++- src/tubik/Makefile.in | 11 +----- src/tviced/serialize_state.c | 2 +- src/tviced/state_analyzer.c | 3 +- src/uss/Makefile.in | 5 ++- src/util/Makefile.in | 4 +-- src/util/NTMakefile | 6 ---- src/util/afsutil.h | 8 ----- src/util/afsutil_prototypes.h | 17 ---------- src/util/daemon.c | 56 ------------------------------ src/util/snprintf.c | 39 --------------------- src/util/strlcat.c | 60 --------------------------------- src/util/strlcpy.c | 54 ----------------------------- src/util/strnlen.c | 33 ------------------ src/util/volparse.c | 2 ++ src/venus/Makefile.in | 4 +-- src/venus/fs.c | 1 + src/venus/up.c | 3 +- src/vol/daemon_com.c | 2 +- src/vol/fssync-debug.c | 3 +- src/vol/namei_ops.c | 2 +- src/vol/salvaged.c | 1 + src/vol/salvsync-client.c | 1 + src/vol/volume.c | 2 +- 34 files changed, 37 insertions(+), 341 deletions(-) delete mode 100644 src/util/daemon.c delete mode 100644 src/util/strlcat.c delete mode 100644 src/util/strlcpy.c delete mode 100644 src/util/strnlen.c diff --git a/Makefile.in b/Makefile.in index 7722436e4d..20e83240e8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -154,7 +154,7 @@ util: $(DIR_roken) procmgmt des lwp_depinstall rx_depinstall audit: util rx rxkad fsint +${COMPILE_PART1} audit ${COMPILE_PART2} #TODO -comerr: util +comerr: util $(DIR_roken) +${COMPILE_PART1} comerr ${COMPILE_PART2} cmd: comerr @@ -213,7 +213,7 @@ sys: cmd comerr afs des rx rxstat fsint auth sys_depinstall rxkad: cmd comerr des rx rxkad_depinstall +${COMPILE_PART1} rxkad ${COMPILE_PART2} -auth: cmd comerr comerr des lwp rx rxkad audit sys_depinstall auth_depinstall +auth: cmd comerr des lwp rx rxkad audit sys_depinstall auth_depinstall +${COMPILE_PART1} auth ${COMPILE_PART2} ubik: cmd comerr auth ubik_depinstall sys @@ -267,7 +267,7 @@ sgiefs: echo No efs stuff for ${SYS_NAME};; \ esac -vol: cmd comerr dir afs sgiefs +vol: cmd comerr dir afs sgiefs $(DIR_roken) +${COMPILE_PART1} vol ${COMPILE_PART2} tsalvaged: vol libafsrpc libafsauthent cmd util diff --git a/src/afs/UKERNEL/sysincludes.h b/src/afs/UKERNEL/sysincludes.h index 864c67438a..6375c02841 100644 --- a/src/afs/UKERNEL/sysincludes.h +++ b/src/afs/UKERNEL/sysincludes.h @@ -235,6 +235,7 @@ typedef unsigned int fsblkcnt_t; #define ifaddr usr_ifaddr #define ifnet usr_ifnet #define in_ifaddr usr_in_ifaddr +#undef socket #define socket usr_socket #define crget usr_crget #define crcopy usr_crcopy diff --git a/src/afsd/Makefile.in b/src/afsd/Makefile.in index f0b244d2d0..1d22402848 100644 --- a/src/afsd/Makefile.in +++ b/src/afsd/Makefile.in @@ -32,7 +32,7 @@ FUSE_LIBS=@FUSE_LIBS@ LDFLAGS_afsd = $(AFSD_LDFLAGS) afsd: afsd.o afsd_kernel.o $(AFSLIBS) $(AFSD_LIBS) ${AFS_LDRULE} afsd.o afsd_kernel.o $(NON_SHARED) \ - $(AFSLIBS) $(LIB_roken) ${XLIBS} ${AFSD_LIBS} + $(AFSLIBS) ${AFSD_LIBS} $(LIB_roken) $(XLIBS) LDFLAGS_afsd.fuse = $(AFSD_LDFLAGS) afsd.fuse: afsd_fuse.o $(UAFSLIBS) $(AFSD_LIBS) diff --git a/src/afsd/afsd_kernel.c b/src/afsd/afsd_kernel.c index 5f769e6bab..76e28b503a 100644 --- a/src/afsd/afsd_kernel.c +++ b/src/afsd/afsd_kernel.c @@ -10,6 +10,8 @@ #include #include +#include + #define VFS 1 #include diff --git a/src/budb/struct_ops.c b/src/budb/struct_ops.c index 3ec27ce37d..1d67f78634 100644 --- a/src/budb/struct_ops.c +++ b/src/budb/struct_ops.c @@ -20,6 +20,7 @@ #include #endif #include + #include #include #include diff --git a/src/libafsauthent/Makefile.in b/src/libafsauthent/Makefile.in index 9acec36ddc..7a048a9478 100644 --- a/src/libafsauthent/Makefile.in +++ b/src/libafsauthent/Makefile.in @@ -64,8 +64,6 @@ UTILOBJS = \ dirpath.o \ serverLog.o \ snprintf.o \ - strlcat.o \ - strlcpy.o \ fileutil.o RXKADOBJS = \ @@ -206,12 +204,6 @@ serverLog.o: ${UTIL}/serverLog.c snprintf.o: ${UTIL}/snprintf.c ${AFS_CCRULE} ${UTIL}/snprintf.c -strlcat.o: ${UTIL}/strlcat.c - ${AFS_CCRULE} ${UTIL}/strlcat.c - -strlcpy.o: ${UTIL}/strlcpy.c - ${AFS_CCRULE} ${UTIL}/strlcpy.c - fileutil.o: ${UTIL}/fileutil.c ${AFS_CCRULE} ${UTIL}/fileutil.c diff --git a/src/libafsrpc/Makefile.in b/src/libafsrpc/Makefile.in index 637a12c390..1e1a1088d1 100644 --- a/src/libafsrpc/Makefile.in +++ b/src/libafsrpc/Makefile.in @@ -39,9 +39,7 @@ SYSOBJS =\ UTILOBJS =\ assert.o \ casestrcpy.o \ - base64.o \ - strlcat.o \ - strlcpy.o + base64.o COMERROBJS =\ error_msg.o \ @@ -374,12 +372,6 @@ assert.o: ${UTIL}/assert.c base64.o: ${UTIL}/base64.c $(AFS_CCRULE) $(UTIL)/base64.c -strlcat.o: ${UTIL}/strlcat.c - $(AFS_CCRULE) $(UTIL)/strlcat.c - -strlcpy.o: ${UTIL}/strlcpy.c - $(AFS_CCRULE) $(UTIL)/strlcpy.c - fasttime.o: ${LWP}/fasttime.c $(AFS_CCRULE) $(LWP)/fasttime.c diff --git a/src/libuafs/Makefile.common.in b/src/libuafs/Makefile.common.in index 10132458bd..3e48f58745 100644 --- a/src/libuafs/Makefile.common.in +++ b/src/libuafs/Makefile.common.in @@ -82,7 +82,6 @@ linktest: UAFS/$(LIBUAFS) ${TOP_OBJDIR}/lib/libdes.a ${TOP_LIBDIR}/libdes.a ${TOP_LIBDIR}/libafsutil.a \ $(LIB_roken) $(TEST_LIBS) $(XLIBS) - CRULE1= $(CC) $(COMMON_INCLUDE) $(OPTF) -DKERNEL $(LIBJUAFS_FLAGS) $(CFLAGS) -c $? CRULE2= $(CC) $(COMMON_INCLUDE) $(OPTF) $(WEBOPTS) -DKERNEL $(LIBJUAFS_FLAGS) $(CFLAGS) -c $? diff --git a/src/shlibafsauthent/Makefile.in b/src/shlibafsauthent/Makefile.in index 4d4e1fff22..3edd7c8ca2 100644 --- a/src/shlibafsauthent/Makefile.in +++ b/src/shlibafsauthent/Makefile.in @@ -71,8 +71,6 @@ UTILOBJS = \ dirpath.o \ serverLog.o \ snprintf.o \ - strlcat.o \ - strlcpy.o \ fileutil.o RXKADOBJS = \ @@ -135,7 +133,10 @@ dest: ${LIBAFSAUTHENT} libafsauthent_pic.a ${LIBAFSAUTHENT}: ${LIBOBJS} libafsauthent.map ../config/shlib-build -d $(srcdir) -l libafsauthent \ -M ${LIBAFSAUTHENTMAJOR} -m ${LIBAFSAUTHENTMINOR} -- \ - -L${TOP_LIBDIR} -lafsrpc ${LIB_crypt} ${LIBOBJS} ${LIB_AFSDB} ${MT_LIBS} + -L${TOP_LIBDIR} $(LDFLAGS_roken) \ + $(LIBOBJS) \ + -lafsrpc $(LIB_roken) $(LIB_crypt) $(LIB_AFSDB) \ + ${MT_LIBS} libafsauthent_pic.a: ${LIBOBJS} $(RM) -f $@ @@ -226,7 +227,6 @@ ubik_int.cs.o: ../ubik/ubik_int.cs.c ubik_int.xdr.o: ../ubik/ubik_int.xdr.c ${AFS_CCRULE} ../ubik/ubik_int.xdr.c - get_krbrlm.o: ${UTIL}/get_krbrlm.c ${AFS_CCRULE} ${UTIL}/get_krbrlm.c @@ -239,12 +239,6 @@ serverLog.o: ${UTIL}/serverLog.c snprintf.o: ${UTIL}/snprintf.c ${AFS_CCRULE} ${UTIL}/snprintf.c -strlcat.o: ${UTIL}/strlcat.c - ${AFS_CCRULE} ${UTIL}/strlcat.c - -strlcpy.o: ${UTIL}/strlcpy.c - ${AFS_CCRULE} ${UTIL}/strlcpy.c - fileutil.o: ${UTIL}/fileutil.c ${AFS_CCRULE} ${UTIL}/fileutil.c diff --git a/src/shlibafsrpc/Makefile.in b/src/shlibafsrpc/Makefile.in index 925183137b..5f67a1d01e 100644 --- a/src/shlibafsrpc/Makefile.in +++ b/src/shlibafsrpc/Makefile.in @@ -44,8 +44,6 @@ UTILOBJS =\ assert.o \ casestrcpy.o \ base64.o \ - strlcat.o \ - strlcpy.o COMERROBJS =\ error_msg.o \ @@ -166,7 +164,7 @@ dest: ${LIBAFSRPC} libafsrpc_pic.a ${LIBAFSRPC}: ${LIBOBJS} libafsrpc.map ../config/shlib-build -d $(srcdir) -l libafsrpc \ -M ${LIBAFSRPCMAJOR} -m ${LIBAFSRPCMINOR} -- \ - ${LIBOBJS} ${MT_LIBS} + $(LDFLAGS_roken) ${LIBOBJS} ${MT_LIBS} $(LIB_roken) libafsrpc_pic.a: ${LIBOBJS} $(RM) -f $@ @@ -390,12 +388,6 @@ assert.o: ${UTIL}/assert.c base64.o: ${UTIL}/base64.c $(AFS_CCRULE) $(UTIL)/base64.c -strlcat.o: ${UTIL}/strlcat.c - $(AFS_CCRULE) $(UTIL)/strlcat.c - -strlcpy.o: ${UTIL}/strlcpy.c - $(AFS_CCRULE) $(UTIL)/strlcpy.c - fasttime.o: ${LWP}/fasttime.c $(AFS_CCRULE) $(LWP)/fasttime.c diff --git a/src/tsalvaged/salvsync-debug.c b/src/tsalvaged/salvsync-debug.c index b7bea96fd1..b1c62eef83 100644 --- a/src/tsalvaged/salvsync-debug.c +++ b/src/tsalvaged/salvsync-debug.c @@ -18,7 +18,6 @@ #include #include - #include #include #include @@ -36,6 +35,9 @@ #include #endif /* ITIMER_REAL */ #endif + +#include + #include #include #include diff --git a/src/tubik/Makefile.in b/src/tubik/Makefile.in index 597eddba9d..d5f6996d20 100644 --- a/src/tubik/Makefile.in +++ b/src/tubik/Makefile.in @@ -31,7 +31,7 @@ RXOBJS = rx_pthread.o UTILOBJS=assert.o uuid.o serverLog.o fileutil.o netutils.o dirpath.o \ volparse.o flipbase64.o softsig.o hostparse.o snprintf.o \ - pthread_glock.o strlcat.o strlcpy.o strnlen.o + pthread_glock.o LIBS=${RXOBJS} ${UTILOBJS} ${TOP_LIBDIR}/libafsrpc.a ${TOP_LIBDIR}/liblwp.a \ ${TOP_LIBDIR}/libcom_err.a ${TOP_LIBDIR}/libcmd.a \ @@ -73,15 +73,6 @@ fileutil.o: ${UTIL}/fileutil.c volparse.o: ${UTIL}/volparse.c $(AFS_CCRULE) $(UTIL)/volparse.c -strlcat.o: ${UTIL}/strlcat.c - $(AFS_CCRULE) $(UTIL)/strlcat.c - -strlcpy.o: ${UTIL}/strlcpy.c - $(AFS_CCRULE) $(UTIL)/strlcpy.c - -strnlen.o: ${UTIL}/strnlen.c - $(AFS_CCRULE) $(UTIL)/strnlen.c - flipbase64.o: ${UTIL}/flipbase64.c $(AFS_CCRULE) $(UTIL)/flipbase64.c diff --git a/src/tviced/serialize_state.c b/src/tviced/serialize_state.c index bc10746e5b..6b2dbff2c0 100644 --- a/src/tviced/serialize_state.c +++ b/src/tviced/serialize_state.c @@ -28,10 +28,10 @@ #include #include #endif -#include #include #include +#include #include #include diff --git a/src/tviced/state_analyzer.c b/src/tviced/state_analyzer.c index 5e8039494c..05dcb31604 100644 --- a/src/tviced/state_analyzer.c +++ b/src/tviced/state_analyzer.c @@ -17,7 +17,6 @@ #include #include - #include #include #include @@ -26,6 +25,8 @@ #include #include +#include + #include #include #include diff --git a/src/uss/Makefile.in b/src/uss/Makefile.in index caf563084e..44ffaa4c2c 100644 --- a/src/uss/Makefile.in +++ b/src/uss/Makefile.in @@ -33,8 +33,7 @@ LIBS=${TOP_LIBDIR}/libvolser.a \ ${TOP_LIBDIR}/liblwp.a \ ${TOP_LIBDIR}/libcmd.a \ ${TOP_LIBDIR}/libcom_err.a\ - ${TOP_LIBDIR}/util.a \ - ${XLIBS} + ${TOP_LIBDIR}/util.a OBJS = uss_procs.o \ uss_common.o \ @@ -47,7 +46,7 @@ OBJS = uss_procs.o \ y.tab.o uss: uss.o ${OBJS} - $(AFS_LDRULE) uss.o ${OBJS} ${LIBS} $(LIB_roken) + $(AFS_LDRULE) uss.o ${OBJS} ${LIBS} $(LIB_roken) $(XLIBS) uss.o: uss.c AFS_component_version_number.c diff --git a/src/util/Makefile.in b/src/util/Makefile.in index 8f2da1f7ca..8588eab42e 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -20,8 +20,8 @@ objects = assert.o base64.o casestrcpy.o config_file.o ktime.o volparse.o \ hostparse.o exec.o \ hputil.o kreltime.o isathing.o get_krbrlm.o uuid.o serverLog.o \ dirpath.o fileutil.o netutils.o flipbase64.o fstab.o \ - afs_atomlist.o afs_lhash.o snprintf.o strlcat.o strlcpy.o strnlen.o \ - pthread_glock.o daemon.o ${REGEX_OBJ} + afs_atomlist.o afs_lhash.o snprintf.o pthread_glock.o \ + ${REGEX_OBJ} includes = \ ${TOP_INCDIR}/afs/dirpath.h \ diff --git a/src/util/NTMakefile b/src/util/NTMakefile index 2bd40ae0fa..9855c61508 100644 --- a/src/util/NTMakefile +++ b/src/util/NTMakefile @@ -57,14 +57,11 @@ LIBOBJS = \ $(OUT)\readdir_nt.obj \ $(OUT)\serverLog.obj \ $(OUT)\snprintf.obj \ - $(OUT)\strlcat.obj \ $(OUT)\uuid.obj \ $(OUT)\volparse.obj \ $(OUT)\winsock_nt.obj \ $(OUT)\errmap_nt.obj \ $(OUT)\dirpath.obj \ - $(OUT)\strnlen.obj \ - $(OUT)\strlcpy.obj \ $(OUT)\fileutil.obj \ $(OUT)\secutil_nt.obj @@ -83,14 +80,11 @@ MT_LIBOBJS = \ $(OUT)\readdir_nt.obj \ $(OUT)\serverLog_mt.obj \ $(OUT)\snprintf.obj \ - $(OUT)\strlcat.obj \ $(OUT)\uuid.obj \ $(OUT)\volparse.obj \ $(OUT)\winsock_nt.obj \ $(OUT)\errmap_nt.obj \ $(OUT)\dirpath_mt.obj \ - $(OUT)\strnlen.obj \ - $(OUT)\strlcpy.obj \ $(OUT)\fileutil.obj \ $(OUT)\secutil_nt.obj diff --git a/src/util/afsutil.h b/src/util/afsutil.h index e3fd362db3..b56015e89d 100644 --- a/src/util/afsutil.h +++ b/src/util/afsutil.h @@ -151,14 +151,6 @@ extern int re_exec(const char *p1); /* b64_string_t is 8 bytes, in stds.h */ typedef char lb64_string_t[12]; -#ifndef HAVE_STRLCAT -extern size_t strlcat(char *dst, const char *src, size_t siz); -#endif - -#ifndef HAVE_STRLCPY -extern size_t strlcpy(char *dst, const char *src, size_t siz); -#endif - #include #include "afsutil_prototypes.h" diff --git a/src/util/afsutil_prototypes.h b/src/util/afsutil_prototypes.h index d4da7cc82a..7554c79a65 100644 --- a/src/util/afsutil_prototypes.h +++ b/src/util/afsutil_prototypes.h @@ -44,11 +44,6 @@ extern const char* fs_config_get_string(const afs_config_section *, ...); extern int afs_config_get_bool(const afs_config_section *, ...); extern int afs_config_get_int(const afs_config_section *c, ...); -/* daemon.c */ -#ifndef HAVE_DAEMON -int daemon(int nochdir, int noclose); -#endif - /* dirpath.c */ extern unsigned int initAFSDirPath(void); extern const char *getDirPath(afsdir_id_t string_id); @@ -176,18 +171,6 @@ extern void LogCommandLine(int argc, char **argv, const char *progname, /* snprintf.c */ -/* strl */ -#ifndef HAVE_STRLCPY -extern size_t strlcpy(char *dst, const char *src, size_t siz); -#endif -#ifndef HAVE_STRLCAT -extern size_t strlcat(char *dst, const char *src, size_t siz); -#endif - -/* strn */ -extern size_t afs_strnlen(char * buf, size_t len); - - /* sys.c */ diff --git a/src/util/daemon.c b/src/util/daemon.c deleted file mode 100644 index e08845cf88..0000000000 --- a/src/util/daemon.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include - -#ifndef HAVE_DAEMON - -#include -#include -#include - -#include - -int daemon(int nochdir, int noclose) -{ - int err = -1; - pid_t pid; - - pid = fork(); - if (pid == -1) { - goto out; - } else if (pid) { - exit(0); - } - - err = setsid(); - if (err == -1) { - goto out; - } - - if (!nochdir) { - err = chdir("/"); - if (err == -1) { - goto out; - } - } - - err = -1; - if (!noclose) { - if (!freopen("/dev/null", "r", stdin)) { - goto out; - } - - if (!freopen("/dev/null", "w", stdout)) { - goto out; - } - - if (!freopen("/dev/null", "w", stderr)) { - goto out; - } - } - - err = 0; - -out: - return(err); -} -#endif diff --git a/src/util/snprintf.c b/src/util/snprintf.c index d0c61f22cc..69507e9ee8 100644 --- a/src/util/snprintf.c +++ b/src/util/snprintf.c @@ -913,23 +913,6 @@ afs_asnprintf (char **ret, size_t max_sz, const char *format, ...) return val; } -#if defined(AFS_OSF20_ENV) && !defined(AFS_DUX50_ENV) || defined(AFS_AIX32_ENV) || (defined(AFS_SUN55_ENV) && !defined(AFS_SUN56_ENV)) || !defined(HAVE_VSNPRINTF) || defined(TEST_SNPRINTF) - -#if defined(AFS_AIX51_ENV) || defined(AFS_NT40_ENV) -int -vsnprintf(char *p, size_t avail, const char *fmt, va_list ap) -#else -void -vsnprintf(char *p, unsigned int avail, char *fmt, va_list ap) -#endif -{ - int result; - result = afs_vsnprintf(p, avail, fmt, ap); -#if defined(AFS_AIX51_ENV) || defined(AFS_NT40_ENV) - return result; -#endif -} -#endif /* AFS_OSF20_ENV || AFS_AIX32_ENV */ #ifndef AFS_NT40_ENV #ifndef HAVE_VSYSLOG @@ -941,26 +924,4 @@ vsyslog(int priority, const char *format, va_list args) syslog(priority, "%s", buf); } #endif - -#if defined(AFS_OSF20_ENV) && !defined(AFS_DUX50_ENV) || defined(AFS_AIX32_ENV) || (defined(AFS_SUN55_ENV) && !defined(AFS_SUN56_ENV)) || !defined(HAVE_SNPRINTF) - -#ifdef AFS_AIX51_ENV -int -snprintf(char *p, size_t avail, const char *fmt, ...) -#else -void -snprintf(char *p, unsigned int avail, char *fmt, ...) #endif -{ - va_list ap; - int result; - - va_start(ap, fmt); - result = afs_vsnprintf(p, avail, fmt, ap); - va_end(ap); -#ifdef AFS_AIX51_ENV - return result; -#endif -} -#endif /* AFS_OSF20_ENV || AFS_AIX32_ENV */ -#endif /* AFS_NT40_ENV */ diff --git a/src/util/strlcat.c b/src/util/strlcat.c deleted file mode 100644 index 877c967d21..0000000000 --- a/src/util/strlcat.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - - -#ifndef HAVE_STRLCAT - -#include -#include - -/* - * Appends src to string dst of size siz (unlike strncat, siz is the - * full size of dst, not space left). At most siz-1 characters - * will be copied. Always NUL terminates (unless siz <= strlen(dst)). - * Returns strlen(src) + MIN(siz, strlen(initial dst)). - * If retval >= siz, truncation occurred. - */ -size_t -strlcat(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = siz - dlen; - - if (n == 0) - return (dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return (dlen + (s - src)); /* count does not include NUL */ -} -#endif diff --git a/src/util/strlcpy.c b/src/util/strlcpy.c deleted file mode 100644 index ebd5a1200e..0000000000 --- a/src/util/strlcpy.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - - -#ifndef HAVE_STRLCPY - -#include - -/* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -size_t -strlcpy(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++); - } - - return (s - src - 1); /* count does not include NUL */ -} -#endif diff --git a/src/util/strnlen.c b/src/util/strnlen.c deleted file mode 100644 index af600ff4d3..0000000000 --- a/src/util/strnlen.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2006, Sine Nomine Associates and others. - * All Rights Reserved. - * - * This software has been released under the terms of the IBM Public - * License. For details, see the LICENSE file in the top-level source - * directory or online at http://www.openafs.org/dl/license10.html - */ - -/* strnlen.c - fixed length string length */ - -#include -#include - - -#include -#include -#include - - -size_t -afs_strnlen(char * buf, size_t len) -{ - size_t i; - - for (i = 0; i < len; i++) { - if (buf[i] == '\0') - break; - } - - return i; -} - diff --git a/src/util/volparse.c b/src/util/volparse.c index db022c9146..1e161f7056 100644 --- a/src/util/volparse.c +++ b/src/util/volparse.c @@ -16,6 +16,8 @@ #include #endif +#include + #include "afsutil.h" /* maximum number of partitions - must match vol/voldefs.h */ diff --git a/src/venus/Makefile.in b/src/venus/Makefile.in index f85121b8c7..d1acc8e0a9 100644 --- a/src/venus/Makefile.in +++ b/src/venus/Makefile.in @@ -113,7 +113,7 @@ fstrace: fstrace.o * ) \ $(AFS_LDRULE) fstrace.o ${TOP_LIBDIR}/libsys.a \ ${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/util.a \ - ${XLIBS} ;; \ + ${XLIBS} $(LIB_roken);; \ esac cmdebug.o: cmdebug.c ${INCLS} AFS_component_version_number.c @@ -126,8 +126,6 @@ dedebug.o: dedebug.c ${INCLS} AFS_component_version_number.c dedebug: dedebug.o ${CMLIBS} $(AFS_LDRULE) dedebug.o ${CMLIBS} $(LIB_roken) ${XLIBS} - - # # Kernel info dumper - these are done with submakes so that # the build process does not attempt to rebuild them every time it runs. diff --git a/src/venus/fs.c b/src/venus/fs.c index a8c17123ea..adf5a0b5d4 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/src/venus/up.c b/src/venus/up.c index eee1648575..f8ceb6ac5a 100644 --- a/src/venus/up.c +++ b/src/venus/up.c @@ -10,8 +10,7 @@ #include #include - -/* missing type from C language */ +#include #include #ifdef AFS_AIX32_ENV diff --git a/src/vol/daemon_com.c b/src/vol/daemon_com.c index 923306f365..afcc057490 100644 --- a/src/vol/daemon_com.c +++ b/src/vol/daemon_com.c @@ -631,7 +631,7 @@ SYNC_verifyProtocolString(char * buf, size_t len) { size_t s_len; - s_len = afs_strnlen(buf, len); + s_len = strnlen(buf, len); return (s_len == len) ? 1 : 0; } diff --git a/src/vol/fssync-debug.c b/src/vol/fssync-debug.c index d1ae92039f..7a6d576ea4 100644 --- a/src/vol/fssync-debug.c +++ b/src/vol/fssync-debug.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -938,7 +939,7 @@ VolOpQuery(struct cmd_syndesc * as, void * rock) printf("\tvop = {\n"); printf("\t\tvolume = %u\n", vop.vop.volume); - if (afs_strnlen(vop.vop.partName, sizeof(vop.vop.partName)) < + if (strnlen(vop.vop.partName, sizeof(vop.vop.partName)) < sizeof(vop.vop.partName)) { printf("\t\tpartName = '%s'\n", vop.vop.partName); } else { diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index edbf8fb9f3..e62a986208 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -12,9 +12,9 @@ #include #include +#include #ifdef AFS_NAMEI_ENV -#include #include #include #ifndef AFS_NT40_ENV diff --git a/src/vol/salvaged.c b/src/vol/salvaged.c index 0873258882..080727de0e 100644 --- a/src/vol/salvaged.c +++ b/src/vol/salvaged.c @@ -18,6 +18,7 @@ #include #include +#include #include #include diff --git a/src/vol/salvsync-client.c b/src/vol/salvsync-client.c index 84d65ed438..691d82a266 100644 --- a/src/vol/salvsync-client.c +++ b/src/vol/salvsync-client.c @@ -17,6 +17,7 @@ #include #include +#include #include #include diff --git a/src/vol/volume.c b/src/vol/volume.c index 4703e11813..c85b6852b4 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -5734,7 +5734,7 @@ static int VScheduleSalvage_r(Volume * vp) { int ret=0; - int code; + int code = 0; VolState state_save; VThreadOptions_t * thread_opts; char partName[16];