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

Diederik de Groot asteriskteam at digium.com
Tue Apr 21 10:53:12 CDT 2015


Diederik de Groot has posted comments on this change.

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


Patch Set 4:

(1 comment)

Just want to confirm the action to be taken.

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);
> @Diederik: Would you do that since you have clang setup?  Thanks.  I'm havi
This means that:
ast_assert(event_type >= 0 && event_type < AST_SECURITY_EVENT_NUM_TYPES);

Get's changed to:
ast_assert((unsigned int) event_type < AST_SECURITY_EVENT_NUM_TYPES);

Clang wasn't having problems with the last part of the comparison, but only the first part (event_type >= 0 is always true if event_type is an unsigned int). Casting the last part does not make much of a difference.

Also doesn't that still cause a problem with ast_json_integer_get does return a negative integer, as previously remarked by Mark. Or is ast_json_integer_get going to be 'fixed'. I just need to understand the objective before i can make change for the other tautological-patches we made before.

Please confirm that:
ast_assert((unsigned int) event_type < AST_SECURITY_EVENT_NUM_TYPES);

is what you want to happen. If so will make the necessary change in this review first. Then i can start a new review for all the other occasions that where changed in the weeks before.


-- 
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: 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