Fix Compile Error with gcc 11.3.0(in Ubuntu 22.04).

This commit is contained in:
fengbojiang 2023-02-16 20:06:28 +08:00
parent e3917f8953
commit 36ab0a9857
6 changed files with 67 additions and 33 deletions

View File

@ -545,6 +545,11 @@ kevent(int kq, const struct kevent *changelist, int nchanges,
return ff_kevent(kq, changelist, nchanges, eventlist, nevents, timeout);
}
/*
* It is need to modify the definition in some OS, such as Ubuntu 22.04 or later.
*
* int(struct timeval * restrict, void * restrict)
*/
int
gettimeofday(struct timeval *tv, struct timezone *tz)
{

View File

@ -34,7 +34,7 @@
#define __SDS_H
#define SDS_MAX_PREALLOC (1024*1024)
const char *SDS_NOINIT;
extern const char *SDS_NOINIT;
#include <sys/types.h>
#include <stdarg.h>

View File

@ -1711,6 +1711,9 @@ linker_lookup_file(const char *path, int pathlen, const char *name,
reclen = pathlen + strlen(sep) + namelen + extlen + 1;
result = malloc(reclen, M_LINKER, M_WAITOK);
for (cpp = linker_ext_list; *cpp; cpp++) {
#ifdef FSTACK
if (path != NULL && name != NULL)
#endif
snprintf(result, reclen, "%.*s%s%.*s%s", pathlen, path, sep,
namelen, name, *cpp);
/*
@ -1776,7 +1779,11 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname,
goto bad;
best = cp = NULL;
error = VOP_GETATTR(nd.ni_vp, &vattr, cred);
#ifdef FSTACK
if (error || vattr.va_size == 0)
#else
if (error)
#endif
goto bad;
/*
* XXX: we need to limit this number to some reasonable value

View File

@ -2990,6 +2990,9 @@ local void copy_block(s, buf, len, header)
s->bits_sent += (ulg)len<<3;
#endif
/* bundle up the put_byte(s, *buf++) calls */
#ifdef FSTACK
if (buf != NULL)
#endif
zmemcpy(&s->pending_buf[s->pending], buf, len);
s->pending += len;
}

View File

@ -687,7 +687,11 @@ imf_get_source(struct in_mfilter *imf, const struct sockaddr_in *psin,
if (lims == NULL) {
if (imf->imf_nsrc == in_mcast_maxsocksrc)
return (ENOSPC);
#ifdef FSTACK
nims = malloc(sizeof(struct ip_msource), M_INMFILTER,
#else
nims = malloc(sizeof(struct in_msource), M_INMFILTER,
#endif
M_NOWAIT | M_ZERO);
if (nims == NULL)
return (ENOMEM);
@ -718,7 +722,11 @@ imf_graft(struct in_mfilter *imf, const uint8_t st1,
struct ip_msource *nims;
struct in_msource *lims;
#ifdef FSTACK
nims = malloc(sizeof(struct ip_msource), M_INMFILTER,
#else
nims = malloc(sizeof(struct in_msource), M_INMFILTER,
#endif
M_NOWAIT | M_ZERO);
if (nims == NULL)
return (NULL);
@ -1053,10 +1061,11 @@ inm_merge(struct in_multi *inm, /*const*/ struct in_mfilter *imf)
/* Decrement ASM listener count on transition out of ASM mode. */
if (imf->imf_st[0] == MCAST_EXCLUDE && nsrc0 == 0) {
if ((imf->imf_st[1] != MCAST_EXCLUDE) ||
(imf->imf_st[1] == MCAST_EXCLUDE && nsrc1 > 0))
(imf->imf_st[1] == MCAST_EXCLUDE && nsrc1 > 0)) {
CTR1(KTR_IGMPV3, "%s: --asm on inm at t1", __func__);
--inm->inm_st[1].iss_asm;
}
}
/* Increment ASM listener count on transition to ASM mode. */
if (imf->imf_st[1] == MCAST_EXCLUDE && nsrc1 == 0) {

View File

@ -641,7 +641,12 @@ im6f_get_source(struct in6_mfilter *imf, const struct sockaddr_in6 *psin,
if (lims == NULL) {
if (imf->im6f_nsrc == in6_mcast_maxsocksrc)
return (ENOSPC);
#ifdef FSTACK
nims = malloc(sizeof(struct ip6_msource), M_IN6MFILTER,
#else
nims = malloc(sizeof(struct in6_msource), M_IN6MFILTER,
#endif
M_NOWAIT | M_ZERO);
if (nims == NULL)
return (ENOMEM);
@ -672,7 +677,11 @@ im6f_graft(struct in6_mfilter *imf, const uint8_t st1,
struct ip6_msource *nims;
struct in6_msource *lims;
#ifdef FSTACK
nims = malloc(sizeof(struct ip6_msource), M_IN6MFILTER,
#else
nims = malloc(sizeof(struct in6_msource), M_IN6MFILTER,
#endif
M_NOWAIT | M_ZERO);
if (nims == NULL)
return (NULL);
@ -999,10 +1008,11 @@ in6m_merge(struct in6_multi *inm, /*const*/ struct in6_mfilter *imf)
/* Decrement ASM listener count on transition out of ASM mode. */
if (imf->im6f_st[0] == MCAST_EXCLUDE && nsrc0 == 0) {
if ((imf->im6f_st[1] != MCAST_EXCLUDE) ||
(imf->im6f_st[1] == MCAST_EXCLUDE && nsrc1 > 0))
(imf->im6f_st[1] == MCAST_EXCLUDE && nsrc1 > 0)) {
CTR1(KTR_MLD, "%s: --asm on inm at t1", __func__);
--inm->in6m_st[1].iss_asm;
}
}
/* Increment ASM listener count on transition to ASM mode. */
if (imf->im6f_st[1] == MCAST_EXCLUDE && nsrc1 == 0) {