DARWIN: Declare/include functions before using them

Every function should be explicitly declared before it can be called.
Since -Wimplicit-function-declaration is usually a warning and not an
error, calling undeclared functions does not prevent us from building
the code.

However, apple-clang 12 makes this an error by default, prohibiting the
build of the current version on macOS 11 (Big Sur).

To fix this problem, declare functions before calling them. Also,
include mach/thread_act.h into afs_call.c so the declaration of
thread_terminate() can be found on macOS. Last, given that the third
argument of PIOCTL() (if UKERNEL is defined) is a pointer, cast it to
'long'. Doing so, we can avoid another inhibited warning. Notice that
this PIOCTL definition is scoped to a single file (src/auth/ktc.c).

Change-Id: I6d796c10ea4dd81b13ae5feb9f42608aa445560d
Reviewed-on: https://gerrit.openafs.org/14744
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Marcio Barbosa 2022-03-23 17:58:41 -03:00 committed by Benjamin Kaduk
parent 981b3d723e
commit f9c96d0fd6
12 changed files with 36 additions and 21 deletions

1
CODING
View File

@ -331,7 +331,6 @@ afs/afs_syscall.c : old-style
: strict-proto
: all (ukernel) : syscall pointer issues
afsd/afsd_kernel.c : deprecated : daemon() marked as deprecated on Darwin
auth/ktc.c : all (ukernel) : call_syscall doesn't have a prototype
bozo/bosserver.c : deprecated : daemon() marked as deprecated on Darwin
bucoord/ubik_db_if.c : strict-proto : ubik_Call_SingleServer
bucoord/commands.c : all : signed vs unsigned for dates

View File

@ -98,7 +98,6 @@ afs_lock_t osi_fsplock;
pthread_mutex_t usr_sleep_mutex;
pthread_cond_t usr_sleep_cond;
int call_syscall(long, long, long, long, long, long);
int fork_syscall(long, long, long, long, long, long);

View File

@ -145,5 +145,6 @@ extern void uafs_Shutdown(void);
extern void uafs_mount(void);
extern void uafs_setMountDir(const char *dir);
extern int uafs_access(char *path, int amode);
extern int call_syscall(long syscall, long afscall, long param1, long param2,
long param3, long param4);
#endif /* __AFS_USROPS_H__ */

View File

@ -23,7 +23,6 @@
#include "afs/afs_args.h"
#include "afsd/afsd.h"
extern int call_syscall(long, long, long, long, long, long);
void
afsd_mount_afs(const char *rn, const char *mountdir)

View File

@ -37,6 +37,10 @@
#endif
#include <hcrypto/rand.h>
#if defined(AFS_DARWIN80_ENV)
# include <mach/thread_act.h>
#endif
#if defined(AFS_SUN5_ENV) || defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV)
#define AFS_MINBUFFERS 100
#else

View File

@ -683,6 +683,9 @@ extern int afs_osi_Write(struct osi_file *afile, afs_int32 offset,
extern int afs_osi_MapStrategy(int (*aproc) (struct buf * bp),
struct buf *bp);
extern void shutdown_osifile(void);
#if defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV)
extern void afs_InitDualFSCacheOps(struct vnode *vp);
#endif
/* ARCH/osi_groups.c */
@ -701,6 +704,9 @@ extern int setpag(afs_proc_t *proc, afs_ucred_t **cred, afs_uint32 pagvalue,
#elif defined(AFS_OBSD_ENV)
extern int setpag(afs_proc_t *proc, struct ucred **cred, afs_uint32 pagvalue,
afs_uint32 * newpag, int change_parent);
#elif defined(AFS_DARWIN_ENV)
extern int setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue,
afs_uint32 *newpag, afs_uint32 change_parent);
#endif /* UKERNEL */
#if defined(AFS_LINUX_ENV) || defined(AFS_PAG_ONEGROUP_ENV)

View File

@ -24,7 +24,8 @@
#endif
#if defined(UKERNEL)
#include "afsincludes.h"
# include "afsincludes.h"
# include <afs_usrops.h>
#endif
#ifdef AFS_AIX_ENV
@ -119,7 +120,7 @@ static void ktc_LocalCell(void);
#endif /* AFS_KERBEROS_ENV */
#if defined(UKERNEL)
#define PIOCTL(A,B,C,D) (errno = (call_syscall(AFSCALL_PIOCTL,A,B,C,D)), errno?-1:0)
#define PIOCTL(A,B,C,D) (errno = (call_syscall(AFSCALL_PIOCTL,A,B,(long)C,D,0)), errno?-1:0)
#else
#define PIOCTL pioctl
#endif

View File

@ -65,9 +65,9 @@ MODLD=$(CC) -static $(KOPTS_DBUG) -nostdlib $(ARCHFLAGS)
<all>
CFLAGS_ppc=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_ppc) $(KOPTS_DBUG)
CFLAGS_x86=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_x86) $(KOPTS_DBUG)
CFLAGS_amd64=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_amd64) $(KOPTS_DBUG)
CFLAGS_ppc=-I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_ppc) $(KOPTS_DBUG)
CFLAGS_x86=-I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_x86) $(KOPTS_DBUG)
CFLAGS_amd64=-I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS_amd64) $(KOPTS_DBUG)
<all>
# Name of directory to hold object files and libraries.
@ -81,31 +81,32 @@ DESTDIRS = single_destdir
include Makefile.common
<all -ppc_darwin_70>
ALL_COMMON_INCLUDES=$(KINCLUDES) $(COMMON_INCLUDE)
# override suffix rule; unfortunately, this causes a warning message
.c.o:
if [ "$(ARCH_ppc)" = "yes" ]; then \
$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $< || exit(1) \
$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $< || exit(1) \
fi \
if [ "$(ARCH_x86)" = "yes" ]; then \
$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $< || exit(1) \
$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $< || exit(1) \
fi
if [ "$(ARCH_amd64)" = "yes" ]; then \
$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $< || exit(1) \
$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $< || exit(1) \
fi \
lipo -create ${OBJ_ppc} ${OBJ_x86} ${OBJ_amd64} -output $@;
CRULE_NOOPT_ppc=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $?
CRULE_NOOPT_x86=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $?
CRULE_NOOPT_amd64=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $?
CRULE_NOOPT_ppc=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $?
CRULE_NOOPT_x86=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $?
CRULE_NOOPT_amd64=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $?
CRULE_NOOPT=$(shell echo "${ARCH_ppc}" | grep -q -w yes && echo "${CRULE_NOOPT_ppc} && "; echo "${ARCH_x86}" | grep -q -w yes && echo "${CRULE_NOOPT_x86} && "; echo "${ARCH_amd64}" | grep -q -w yes && echo "${CRULE_NOOPT_amd64} && "; echo " lipo -create ${OBJ_ppc} ${OBJ_x86} ${OBJ_amd64} -output $@ && true")
CRULE_OPT_ppc=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $?
CRULE_OPT_x86=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $?
CRULE_OPT_amd64=$(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $?
CRULE_OPT_ppc=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_ppc) $(CFLAGS-$@) -o $(patsubst %.o,%.o.ppc,$@) -c $?
CRULE_OPT_x86=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_x86) $(CFLAGS-$@) -o $(patsubst %.o,%.o.x86,$@) -c $?
CRULE_OPT_amd64=$(CC) $(ALL_COMMON_INCLUDES) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS_amd64) $(CFLAGS-$@) -o $(patsubst %.o,%.o.amd64,$@) -c $?
CRULE_OPT=$(shell echo "${ARCH_ppc}" | grep -q -w yes && echo "${CRULE_OPT_ppc} && "; echo "${ARCH_x86}" | grep -q -w yes && echo "${CRULE_OPT_x86} && "; echo "${ARCH_amd64}" | grep -q -w yes && echo "${CRULE_OPT_amd64} && ";echo "lipo -create ${OBJ_ppc} ${OBJ_x86} ${OBJ_amd64} -output $@ && true")
<ppc_darwin_70>
CFLAGS=${KINCLUDES} -I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS)
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config $(DEFINES) $(KDEFS) $(KOPTS)
KOPTS=-static -fno-common -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch
<all>

View File

@ -437,7 +437,7 @@ afs_syscall.lo: $(TOP_SRC_AFS)/afs_syscall.c
osi_vfsops.lo: $(TOP_SRC_AFS)/UKERNEL/osi_vfsops.c
$(LT_CCRULE) $(TOP_SRC_AFS)/UKERNEL/osi_vfsops.c -DAFS_NONFSTRANS
ktc.lo: $(TOP_SRCDIR)/auth/ktc.c
$(LT_CCRULE) $(TOP_SRCDIR)/auth/ktc.c @CFLAGS_NOERROR@
$(LT_CCRULE) $(TOP_SRCDIR)/auth/ktc.c
cellconfig.lo: $(TOP_SRCDIR)/auth/cellconfig.c
$(LT_CCRULE) $(TOP_SRCDIR)/auth/cellconfig.c
keys.lo: $(TOP_SRCDIR)/auth/keys.c

View File

@ -16,6 +16,7 @@
#include <afsconfig.h>
#include "afs/param.h"
#include "rx_kmutex.h"
#ifndef AFS_DARWIN80_ENV
/*

View File

@ -108,6 +108,8 @@ typedef struct {
typedef int afs_kcondvar_t;
extern lck_grp_t * openafs_lck_grp;
extern void rx_kmutex_setup(void);
extern void rx_kmutex_finish(void);
#define MUTEX_SETUP() rx_kmutex_setup()
#define MUTEX_FINISH() rx_kmutex_finish()

View File

@ -315,9 +315,11 @@ extern int osi_NetReceive(osi_socket so, struct sockaddr_in *addr,
# if defined(AFS_SUN510_ENV)
extern void osi_StartNetIfPoller(void);
extern void osi_NetIfPoller(void);
extern void osi_StopNetIfPoller(void);
extern struct afs_ifinfo afsifinfo[ADDRSPERSITE];
# endif
# if defined(AFS_SUN510_ENV) || defined(RXK_UPCALL_ENV)
extern void osi_StopNetIfPoller(void);
# endif
extern void osi_StopListener(void);
extern int rxi_FindIfMTU(afs_uint32 addr);
# if defined(UKERNEL)