
On Fri, 2021-09-17 at 14:08 +0100, Daniel P. Berrangé wrote:
On Fri, Sep 17, 2021 at 02:58:09PM +0200, Tim Wiederhake wrote:
This helps to bring down the frame size of virNWFilterRuleDefFixup, as it exceeds 8192 bytes when libvirt is build with sanitizers enabled, in debug mode, on clang.
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> --- src/conf/nwfilter_conf.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index a3109962af..62334edeec 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2189,23 +2189,23 @@ virNWFilterRuleValidate(virNWFilterRuleDef *rule) static void virNWFilterRuleDefFixup(virNWFilterRuleDef *rule) { + ethHdrDataDef *ethHdr; + #define COPY_NEG_SIGN(A, B) \ (A).flags = ((A).flags & ~NWFILTER_ENTRY_ITEM_FLAG_IS_NEG) | \ ((B).flags & NWFILTER_ENTRY_ITEM_FLAG_IS_NEG); switch (rule->prtclType) { case VIR_NWFILTER_RULE_PROTOCOL_MAC: - COPY_NEG_SIGN(rule->p.ethHdrFilter.ethHdr.dataSrcMACMask, - rule->p.ethHdrFilter.ethHdr.dataSrcMACAddr); - COPY_NEG_SIGN(rule->p.ethHdrFilter.ethHdr.dataDstMACMask, - rule->p.ethHdrFilter.ethHdr.dataDstMACAddr); + ethHdr = &rule->p.ethHdrFilter.ethHdr; + COPY_NEG_SIGN(ethHdr->dataSrcMACMask, ethHdr-
dataSrcMACAddr); + COPY_NEG_SIGN(ethHdr->dataDstMACMask, ethHdr- dataDstMACAddr);
I don't get why this reduces stack size at all ?
COPY_NEG_SIGN is just doing a bitwise and + or + assignment which doesn't require any intermediate variables.
Regards, Daniel
I believe it's debug information for something that gets optimized away in non-debug (i.e. release) builds. Do you know of a way to ask clang to explain what takes up the space in a stack frame? Regards, Tim