From: Tim Creech Date: Fri, 30 Aug 2019 01:40:26 +0000 (-0400) Subject: FBSD: Handle malloc/free changes in FBSD 12 X-Git-Tag: openafs-devel-1_9_1~16 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=3bc541743b09f408364a946139c524d53056d40a FBSD: Handle malloc/free changes in FBSD 12 FreeBSD 12 (r328417) removed the deprecated compatibility macros MALLOC and FREE. Convert our users to just use the normal malloc and free, so we can build. FreeBSD 12 (r334545) also changed malloc() into a macro, which breaks our own malloc macro in our hcrypto config.h. To fix this, just undef malloc, if it's already a macro. Change-Id: I5c683e3834710a60cc78476cbaa7203218b11fe0 Reviewed-on: https://gerrit.openafs.org/13856 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- diff --git a/src/afs/FBSD/osi_vnodeops.c b/src/afs/FBSD/osi_vnodeops.c index 828a0a4..f58aa99 100644 --- a/src/afs/FBSD/osi_vnodeops.c +++ b/src/afs/FBSD/osi_vnodeops.c @@ -66,11 +66,11 @@ extern int afs_pbuf_freecnt; #define GETNAME() \ struct componentname *cnp = ap->a_cnp; \ char *name; \ - MALLOC(name, char *, cnp->cn_namelen+1, M_TEMP, M_WAITOK); \ + name = malloc(cnp->cn_namelen+1, M_TEMP, M_WAITOK); \ memcpy(name, cnp->cn_nameptr, cnp->cn_namelen); \ name[cnp->cn_namelen] = '\0' -#define DROPNAME() FREE(name, M_TEMP) +#define DROPNAME() free(name, M_TEMP) /* * Here we define compatibility functions/macros for interfaces that @@ -920,10 +920,10 @@ afs_vop_rename(ap) if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0) goto abortit; - MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK); + fname = malloc(fcnp->cn_namelen + 1, M_TEMP, M_WAITOK); memcpy(fname, fcnp->cn_nameptr, fcnp->cn_namelen); fname[fcnp->cn_namelen] = '\0'; - MALLOC(tname, char *, tcnp->cn_namelen + 1, M_TEMP, M_WAITOK); + tname = malloc(tcnp->cn_namelen + 1, M_TEMP, M_WAITOK); memcpy(tname, tcnp->cn_nameptr, tcnp->cn_namelen); tname[tcnp->cn_namelen] = '\0'; @@ -934,8 +934,8 @@ afs_vop_rename(ap) afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred); AFS_GUNLOCK(); - FREE(fname, M_TEMP); - FREE(tname, M_TEMP); + free(fname, M_TEMP); + free(tname, M_TEMP); if (tdvp == tvp) vrele(tdvp); else @@ -1075,7 +1075,7 @@ afs_vop_readdir(ap) dp = (const struct dirent *)((const char *)dp + dp->d_reclen)) ncookies++; - MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP, + cookies = malloc(ncookies * sizeof(u_long), M_TEMP, M_WAITOK); for (dp = dp_start, cookiep = cookies; dp < dp_end; dp = (const struct dirent *)((const char *)dp + dp->d_reclen)) { diff --git a/src/crypto/hcrypto/kernel/config.h b/src/crypto/hcrypto/kernel/config.h index dd7608d..ef89ed4 100644 --- a/src/crypto/hcrypto/kernel/config.h +++ b/src/crypto/hcrypto/kernel/config.h @@ -60,6 +60,9 @@ #define calloc _afscrypto_calloc void * _afscrypto_calloc(int, size_t); +#ifdef malloc +# undef malloc +#endif #define malloc _afscrypto_malloc void * _afscrypto_malloc(size_t); diff --git a/src/rx/FBSD/rx_knet.c b/src/rx/FBSD/rx_knet.c index 5d4b304..cae6cac 100644 --- a/src/rx/FBSD/rx_knet.c +++ b/src/rx/FBSD/rx_knet.c @@ -69,7 +69,7 @@ osi_NetReceive(osi_socket asocket, struct sockaddr_in *addr, *addr = *(struct sockaddr_in *)sa; } else printf("Unknown socket family %d in NetReceive\n", sa->sa_family); - FREE(sa, M_SONAME); + free(sa, M_SONAME); } return code; }