From: Thomas Veerman Date: Wed, 1 Feb 2012 11:44:26 +0000 (+0000) Subject: libpuffs: make GCC happy X-Git-Tag: v3.2.0~92 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=71634240a0338feb8f8471fa2647f1ba63625731;p=minix.git libpuffs: make GCC happy --- diff --git a/lib/libpuffs/Makefile b/lib/libpuffs/Makefile index 967ed1312..e0abd0e66 100644 --- a/lib/libpuffs/Makefile +++ b/lib/libpuffs/Makefile @@ -1,17 +1,23 @@ -# Makefile for libpuffs +# $NetBSD: Makefile,v 1.24 2010/12/06 14:50:34 pooka Exp $ +# -LIB= puffs -CC= clang -SRCS= callcontext.c creds.c null.c pnode.c puffs.c subr.c\ - table.c link.c misc.c open.c path.c path_puffs.c protect.c\ - read.c stadir.c time.c utility.c mount.c inode.c -INCS= puffs.h puffs_msgif.h -INCSDIR= /usr/include -MAN= puffs.3 puffs_cc.3 puffs_cred.3 puffs_node.3 \ - puffs_ops.3 puffs_path.3 +.include -DEFAULT_NR_BUFS= 1024 +USE_FORT?= no # data-driven bugs? -CPPFLAGS+= -D_MINIX -D_POSIX_SOURCE -D_POSIX_C_SOURCE -D_NETBSD_SOURCE -DDEFAULT_NR_BUFS=${DEFAULT_NR_BUFS} +WARNS= 4 + +LIB= puffs + +SRCS= puffs.c callcontext.c creds.c \ + null.c pnode.c \ + subr.c \ + inode.c link.c misc.c mount.c open.c path.c path_puffs.c \ + protect.c read.c stadir.c time.c utility.c table.c +MAN= puffs.3 puffs_cc.3 puffs_cred.3 \ + puffs_node.3 puffs_ops.3 puffs_path.3 +INCS= puffs.h puffs_msgif.h +INCSDIR= /usr/include +LINTFLAGS+=-S -w .include diff --git a/lib/libpuffs/fs.h b/lib/libpuffs/fs.h index 691b0dd2e..44c70a9e3 100644 --- a/lib/libpuffs/fs.h +++ b/lib/libpuffs/fs.h @@ -14,6 +14,7 @@ /* The following are so basic, all the *.c files get them automatically. */ #include /* MUST be first */ #include /* MUST be second */ +#include #include #include #include diff --git a/lib/libpuffs/link.c b/lib/libpuffs/link.c index e85222450..8129df7c9 100644 --- a/lib/libpuffs/link.c +++ b/lib/libpuffs/link.c @@ -79,7 +79,7 @@ PUBLIC int fs_link() time_t cur_time; struct puffs_kcn pkcnp; PUFFS_MAKECRED(pcr, &global_kcred); - struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *)pcr, {0}}; + struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}}; if (global_pu->pu_ops.puffs_node_link == NULL) return(OK); @@ -157,7 +157,7 @@ PUBLIC int fs_rdlink() register int r; /* return value */ size_t copylen; struct puffs_node *pn; - char user_path[PATH_MAX]; + char path[PATH_MAX]; PUFFS_MAKECRED(pcr, &global_kcred); copylen = fs_m_in.REQ_MEM_SIZE < UMAX_FILE_POS ? @@ -174,7 +174,7 @@ PUBLIC int fs_rdlink() if (global_pu->pu_ops.puffs_node_readlink == NULL) return(EINVAL); - r = global_pu->pu_ops.puffs_node_readlink(global_pu, pn, pcr, user_path, + r = global_pu->pu_ops.puffs_node_readlink(global_pu, pn, pcr, path, ©len); if (r != OK) { if (r > 0) r = -r; @@ -182,7 +182,7 @@ PUBLIC int fs_rdlink() } r = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT, - (vir_bytes) 0, (vir_bytes) user_path, (size_t) copylen, D); + (vir_bytes) 0, (vir_bytes) path, (size_t) copylen, D); if (r == OK) fs_m_out.RES_NBYTES = copylen; @@ -190,9 +190,6 @@ PUBLIC int fs_rdlink() } -FORWARD _PROTOTYPE( void release_node, (struct puffs_usermount *pu, - struct puffs_node *pn )); - /*===========================================================================* * fs_rename * *===========================================================================*/ @@ -203,10 +200,10 @@ PUBLIC int fs_rename() struct puffs_node *new_dirp, *new_ip; /* ptrs to new dir, file pnodes */ struct puffs_kcn pkcnp_src; PUFFS_MAKECRED(pcr_src, &global_kcred); - struct puffs_cn pcn_src = {&pkcnp_src, (struct puffs_cred *) pcr_src, {0}}; + struct puffs_cn pcn_src = {&pkcnp_src, (struct puffs_cred *) __UNCONST(pcr_src), {0,0,0}}; struct puffs_kcn pkcnp_dest; PUFFS_MAKECRED(pcr_dest, &global_kcred); - struct puffs_cn pcn_targ = {&pkcnp_dest, (struct puffs_cred *) pcr_dest, {0}}; + struct puffs_cn pcn_targ = {&pkcnp_dest, (struct puffs_cred *) __UNCONST(pcr_dest), {0,0,0}}; int r = OK; /* error flag; initially no error */ int odir, ndir; /* TRUE iff {old|new} file is dir */ int same_pdir; /* TRUE iff parent dirs are the same */ @@ -406,7 +403,7 @@ PUBLIC int fs_unlink() struct puffs_node *pn, *pn_dir; time_t cur_time; struct puffs_kcn pkcnp; - struct puffs_cn pcn = {&pkcnp, 0, {0}}; + struct puffs_cn pcn = {&pkcnp, 0, {0,0,0}}; PUFFS_KCREDTOCRED(pcn.pcn_cred, &global_kcred); int len; diff --git a/lib/libpuffs/null.c b/lib/libpuffs/null.c index d1aad767c..5e1924062 100644 --- a/lib/libpuffs/null.c +++ b/lib/libpuffs/null.c @@ -66,7 +66,9 @@ processvattr(const char *path, const struct vattr *va, int regular) if (chown(path, va->va_uid, va->va_gid) == -1) return errno; +#ifndef __minix if (va->va_mode != (unsigned)PUFFS_VNOVAL) +#endif /* FIXME: lchmod */ if (chmod(path, va->va_mode) == -1) return errno; diff --git a/lib/libpuffs/open.c b/lib/libpuffs/open.c index da3e1f059..1ff9834e5 100644 --- a/lib/libpuffs/open.c +++ b/lib/libpuffs/open.c @@ -25,7 +25,7 @@ PUBLIC int fs_create() struct puffs_newinfo pni; struct puffs_kcn pkcnp; PUFFS_MAKECRED(pcr, &global_kcred); - struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}}; + struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}}; struct vattr va; time_t cur_time; int len; @@ -122,7 +122,7 @@ PUBLIC int fs_mknod() struct puffs_newinfo pni; struct puffs_kcn pkcnp; PUFFS_MAKECRED(pcr, &global_kcred); - struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}}; + struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}}; struct vattr va; time_t cur_time; int len; @@ -205,7 +205,7 @@ PUBLIC int fs_mkdir() struct puffs_newinfo pni; struct puffs_kcn pkcnp; PUFFS_MAKECRED(pcr, &global_kcred); - struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}}; + struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}}; struct vattr va; time_t cur_time; int len; @@ -289,7 +289,7 @@ PUBLIC int fs_slink() struct puffs_newinfo pni; struct puffs_kcn pkcnp; PUFFS_MAKECRED(pcr, &global_kcred); - struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}}; + struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}}; struct vattr va; int len; diff --git a/lib/libpuffs/path.c b/lib/libpuffs/path.c index 211afbfad..9ad6e3e11 100644 --- a/lib/libpuffs/path.c +++ b/lib/libpuffs/path.c @@ -372,7 +372,7 @@ int chk_perm; /* check permissions when string is looked up*/ struct puffs_kcn pkcnp; PUFFS_MAKECRED(pcr, &global_kcred); - struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}}; + struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}}; enum vtype node_vtype; voff_t size; diff --git a/lib/libpuffs/path_puffs.c b/lib/libpuffs/path_puffs.c index 027f1f815..70a64ad6c 100644 --- a/lib/libpuffs/path_puffs.c +++ b/lib/libpuffs/path_puffs.c @@ -54,6 +54,7 @@ puffs_path_pcnbuild(struct puffs_usermount *pu, struct puffs_cn *pcn, assert(pn_parent->pn_po.po_path != NULL); assert(pu->pu_flags & PUFFS_FLAG_BUILDPATH); + pcn_orig = *pcn; if (pu->pu_pathtransform) { rv = pu->pu_pathtransform(pu, &pn_parent->pn_po, pcn, &po); @@ -65,8 +66,6 @@ puffs_path_pcnbuild(struct puffs_usermount *pu, struct puffs_cn *pcn, } if (pu->pu_namemod) { - /* XXX: gcc complains if I do assignment */ - memcpy(&pcn_orig, pcn, sizeof(pcn_orig)); rv = pu->pu_namemod(pu, &pn_parent->pn_po, pcn); if (rv) return rv; diff --git a/lib/libpuffs/proto.h b/lib/libpuffs/proto.h index da1c95d8b..09e784d35 100644 --- a/lib/libpuffs/proto.h +++ b/lib/libpuffs/proto.h @@ -1,12 +1,17 @@ #ifndef PUFFS_PROTO_H #define PUFFS_PROTO_H +struct puffs_usermount; +struct puffs_node; + /* Function prototypes. */ _PROTOTYPE( int fs_new_driver, (void) ); /* inode.c */ _PROTOTYPE( int fs_putnode, (void) ); +_PROTOTYPE( void release_node, (struct puffs_usermount *pu, + struct puffs_node *pn ) ); /* device.c */ _PROTOTYPE( int dev_open, (endpoint_t driver_e, dev_t dev, @@ -62,10 +67,10 @@ _PROTOTYPE( int fs_utime, (void) ); /* utility.c */ _PROTOTYPE( int no_sys, (void) ); -_PROTOTYPE( void mfs_nul_f, (char *file, int line, char *str, +_PROTOTYPE( void mfs_nul_f, (const char *file, int line, char *str, unsigned int len, unsigned int maxlen) ); _PROTOTYPE( time_t clock_time, (void) ); _PROTOTYPE( int update_times, (struct puffs_node *pn, int fl, time_t t) ); -_PROTOTYPE( void lpuffs_debug, (char *format, ...) ); +_PROTOTYPE( void lpuffs_debug, (const char *format, ...) ); #endif /* PUFFS_PROTO_H */ diff --git a/lib/libpuffs/read.c b/lib/libpuffs/read.c index 3e260b10b..4c4516b0f 100644 --- a/lib/libpuffs/read.c +++ b/lib/libpuffs/read.c @@ -32,7 +32,7 @@ PUBLIC int fs_readwrite(void) int r = OK, rw_flag; cp_grant_id_t gid; off_t pos; - size_t nrbytes, bytes_left, bytes_done; + size_t nrbytes, bytes_left, bytes_done = 0; struct puffs_node *pn; struct vattr va; PUFFS_MAKECRED(pcr, &global_kcred); @@ -51,7 +51,7 @@ PUBLIC int fs_readwrite(void) if (nrbytes > RW_BUFSIZ) nrbytes = bytes_left = RW_BUFSIZ; - memset(getdents_buf, '\0', RW_BUFSIZ); /* Avoid leaking any data */ + memset(getdents_buf, '\0', GETDENTS_BUFSIZ); /* Avoid leaking any data */ if (rw_flag == READING) { if (global_pu->pu_ops.puffs_node_read == NULL) diff --git a/lib/libpuffs/utility.c b/lib/libpuffs/utility.c index a1e262d87..5b49869e2 100644 --- a/lib/libpuffs/utility.c +++ b/lib/libpuffs/utility.c @@ -24,7 +24,7 @@ PUBLIC int no_sys() /*===========================================================================* * mfs_nul * *===========================================================================*/ -PUBLIC void mfs_nul_f(char *file, int line, char *str, unsigned int len, +PUBLIC void mfs_nul_f(const char *file, int line, char *str, unsigned int len, unsigned int maxlen) { if (len < maxlen && str[len-1] != '\0') { @@ -103,7 +103,7 @@ PUBLIC int update_times(struct puffs_node *pn, int flags, time_t t) /*===========================================================================* * lpuffs_debug * *===========================================================================*/ -PUBLIC void lpuffs_debug(char *format, ...) +PUBLIC void lpuffs_debug(const char *format, ...) { char buffer[256]; va_list args;