25 Commits

Author SHA1 Message Date
Rainer Gerhards
e1e3d1b698
hardning: harden config parameter ownership and OOM cleanup 2026-05-09 11:50:21 +02:00
Rainer Gerhards
b326c76f45 style: normalize C source formatting via clang-format (PoC)
This commit applies the new canonical formatting style using `clang-format` with custom settings (notably 4-space indentation), as part of our shift toward automated formatting normalization.

⚠️ No functional changes are included — only whitespace and layout modifications as produced by `clang-format`.

This change is part of the formatting modernization strategy discussed in:
https://github.com/rsyslog/rsyslog/issues/5747

Key context:
- Formatting is now treated as a disposable view, normalized via tooling.
- The `.clang-format` file defines the canonical style.
- A fixup script (`devtools/format-code.sh`) handles remaining edge cases.
- Formatting commits are added to `.git-blame-ignore-revs` to reduce noise.
- Developers remain free to format code however they prefer locally.
2025-07-16 13:56:21 +02:00
Rainer Gerhards
7225999b77 refactor: modernize macro definitions to support formatting and clarity
This commit performs a broad modernization of widely used rsyslog
macros to align with modern C practices and support automated
formatting tools like clang-format. The changes focus on improving
syntactic regularity, readability, and tooling compatibility — without
altering behavior.

Macros refactored in this commit now follow a consistent,
statement-like form with explicit trailing semicolons. Where
applicable, macro blocks that define module interfaces (`queryEtryPt`)
have been updated to use simple `if` statements instead of `else if`
chains. While this slightly increases evaluation time, the affected
functions are only called once per module during load time to register
supported interfaces — making the performance cost irrelevant in
practice.

These improvements serve multiple purposes:
- Enable reliable clang-format usage without mangling macro logic
- Simplify reasoning about macro-expanded code for human readers
- Reduce style drift and merge conflicts
- Facilitate development for contributors using assistive tools
- Support future formatting pipelines using:
  1. `clang-format`
  2. a post-fixup normalization script

Refactored macros:
- MODULE_TYPE_NOKEEP
- MODULE_TYPE_KEEP
- MODULE_TYPE_INPUT
- MODULE_TYPE_OUTPUT
- MODULE_TYPE_FUNCTION
- MODULE_TYPE_PARSER
- MODULE_TYPE_LIB
- DEF_IMOD_STATIC_DATA
- DEF_OMOD_STATIC_DATA
- DEF_PMOD_STATIC_DATA
- DEF_FMOD_STATIC_DATA
- DEFobjStaticHelpers
- SIMP_PROP(...)

And all `queryEtryPt()` dispatch macros:
- CODEqueryEtryPt_STD_MOD_QUERIES
- CODEqueryEtryPt_STD_OMOD_QUERIES
- CODEqueryEtryPt_STD_OMODTX_QUERIES
- CODEqueryEtryPt_STD_OMOD8_QUERIES
- CODEqueryEtryPt_TXIF_OMOD_QUERIES
- CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES
- CODEqueryEtryPt_STD_IMOD_QUERIES
- CODEqueryEtryPt_STD_CONF2_QUERIES
- CODEqueryEtryPt_STD_CONF2_setModCnf_QUERIES
- CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES
- CODEqueryEtryPt_STD_CONF2_IMOD_QUERIES
- CODEqueryEtryPt_STD_CONF2_PREPRIVDROP_QUERIES
- CODEqueryEtryPt_STD_CONF2_CNFNAME_QUERIES
- CODEqueryEtryPt_STD_PMOD_QUERIES
- CODEqueryEtryPt_STD_PMOD2_QUERIES
- CODEqueryEtryPt_STD_FMOD_QUERIES
- CODEqueryEtryPt_STD_SMOD_QUERIES
- CODEqueryEtryPt_doHUPWrkr
- CODEqueryEtryPt_doHUP

This general modernization reduces macro misuse, improves DX, and
lays the foundation for a robust, automated style normalization
system.

See also: https://github.com/rsyslog/rsyslog/issues/5747
2025-07-15 08:25:58 +02:00
Rainer Gerhards
9f7f1815bb
CI: new python-based codestyle checker
Easier to maintain than the off-project C source. The checks
are pretty trivial.

This also fixes some nits that the old checker did not detect.

closes https://github.com/rsyslog/rsyslog/issues/5631
2025-06-09 18:43:36 +02:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Rainer Gerhards
fff09ac94d
core: replace errmsg object calling conventions
old interface still needs to be removed to fully finish
refactoring of this component.

see also https://github.com/rsyslog/rsyslog/issues/1684
2018-07-21 17:47:29 +02:00
Rainer Gerhards
aaade1a377 mmpstrucdata: better error message, support $! in var names
see also https://github.com/rsyslog/rsyslog/issues/1262#issuecomment-404773495
2018-07-16 14:35:05 +02:00
Rainer Gerhards
e134b545b3 mmpstrucdata: make case preservation of SD_IDs optional
commit 5cee06a60 introduced case-perservation, but did not make
it optional. This broke existing behavior and thus potentially
existing configurations. This commit introduces a new parameter
"sd_name.lowercase" which now controls this behavior.

Note that 5cee06a60 is merged to master branch together with this
commit, so no released code ever had the potential regression.

see also https://github.com/rsyslog/rsyslog/pull/2181
2018-01-07 10:18:57 +01:00
arobson
5cee06a605 case preservation for RFC5424 SD-PARAMs 2017-12-09 00:12:44 +00:00
Rainer Gerhards
3b9dec9741 "fix" Coverity scan false positives 2017-12-04 09:59:54 +01:00
Rainer Gerhards
43b621b491 mmpstrucdata bugfix: formatting error of ']' char
This was invalidly formatted as '"'. Thanks to github user
wu3396 for the error report including the patch idea.

closes https://github.com/rsyslog/rsyslog/issues/1826
2017-10-20 18:37:09 +02:00
purnima
d45daa2af0 Rebase,redefine msgDestruct() as smsg_t is used 2016-11-22 14:24:25 +05:30
Rainer Gerhards
448f16495c remove "inline" attribute from excessivly long functions 2016-10-26 11:50:15 +02:00
Rainer Gerhards
b3940cb966 remove excessive "inline" attributes 2016-06-03 12:24:27 +02:00
Rainer Gerhards
2e55c77d70 clean up doAction output module interface
We started with char * pointers, but used different types of pointers
over time. This lead to alignment warnings. In practice, I think this
should never cause any problems (at least there have been no reports
in the 7 or so years we do this), but it is not clean. The interface is
now cleaned up. We do this in a way that does not require modifications
to modules that just use string parameters. For those with message
parameters, have a look at e.g. mmutf8fix to see how easy the
required change is.
2016-01-13 04:04:26 -05:30
Janmejay Singh
15afe8245f created param in add-flow to indicate if a graph being added to global-variable is shared, so it can be deep-copied instead of referenced (external modifications to which can not be protected from unsafe concurrent access) + killed an unused function 2015-05-26 09:41:35 +05:30
Rainer Gerhards
99f93bfff8 mmpstrucdata: code cleanup 2015-04-30 10:54:08 +02:00
Rainer Gerhards
cc885deb42 bugfix: memory leak in mmpstrucdata
Thanks to Grégoire Seux for reporting this issue.

closes https://github.com/rsyslog/rsyslog/issues/310
2015-04-30 10:42:03 +02:00
Janmejay Singh
4ca5e217e2 Adds support for 'reset' statement (it has syntax similar to set 'set', but _unlike_ 'set' always force-sets the given value insteed of conditionally merging it, or not saving it because it is trying to replace an object with a leaf value etc).
Syntax:

reset $.foo = $!bar;

etc.
2014-12-17 11:39:31 +01:00
Rainer Gerhards
f491eca6dc Merge branch 'v7-devel'
Conflicts:
	tests/Makefile.am
2013-11-22 11:10:54 +01:00
Rainer Gerhards
f09010e15e bugfix: mmpstrucdata generated inaccessible properties 2013-11-21 14:27:16 +01:00
Rainer Gerhards
45a4134a8b mmpstrucdata: support for v8 omod interface 2013-11-13 13:14:25 +01:00
Rainer Gerhards
f0b56fe88f mmpstrucdata: add structured data in explicit subtree 2013-09-24 09:11:10 +02:00
Rainer Gerhards
33a3a0852c milestone: mmpstrucdata persists to json tree
but not yet to a specific subtree
2013-09-23 17:20:41 +02:00
Rainer Gerhards
593c8e41d1 milestone: mmpstrucdata parses STRUCTURED-DATA (but does not yet store it) 2013-09-23 16:10:12 +02:00