Merge pull request #2130 from rgerhards/i-2102

ensure gcc-7 can be used without problems for building rsyslog
This commit is contained in:
Rainer Gerhards 2017-11-29 16:08:42 +01:00 committed by GitHub
commit 43bb848707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 102 additions and 57 deletions

View File

@ -46,7 +46,7 @@ addons:
- libkrb5-dev
- libsodium-dev
- libczmq-dev
- libhiredis.dev
- libnet1-dev
#- autoconf-archive
#- libgrok1
#- libgrok-dev
@ -62,7 +62,7 @@ matrix:
- os: osx
compiler: "clang"
env: CFLAGS="-g "
#env: CFLAGS="-g -std=c99 -Werror -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute"
#env: CFLAGS="-g -std=c99 -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute"
# note: -Werror makes ./configure.sh not properly detect functions
# like strndup() on Ubuntu 12.04. So we enable it on trusty builds
# only. The first build with gcc actually only has the purpose of
@ -71,17 +71,17 @@ matrix:
# need to find out some time why this is).
- os: linux
compiler: "gcc"
env: KAFKA="YES", CFLAGS="-g -std=c99 -Werror -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute"
env: KAFKA="YES", CFLAGS="-g -std=c99 -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute"
dist: trusty
- os: linux
compiler: "clang"
env: STAT_AN="YES", GROK="YES", KAFKA="YES", CFLAGS="-g -O2 -std=c99 -Werror -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute -Wno-unused-function"
env: STAT_AN="YES", GROK="YES", KAFKA="YES", CFLAGS="-g -O2 -std=c99 -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute -Wno-unused-function"
# note: we currently need -Wno-unused-function until we fix inline
# functions (C99 semantics are really ugly...)
dist: trusty
- os: linux
compiler: "clang"
env: MERGE="YES", STAT_AN="YES", CHECK="YES", GROK="YES", KAFKA="YES", CFLAGS="-g -O2 -std=c99 -Werror -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute -Wno-unused-function"
env: MERGE="YES", STAT_AN="YES", CHECK="YES", GROK="YES", KAFKA="YES", CFLAGS="-g -O2 -std=c99 -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute -Wno-unused-function"
# note: we currently need -Wno-unused-function until we fix inline
# functions (C99 semantics are really ugly...)
dist: trusty
@ -100,7 +100,7 @@ matrix:
- os: linux
compiler: "gcc"
dist: trusty
env: DEBUGLESS="YES", CFLAGS="-g -O2 -std=c99 -Werror -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute -Wno-unused-function"
env: DEBUGLESS="YES", CFLAGS="-g -O2 -std=c99 -W -Wall -Wextra -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute -Wno-unused-function"
# next is experimental, we may merge it with some other compile-only test
- os: linux

View File

@ -189,7 +189,7 @@ BEGINtryResume
CODESTARTtryResume
ENDtryResume
static inline grok_t *CreateGrok()
static inline grok_t *CreateGrok(void)
{
grok_t *grok = grok_new();
if(grok == NULL){
@ -270,7 +270,7 @@ parse_result_store(const grok_match_t gm,instanceData *pData)
type_len = pname_len - key_len -1;
sprintf(type,"%.*s",type_len,type);
}
else{type = "null";}
else{type = (char*)"null";}
/* store parse result into list */
result->key = key;
result->key_len = key_len;

View File

@ -61,6 +61,9 @@
#include <proton/version.h>
/* work-around issues in this contributed module */
#pragma GCC diagnostic ignored "-Wswitch-enum"
MODULE_TYPE_OUTPUT
MODULE_TYPE_NOKEEP
MODULE_CNFNAME("omamqp1")

View File

@ -25,6 +25,9 @@
*/
#include "config.h"
#include "rsyslog.h"
/* work around gcc-7 build problems - acceptable for contributed module */
#pragma GCC diagnostic ignored "-Wundef"
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>

View File

@ -34,6 +34,7 @@
#include "srUtils.h"
#if !defined(_AIX)
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
#endif
}

View File

@ -7,7 +7,7 @@
*
* File begun on 2011-05-05 by RGerhards
*
* Copyright 2011 Rainer Gerhards and Adiscon GmbH.
* Copyright 2011-2017 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -187,23 +187,22 @@ getSubstring(uchar **psrc, uchar delim, uchar *dst, int lenDst)
* dst, lenDst (receive buffer) must be given. lenDst is
* max length on entry and actual length on exit.
*/
static int
getTagComponent(uchar *tag, uchar *dst, int *lenDst)
static int ATTR_NONNULL()
getTagComponent(uchar *tag, uchar *const dst, int *const lenDst)
{
int end = *lenDst - 1; /* -1 for NUL-char! */
int i;
i = 0;
if(tag[i] != '/')
goto done;
++tag;
while(i < end && tag[i] != '\0' && tag[i] != ' ' && tag[i] != '/') {
dst[i] = tag[i];
++i;
if(tag[i] == '/') {
++tag;
while(i < end && tag[i] != '\0' && tag[i] != ' ' && tag[i] != '/') {
dst[i] = tag[i];
++i;
}
}
dst[i] = '\0';
*lenDst = i;
done:
return i;
}
@ -227,19 +226,19 @@ lookupSeverityCode(instanceData *pData, uchar *sever)
}
BEGINdoAction
BEGINdoAction_NoStrings
smsg_t **ppMsg = (smsg_t **) pMsgData;
smsg_t *pMsg = ppMsg[0];
int lenTAG;
int lenSever;
int lenHost;
int sevCode;
smsg_t *pMsg;
uchar *pszTag;
uchar pszSever[512];
uchar pszHost[512];
instanceData *pData;
CODESTARTdoAction
pData = pWrkrData->pData;
pMsg = (smsg_t*) ppString[0];
getTAG(pMsg, &pszTag, &lenTAG);
if(strncmp((char*)pszTag, (char*)pData->pszTagID, pData->lenTagID)) {
DBGPRINTF("tag '%s' not matching, mmsnmptrapd ignoring this message\n",
@ -253,7 +252,7 @@ CODESTARTdoAction
getTagComponent(pszTag+pData->lenTagID+lenSever, pszHost, &lenHost);
DBGPRINTF("mmsnmptrapd: sever '%s'(%d), host '%s'(%d)\n", pszSever, lenSever, pszHost,lenHost);
if(pszHost[lenHost-1] == ':') {
if(lenHost > 0 && pszHost[lenHost-1] == ':') {
pszHost[lenHost-1] = '\0';
--lenHost;
}
@ -270,8 +269,8 @@ ENDdoAction
/* Build the severity mapping table based on user-provided configuration
* settings.
*/
static rsRetVal
buildSeverityMapping(instanceData *pData)
static rsRetVal ATTR_NONNULL()
buildSeverityMapping(instanceData *const pData)
{
uchar pszSev[512];
uchar pszSevCode[512];
@ -305,14 +304,14 @@ buildSeverityMapping(instanceData *pData)
/* we enqueue at the top, so the two lines below do all we need! */
node->next = pData->severMap;
pData->severMap = node;
node = NULL;
DBGPRINTF("mmsnmptrapd: severity string '%s' mapped to code %d\n",
pszSev, sevCode);
}
finalize_it:
if(iRet != RS_RET_OK) {
if(node != NULL)
free(node);
free(node);
}
RETiRet;
}
@ -340,8 +339,8 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
/* finally build the instance */
if(cs.pszTagName == NULL) {
pData->pszTagName = (uchar*) strdup("snmptrapd:");
pData->pszTagID = (uchar*) strdup("snmptrapd/");
CHKmalloc(pData->pszTagName = (uchar*) strdup("snmptrapd:"));
CHKmalloc(pData->pszTagID = (uchar*) strdup("snmptrapd/"));
} else {
int lenTag = ustrlen(cs.pszTagName);
/* new tag value (with colon at the end) */

View File

@ -154,9 +154,6 @@ ENDfreeParserInst
BEGINnewParserInst
struct cnfparamvals *pvals = NULL;
int i;
char *buffer;
char *tStr;
int size = 0;
CODESTARTnewParserInst
DBGPRINTF("newParserInst (pmnormalize)\n");
@ -183,27 +180,17 @@ CODESTARTnewParserInst
} else if(!strcmp(parserpblk.descr[i].name, "rulebase")) {
inst->rulebase = (char *) es_str2cstr(pvals[i].val.d.estr, NULL);
} else if(!strcmp(parserpblk.descr[i].name, "rule")) {
es_str_t *rules;
CHKmalloc(rules = es_newStr(128));
for(int j=0; j < pvals[i].val.d.ar->nmemb; ++j) {
tStr = (char*)es_str2cstr(pvals[i].val.d.ar->arr[j], NULL);
size += strlen(tStr);
free(tStr);
CHKiRet(es_addStr(&rules, pvals[i].val.d.ar->arr[j]));
CHKiRet(es_addChar(&rules, '\n'));
}
buffer = malloc(size + pvals[i].val.d.ar->nmemb + 1);
tStr = (char*)es_str2cstr(pvals[i].val.d.ar->arr[0], NULL);
strcpy(buffer, tStr);
free(tStr);
strcat(buffer, "\n");
for(int j=1; j < pvals[i].val.d.ar->nmemb; ++j) {
tStr = (char*)es_str2cstr(pvals[i].val.d.ar->arr[j], NULL);
strcat(buffer, tStr);
free(tStr);
strcat(buffer, "\n");
}
strcat(buffer, "\0");
inst->rule = buffer;
inst->rule = (char*)es_str2cstr(rules, NULL);
} else {
dbgprintf("pmnormalize: program error, non-handled "
"param '%s'\n", parserpblk.descr[i].name);
LogError(0, RS_RET_INTERNAL_ERROR ,
"pmnormalize: program error, non-handled param '%s'",
parserpblk.descr[i].name);
}
}
if(!inst->rulebase && !inst->rule) {

View File

@ -115,9 +115,9 @@ extern int altdbg; /* and the handle for alternate debug output */
/* macros */
#ifdef DEBUGLESS
# define DBGL_UNUSED __attribute__((__unused__))
inline void r_dbgoprint(const char DBGL_UNUSED *srcname, obj_t DBGL_UNUSED *pObj,
static inline void r_dbgoprint(const char DBGL_UNUSED *srcname, obj_t DBGL_UNUSED *pObj,
const char DBGL_UNUSED *fmt, ...) {}
inline void r_dbgprintf(const char DBGL_UNUSED *srcname, const char DBGL_UNUSED *fmt, ...) {}
static inline void r_dbgprintf(const char DBGL_UNUSED *srcname, const char DBGL_UNUSED *fmt, ...) {}
#else
# define DBGL_UNUSED
void r_dbgoprint(const char *srcname, obj_t *pObj, const char *fmt, ...) __attribute__((format(printf, 3, 4)));

View File

@ -10,7 +10,7 @@ if [ $? -ne 0 ]; then
echo Download autoconf-archive failed!
exit 1
fi
#sudo dpkg -i autoconf-archive_20170928-1adiscon1_all.deb
sudo dpkg -i autoconf-archive_20170928-1adiscon1_all.deb
rm autoconf-archive_20170928-1adiscon1_all.deb
if [ "x$GROK" == "xYES" ]; then sudo apt-get install -qq libgrok1 libgrok-dev ; fi

View File

@ -32,7 +32,10 @@ echo "****************************** END PREP STEP *****************************
export ASAN_OPTIONS=detect_leaks=0
autoreconf --force --verbose --install
export CONFIG_FLAGS="--prefix=/opt/rsyslog --enable-silent-rules --disable-generate-man-pages --enable-testbench --enable-imdiag --enable-imfile --enable-impstats --enable-mmrm1stspace --enable-mmanon --enable-mmaudit --enable-mmfields --enable-mmjsonparse --enable-mmpstrucdata --enable-mmsequence --enable-mmutf8fix --enable-mail --enable-omprog --enable-omstdout --enable-omuxsock --enable-pmaixforwardedfrom --enable-pmciscoios --enable-pmcisconames --enable-pmlastmsg --enable-pmsnare --enable-mmcount --disable-omudpspoof --disable-snmp --disable-mmsnmptrapd --disable-uuid --disable-libgcrypt"
export CONFIG_FLAGS="--prefix=/opt/rsyslog --enable-silent-rules --enable-testbench --enable-imdiag --enable-imfile --enable-impstats --enable-mmrm1stspace --enable-mmanon --enable-mmaudit --enable-mmfields --enable-mmjsonparse --enable-mmpstrucdata --enable-mmsequence --enable-mmutf8fix --enable-mail --enable-omprog --enable-omstdout --enable-omuxsock --enable-pmaixforwardedfrom --enable-pmciscoios --enable-pmcisconames --enable-pmlastmsg --enable-pmsnare --enable-mmcount --disable-omudpspoof --enable-snmp --enable-mmsnmptrapd --disable-uuid --disable-libgcrypt \
--enable-pmnull \
--enable-pmnormalize=no \
--disable-generate-man-pages"
./configure $CONFIG_FLAGS
export USE_AUTO_DEBUG="off" # set to "on" to enable this for travis
make -j

View File

@ -69,14 +69,63 @@ if [ "$CC" == "clang" ] && [ "$DISTRIB_CODENAME" == "trusty" ]; then export CC="
$CC -v
if [ "$DISTRIB_CODENAME" != "precise" ]; then AMQP1="--enable-omamqp1"; fi
export CONFIG_FLAGS="--prefix=/opt/rsyslog --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking --enable-silent-rules --libdir=/usr/lib64 --docdir=/usr/share/doc/rsyslog --disable-generate-man-pages --enable-testbench --enable-imdiag --enable-imfile --enable-impstats --enable-mmrm1stspace --enable-imptcp --enable-mmanon --enable-mmaudit --enable-mmfields --enable-mmjsonparse --enable-mmpstrucdata --enable-mmsequence --enable-mmutf8fix --enable-mail --enable-omprog --enable-omruleset --enable-omstdout --enable-omuxsock --enable-pmaixforwardedfrom --enable-pmciscoios --enable-pmcisconames --enable-pmlastmsg --enable-pmsnare --enable-libgcrypt --enable-mmnormalize --disable-omudpspoof --enable-relp --enable-snmp --disable-mmsnmptrapd --enable-gnutls --enable-mysql --enable-mysql-tests --enable-gt-ksi --enable-libdbi --enable-pgsql --enable-omhttpfs --enable-elasticsearch --enable-valgrind --enable-ommongodb --enable-omrelp-default-port=13515 --enable-omtcl --enable-mmdblookup \
export CONFIG_FLAGS="$CONFIGURE_FLAGS \
$JOURNAL_OPT \
$HIREDIS_OPT \
$ENABLE_KAFKA \
$ENABLE_DEBUGLESS \
$NO_VALGRIND \
$GROK \
$ES_TEST_CONFIGURE_OPT \
$AMQP1 \
--disable-generate-man-pages \
--enable-testbench \
--enable-imdiag \
--enable-imfile \
--enable-impstats \
--enable-mmrm1stspace \
--enable-imptcp \
--enable-mmanon \
--enable-mmaudit \
--enable-mmfields \
--enable-mmjsonparse \
--enable-mmpstrucdata \
--enable-mmsequence \
--enable-mmutf8fix \
--enable-mail \
--enable-omprog \
--enable-omruleset \
--enable-omstdout \
--enable-omuxsock \
--enable-pmaixforwardedfrom \
--enable-pmciscoios \
--enable-pmcisconames \
--enable-pmlastmsg \
--enable-pmsnare \
--enable-libgcrypt \
--enable-mmnormalize \
--enable-omudpspoof \
--enable-relp --enable-omrelp-default-port=13515 \
--enable-snmp \
--enable-mmsnmptrapd \
--enable-gnutls \
--enable-mysql --enable-mysql-tests \
--enable-gt-ksi \
--enable-libdbi \
--enable-pgsql \
--enable-omhttpfs \
--enable-elasticsearch \
--enable-valgrind \
--enable-ommongodb \
--enable-omtcl \
--enable-mmdblookup \
--enable-mmcount \
--enable-gssapi-krb5=no \
--enable-omhiredis \
--enable-imczmq --enable-omczmq \
--enable-usertools=no \
$JOURNAL_OPT $HIREDIS_OPT $ENABLE_KAFKA $ENABLE_DEBUGLESS $NO_VALGRIND \
$GROK $ES_TEST_CONFIGURE_OPT $CONFIGURE_FLAGS $AMQP1"
--enable-pmnull \
--enable-pmnormalize"
# Note: [io]mzmq3 cannot be built any longer, according to Brian Knox they require an
# outdated version of the client lib. So we do not bother any longer about them.
./configure $CONFIG_FLAGS
@ -101,5 +150,5 @@ then
make distcheck
fi
if [ "x$STAT_AN" == "xYES" ] ; then make clean; CFLAGS="-O2 -std=c99"; ./configure $CONFIG_FLAGS ; fi
if [ "x$STAT_AN" == "xYES" ] ; then make clean; CFLAGS="-O2"; ./configure $CONFIG_FLAGS ; fi
if [ "x$STAT_AN" == "xYES" ] ; then $SCAN_BUILD --use-cc $CC --status-bugs make -j ; fi