[Asterisk-code-review] Clang: Fix some more tautological-compare warnings. (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Tue Apr 21 09:46:20 CDT 2015


Richard Mudgett has posted comments on this change.

Change subject: Clang: Fix some more tautological-compare warnings.
......................................................................


Patch Set 4:

(1 comment)

https://gerrit.asterisk.org/#/c/160/4/main/security_events.c
File main/security_events.c:

Line 424: 	RAII_VAR(struct ast_str *, str, NULL, ast_free);
        : 	struct ast_json *event_type_json;
        : 	enum ast_security_event_type event_type;
        : 
        : 	event_type_json = ast_json_object_get(json, "SecurityEvent");
        : 	event_type = ast_json_integer_get(event_type_json);
        : 
        : 	ast_assert(event_type < AST_SECURITY_EVENT_NUM_TYPES);
> I'm fairly certain clang would require a cast to put -2 into that enum vari
After discussing this with Mark this and similar lines should be changed:

ast_assert((unsigned int) event_type < AST_SECURITY_EVENT_NUM_TYPES);

This will work for both gcc and clang since the two compilers differ in their implementation type for the enum.  gcc treats this enum as an int while clang treats this enum as an unsigned int.

Another patch needs to correct the earlier clang tautological fixes that are identical to this.


-- 
To view, visit https://gerrit.asterisk.org/160
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ief23ef68916192b9b72dabe702b543ecfeca0b62
Gerrit-PatchSet: 4
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Diederik de Groot <dkgroot at talon.nl>
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-HasComments: Yes



More information about the asterisk-code-review mailing list