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); 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 int
gettimeofday(struct timeval *tv, struct timezone *tz) gettimeofday(struct timeval *tv, struct timezone *tz)
{ {

View File

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

View File

@ -741,7 +741,7 @@ linker_file_add_dependency(linker_file_t file, linker_file_t dep)
file->deps[file->ndeps] = dep; file->deps[file->ndeps] = dep;
file->ndeps++; file->ndeps++;
KLD_DPF(FILE, ("linker_file_add_dependency:" KLD_DPF(FILE, ("linker_file_add_dependency:"
" adding %s as dependency for %s\n", " adding %s as dependency for %s\n",
dep->filename, file->filename)); dep->filename, file->filename));
return (0); return (0);
} }
@ -1711,6 +1711,9 @@ linker_lookup_file(const char *path, int pathlen, const char *name,
reclen = pathlen + strlen(sep) + namelen + extlen + 1; reclen = pathlen + strlen(sep) + namelen + extlen + 1;
result = malloc(reclen, M_LINKER, M_WAITOK); result = malloc(reclen, M_LINKER, M_WAITOK);
for (cpp = linker_ext_list; *cpp; cpp++) { 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, snprintf(result, reclen, "%.*s%s%.*s%s", pathlen, path, sep,
namelen, name, *cpp); namelen, name, *cpp);
/* /*
@ -1776,7 +1779,11 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname,
goto bad; goto bad;
best = cp = NULL; best = cp = NULL;
error = VOP_GETATTR(nd.ni_vp, &vattr, cred); error = VOP_GETATTR(nd.ni_vp, &vattr, cred);
#ifdef FSTACK
if (error || vattr.va_size == 0)
#else
if (error) if (error)
#endif
goto bad; goto bad;
/* /*
* XXX: we need to limit this number to some reasonable value * XXX: we need to limit this number to some reasonable value

View File

@ -13,7 +13,7 @@
* $FreeBSD$ * $FreeBSD$
*/ */
/* /*
* ==FILEVERSION 971210== * ==FILEVERSION 971210==
* *
* This marker is used by the Linux installation script to determine * This marker is used by the Linux installation script to determine
@ -270,7 +270,7 @@ void zcfree OF((voidpf opaque, voidpf ptr));
/* +++ deflate.h */ /* +++ deflate.h */
/* deflate.h -- internal compression state /* deflate.h -- internal compression state
* Copyright (C) 1995-1996 Jean-loup Gailly * Copyright (C) 1995-1996 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
@ -551,7 +551,7 @@ void _tr_stored_type_only OF((deflate_state *));
/* +++ deflate.c */ /* +++ deflate.c */
/* deflate.c -- compress data using the deflation algorithm /* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-1996 Jean-loup Gailly. * Copyright (C) 1995-1996 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* /*
@ -877,7 +877,7 @@ int deflateReset (strm)
z_streamp strm; z_streamp strm;
{ {
deflate_state *s; deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL || if (strm == Z_NULL || strm->state == Z_NULL ||
strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR; strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR;
@ -949,7 +949,7 @@ local void putShortMSB (s, b)
{ {
put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b >> 8));
put_byte(s, (Byte)(b & 0xff)); put_byte(s, (Byte)(b & 0xff));
} }
/* ========================================================================= /* =========================================================================
* Flush as much pending output as possible. All deflate() output goes * Flush as much pending output as possible. All deflate() output goes
@ -1203,7 +1203,7 @@ int deflateOutputPending (strm)
z_streamp strm; z_streamp strm;
{ {
if (strm == Z_NULL || strm->state == Z_NULL) return 0; if (strm == Z_NULL || strm->state == Z_NULL) return 0;
return ((deflate_state *)(strm->state))->pending; return ((deflate_state *)(strm->state))->pending;
} }
@ -1694,7 +1694,7 @@ local block_state deflate_fast(s, flush)
* always MIN_MATCH bytes ahead. * always MIN_MATCH bytes ahead.
*/ */
} while (--s->match_length != 0); } while (--s->match_length != 0);
s->strstart++; s->strstart++;
} else { } else {
s->strstart += s->match_length; s->strstart += s->match_length;
s->match_length = 0; s->match_length = 0;
@ -1712,7 +1712,7 @@ local block_state deflate_fast(s, flush)
Tracevv((stderr,"%c", s->window[s->strstart])); Tracevv((stderr,"%c", s->window[s->strstart]));
bflush = _tr_tally (s, 0, s->window[s->strstart]); bflush = _tr_tally (s, 0, s->window[s->strstart]);
s->lookahead--; s->lookahead--;
s->strstart++; s->strstart++;
} }
if (bflush) FLUSH_BLOCK(s, 0); if (bflush) FLUSH_BLOCK(s, 0);
} }
@ -1845,7 +1845,7 @@ local block_state deflate_slow(s, flush)
/* +++ trees.c */ /* +++ trees.c */
/* trees.c -- output deflated data using Huffman coding /* trees.c -- output deflated data using Huffman coding
* Copyright (C) 1995-1996 Jean-loup Gailly * Copyright (C) 1995-1996 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* /*
@ -2980,7 +2980,7 @@ local void copy_block(s, buf, len, header)
s->last_eob_len = 8; /* enough lookahead for inflate */ s->last_eob_len = 8; /* enough lookahead for inflate */
if (header) { if (header) {
put_short(s, (ush)len); put_short(s, (ush)len);
put_short(s, (ush)~len); put_short(s, (ush)~len);
#ifdef DEBUG_ZLIB #ifdef DEBUG_ZLIB
s->bits_sent += 2*16; s->bits_sent += 2*16;
@ -2990,6 +2990,9 @@ local void copy_block(s, buf, len, header)
s->bits_sent += (ulg)len<<3; s->bits_sent += (ulg)len<<3;
#endif #endif
/* bundle up the put_byte(s, *buf++) calls */ /* bundle up the put_byte(s, *buf++) calls */
#ifdef FSTACK
if (buf != NULL)
#endif
zmemcpy(&s->pending_buf[s->pending], buf, len); zmemcpy(&s->pending_buf[s->pending], buf, len);
s->pending += len; s->pending += len;
} }
@ -2998,7 +3001,7 @@ local void copy_block(s, buf, len, header)
/* +++ inflate.c */ /* +++ inflate.c */
/* inflate.c -- zlib interface to inflate modules /* inflate.c -- zlib interface to inflate modules
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* #include "zutil.h" */ /* #include "zutil.h" */
@ -3006,7 +3009,7 @@ local void copy_block(s, buf, len, header)
/* +++ infblock.h */ /* +++ infblock.h */
/* infblock.h -- header to use infblock.c /* infblock.h -- header to use infblock.c
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
@ -3088,7 +3091,7 @@ struct internal_state {
/* mode independent information */ /* mode independent information */
int nowrap; /* flag for no wrapper */ int nowrap; /* flag for no wrapper */
uInt wbits; /* log2(window size) (8..15, defaults to 15) */ uInt wbits; /* log2(window size) (8..15, defaults to 15) */
inflate_blocks_statef inflate_blocks_statef
*blocks; /* current inflate_blocks state */ *blocks; /* current inflate_blocks state */
}; };
@ -3426,7 +3429,7 @@ z_streamp z;
/* +++ infblock.c */ /* +++ infblock.c */
/* infblock.c -- interpret and process block types to last block /* infblock.c -- interpret and process block types to last block
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* #include "zutil.h" */ /* #include "zutil.h" */
@ -3435,7 +3438,7 @@ z_streamp z;
/* +++ inftrees.h */ /* +++ inftrees.h */
/* inftrees.h -- header to use inftrees.c /* inftrees.h -- header to use inftrees.c
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
@ -3497,7 +3500,7 @@ extern int inflate_trees_free OF((
/* +++ infcodes.h */ /* +++ infcodes.h */
/* infcodes.h -- header to use infcodes.c /* infcodes.h -- header to use infcodes.c
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
@ -3527,7 +3530,7 @@ extern void inflate_codes_free OF((
/* +++ infutil.h */ /* +++ infutil.h */
/* infutil.h -- types and macros common to blocks and codes /* infutil.h -- types and macros common to blocks and codes
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
@ -3570,7 +3573,7 @@ struct inflate_blocks_state {
struct { struct {
inflate_huft *tl; inflate_huft *tl;
inflate_huft *td; /* trees to free */ inflate_huft *td; /* trees to free */
inflate_codes_statef inflate_codes_statef
*codes; *codes;
} decode; /* if CODES, current state */ } decode; /* if CODES, current state */
} sub; /* submode */ } sub; /* submode */
@ -4103,7 +4106,7 @@ int inflate_packet_flush(s)
/* +++ inftrees.c */ /* +++ inftrees.c */
/* inftrees.c -- generate Huffman trees for efficient decoding /* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* #include "zutil.h" */ /* #include "zutil.h" */
@ -4579,7 +4582,7 @@ z_streamp z; /* for zfree function */
q = (--p)->next; q = (--p)->next;
ZFREE(z,p); ZFREE(z,p);
p = q; p = q;
} }
return Z_OK; return Z_OK;
} }
/* --- inftrees.c */ /* --- inftrees.c */
@ -4587,7 +4590,7 @@ z_streamp z; /* for zfree function */
/* +++ infcodes.c */ /* +++ infcodes.c */
/* infcodes.c -- process literals and length/distance pairs /* infcodes.c -- process literals and length/distance pairs
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* #include "zutil.h" */ /* #include "zutil.h" */
@ -4599,7 +4602,7 @@ z_streamp z; /* for zfree function */
/* +++ inffast.h */ /* +++ inffast.h */
/* inffast.h -- header to use inffast.c /* inffast.h -- header to use inffast.c
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
@ -4856,7 +4859,7 @@ z_streamp z;
/* +++ infutil.c */ /* +++ infutil.c */
/* inflate_util.c -- data and routines common to blocks and codes /* inflate_util.c -- data and routines common to blocks and codes
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* #include "zutil.h" */ /* #include "zutil.h" */
@ -4952,7 +4955,7 @@ int r;
/* +++ inffast.c */ /* +++ inffast.c */
/* inffast.c -- process literals and length/distance pairs fast /* inffast.c -- process literals and length/distance pairs fast
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* #include "zutil.h" */ /* #include "zutil.h" */
@ -5125,7 +5128,7 @@ z_streamp z;
/* +++ zutil.c */ /* +++ zutil.c */
/* zutil.c -- target dependent utility functions for the compression library /* zutil.c -- target dependent utility functions for the compression library
* Copyright (C) 1995-1996 Jean-loup Gailly. * Copyright (C) 1995-1996 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* From: zutil.c,v 1.17 1996/07/24 13:41:12 me Exp $ */ /* From: zutil.c,v 1.17 1996/07/24 13:41:12 me Exp $ */
@ -5343,7 +5346,7 @@ void zcfree (opaque, ptr)
/* +++ adler32.c */ /* +++ adler32.c */
/* adler32.c -- compute the Adler-32 checksum of a data stream /* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1996 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* From: adler32.c,v 1.10 1996/05/22 11:52:18 me Exp $ */ /* From: adler32.c,v 1.10 1996/05/22 11:52:18 me Exp $ */

View File

@ -687,7 +687,11 @@ imf_get_source(struct in_mfilter *imf, const struct sockaddr_in *psin,
if (lims == NULL) { if (lims == NULL) {
if (imf->imf_nsrc == in_mcast_maxsocksrc) if (imf->imf_nsrc == in_mcast_maxsocksrc)
return (ENOSPC); return (ENOSPC);
#ifdef FSTACK
nims = malloc(sizeof(struct ip_msource), M_INMFILTER,
#else
nims = malloc(sizeof(struct in_msource), M_INMFILTER, nims = malloc(sizeof(struct in_msource), M_INMFILTER,
#endif
M_NOWAIT | M_ZERO); M_NOWAIT | M_ZERO);
if (nims == NULL) if (nims == NULL)
return (ENOMEM); return (ENOMEM);
@ -718,7 +722,11 @@ imf_graft(struct in_mfilter *imf, const uint8_t st1,
struct ip_msource *nims; struct ip_msource *nims;
struct in_msource *lims; struct in_msource *lims;
#ifdef FSTACK
nims = malloc(sizeof(struct ip_msource), M_INMFILTER,
#else
nims = malloc(sizeof(struct in_msource), M_INMFILTER, nims = malloc(sizeof(struct in_msource), M_INMFILTER,
#endif
M_NOWAIT | M_ZERO); M_NOWAIT | M_ZERO);
if (nims == NULL) if (nims == NULL)
return (NULL); return (NULL);
@ -1053,9 +1061,10 @@ inm_merge(struct in_multi *inm, /*const*/ struct in_mfilter *imf)
/* Decrement ASM listener count on transition out of ASM mode. */ /* Decrement ASM listener count on transition out of ASM mode. */
if (imf->imf_st[0] == MCAST_EXCLUDE && nsrc0 == 0) { if (imf->imf_st[0] == MCAST_EXCLUDE && nsrc0 == 0) {
if ((imf->imf_st[1] != MCAST_EXCLUDE) || 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__); CTR1(KTR_IGMPV3, "%s: --asm on inm at t1", __func__);
--inm->inm_st[1].iss_asm; --inm->inm_st[1].iss_asm;
}
} }
/* Increment ASM listener count on transition to ASM mode. */ /* Increment ASM listener count on transition to ASM mode. */
@ -2168,7 +2177,7 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
error = in_joingroup_locked(ifp, &gsa->sin.sin_addr, imf, error = in_joingroup_locked(ifp, &gsa->sin.sin_addr, imf,
&inm); &inm);
if (error) { if (error) {
CTR1(KTR_IGMPV3, "%s: in_joingroup_locked failed", CTR1(KTR_IGMPV3, "%s: in_joingroup_locked failed",
__func__); __func__);
IN_MULTI_UNLOCK(); IN_MULTI_UNLOCK();
goto out_imo_free; goto out_imo_free;
@ -2582,7 +2591,7 @@ inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
int i; int i;
INP_WUNLOCK(inp); INP_WUNLOCK(inp);
CTR2(KTR_IGMPV3, "%s: loading %lu source list entries", CTR2(KTR_IGMPV3, "%s: loading %lu source list entries",
__func__, (unsigned long)msfr.msfr_nsrcs); __func__, (unsigned long)msfr.msfr_nsrcs);
kss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs, kss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs,

View File

@ -641,7 +641,12 @@ im6f_get_source(struct in6_mfilter *imf, const struct sockaddr_in6 *psin,
if (lims == NULL) { if (lims == NULL) {
if (imf->im6f_nsrc == in6_mcast_maxsocksrc) if (imf->im6f_nsrc == in6_mcast_maxsocksrc)
return (ENOSPC); return (ENOSPC);
#ifdef FSTACK
nims = malloc(sizeof(struct ip6_msource), M_IN6MFILTER,
#else
nims = malloc(sizeof(struct in6_msource), M_IN6MFILTER, nims = malloc(sizeof(struct in6_msource), M_IN6MFILTER,
#endif
M_NOWAIT | M_ZERO); M_NOWAIT | M_ZERO);
if (nims == NULL) if (nims == NULL)
return (ENOMEM); return (ENOMEM);
@ -672,7 +677,11 @@ im6f_graft(struct in6_mfilter *imf, const uint8_t st1,
struct ip6_msource *nims; struct ip6_msource *nims;
struct in6_msource *lims; struct in6_msource *lims;
#ifdef FSTACK
nims = malloc(sizeof(struct ip6_msource), M_IN6MFILTER,
#else
nims = malloc(sizeof(struct in6_msource), M_IN6MFILTER, nims = malloc(sizeof(struct in6_msource), M_IN6MFILTER,
#endif
M_NOWAIT | M_ZERO); M_NOWAIT | M_ZERO);
if (nims == NULL) if (nims == NULL)
return (NULL); return (NULL);
@ -999,9 +1008,10 @@ in6m_merge(struct in6_multi *inm, /*const*/ struct in6_mfilter *imf)
/* Decrement ASM listener count on transition out of ASM mode. */ /* Decrement ASM listener count on transition out of ASM mode. */
if (imf->im6f_st[0] == MCAST_EXCLUDE && nsrc0 == 0) { if (imf->im6f_st[0] == MCAST_EXCLUDE && nsrc0 == 0) {
if ((imf->im6f_st[1] != MCAST_EXCLUDE) || 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__); CTR1(KTR_MLD, "%s: --asm on inm at t1", __func__);
--inm->in6m_st[1].iss_asm; --inm->in6m_st[1].iss_asm;
}
} }
/* Increment ASM listener count on transition to ASM mode. */ /* Increment ASM listener count on transition to ASM mode. */
@ -2440,7 +2450,7 @@ in6p_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
int i; int i;
INP_WUNLOCK(inp); INP_WUNLOCK(inp);
CTR2(KTR_MLD, "%s: loading %lu source list entries", CTR2(KTR_MLD, "%s: loading %lu source list entries",
__func__, (unsigned long)msfr.msfr_nsrcs); __func__, (unsigned long)msfr.msfr_nsrcs);
kss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs, kss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs,