Use *= 2 instead of += $self for doubling
authorHerwin Weststrate <herwin@snt.utwente.nl>
Fri, 17 Oct 2014 17:34:52 +0000 (19:34 +0200)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 18 Oct 2014 17:35:14 +0000 (13:35 -0400)
The generated code is slightly more efficient too (unless you consider compiler optimizations)

This fixes the following message of cppcheck:

[src/modules/rlm_unbound/rlm_unbound.c:157]: (style) Same expression on both sides of '+='.

src/modules/rlm_unbound/rlm_unbound.c

index 927d1b8..cadc6d3 100644 (file)
@@ -154,7 +154,7 @@ static int ub_common_wait(rlm_unbound_t *inst, REQUEST *request, char const *tag
        iv = inst->timeout > 64 ? 64000 : inst->timeout * 1000;
        ub_process(inst->ub);
 
-       for (waited = 0; (void*)*ub == (void *)inst; waited += iv, iv += iv) {
+       for (waited = 0; (void*)*ub == (void *)inst; waited += iv, iv *= 2) {
 
                if (waited + iv > (useconds_t)inst->timeout * 1000) {
                        usleep(inst->timeout * 1000 - waited);