On (29/01/15 12:57), Martin Babinsky wrote:
>Date: Wed, 28 Jan 2015 16:28:01 +0100
>Subject: [PATCH 6/7] ipa-uuid: emit a message when unexpected mod type is
> encountered
>
>This patch is related to the following defect reported by covscan of FreeIPA
>master code:
>
>"""
>Error: DEADCODE (CWE-561): /daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c:796:
>cond_const: Condition "modtype != 1", taking false branch. Now the value of
>"modtype" is equal to 1.  
>/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c:796:
>cond_const: Condition "modtype != 4", taking false branch. Now the value of
>"modtype" is equal to 4.  
>/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c:941:
>equality_cond: Jumping to case "1".
>/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c:957: equality_cond: Jumping to
>case "4".  
>/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c:940: intervals: When
>switching on "modtype", the value of "modtype" must be in one of the following
>intervals: {[1,1], [4,4]}.
>/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c:940: dead_error_condition: The
>switch value "modtype" cannot reach the default case.
>/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c:1031: dead_error_begin:
>Execution cannot reach this statement: "default:".
>"""
>
>The patch is a part of series related to
>https://fedorahosted.org/freeipa/ticket/4795
>
>---
> daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c 
>b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
>index 
>2b07de45b63dab36a0b7167e3583e88ebd07f6f7..93da0f15b8acfc02beddf4e884a735897a7513fe
> 100644
>--- a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
>+++ b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
>@@ -1030,6 +1030,8 @@ static int ipauuid_pre_op(Slapi_PBlock *pb, int modtype)
> 
>         default:
>             /* never reached, just silence compiler */
>+            LOG_TRACE("File '%s' line %d: Got unexpected value of modtype:"
>+                      "%d\n", __FILE__, __LINE__, modtype);
>             break;

It is good idea to add "__FILE__, __LINE__" to debug message.
It would be better if macro LOG_TRACE added this info itself.

@see macro LOG_FATAL and LOG_TRACE
file: daemons/ipa-slapi-plugins/common/util.h

#define LOG_FATAL(fmt, ...) \
    slapi_log_error(SLAPI_LOG_FATAL, log_func, \
                    "[file %s, line %d]: " fmt, \
                    __FILE__, __LINE__, ##__VA_ARGS__)

#define LOG_TRACE(fmt, ...) \
    slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)

LS

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to