Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c57eda9 authored by Andreas Gampe's avatar Andreas Gampe
Browse files

Frameworks/base: Wall Werror in common_time

Turn on warnings and errors in common_time.

Fix a code path in CommonTimeServer::handleSyncResponse in which
and uninitialized variable is returned.

Change-Id: I2f80f063c625f032266647d0507f573370202707
parent 487ae9b8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -33,4 +33,6 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := common_time

LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code

include $(BUILD_EXECUTABLE)
+2 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#define __STDC_LIMIT_MACROS
#define LOG_TAG "common_time"
#include <utils/Log.h>
#include <inttypes.h>
#include <stdint.h>

#include <common_time/local_clock.h>
@@ -280,7 +281,7 @@ bool ClockRecoveryLoop::pushDisciplineEvent(int64_t local_time,
    // system.
    setTargetCorrection_l(tgt_correction);

    LOG_TS("clock_loop %lld %f %f %f %d\n", raw_delta, delta_f, CO, CObias, tgt_correction);
    LOG_TS("clock_loop %" PRId64 " %f %f %f %d\n", raw_delta, delta_f, CO, CObias, tgt_correction);

#ifdef TIME_SERVICE_DEBUG
    diag_thread_->pushDisciplineEvent(
@@ -335,7 +336,6 @@ void ClockRecoveryLoop::setTargetCorrection_l(int32_t tgt) {
    // 300mSec.
    if (tgt_correction_ != tgt) {
        int64_t now = local_clock_->getLocalTime();
        status_t res;

        tgt_correction_ = tgt;

+0 −1
Original line number Diff line number Diff line
@@ -111,7 +111,6 @@ class ClockRecoveryLoop {
    bool    last_error_est_valid_;
    int32_t last_error_est_usec_;
    float last_delta_f_;
    int32_t integrated_error_;
    int32_t tgt_correction_;
    int32_t cur_correction_;
    LinearTransform time_to_cur_slew_;
+2 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#define LOG_TAG "common_time"
#include <utils/Log.h>

#include <inttypes.h>
#include <stdint.h>

#include <utils/Errors.h>
@@ -50,7 +51,7 @@ bool CommonClock::init(uint64_t local_freq) {

    LinearTransform::reduce(&numer, &denom);
    if ((numer > UINT32_MAX) || (denom > UINT32_MAX)) {
        ALOGE("Overflow in CommonClock::init while trying to reduce %lld/%lld",
        ALOGE("Overflow in CommonClock::init while trying to reduce %" PRIu64 "/%" PRIu64,
             kCommonFreq, local_freq);
        return false;
    }
+4 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <arpa/inet.h>
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <linux/if_ether.h>
#include <net/if.h>
#include <net/if_arp.h>
@@ -969,13 +970,14 @@ bool CommonTimeServer::handleSyncResponse(
        // if the RTT of the packet is significantly larger than the panic
        // threshold, we should simply discard it.  Its better to do nothing
        // than to take cues from a packet like that.
        int rttCommon = mCommonClock.localDurationToCommonDuration(rtt);
        int64_t rttCommon = mCommonClock.localDurationToCommonDuration(rtt);
        if (rttCommon > (static_cast<int64_t>(mPanicThresholdUsec) * 
                         kRTTDiscardPanicThreshMultiplier)) {
            ALOGV("Dropping sync response with RTT of %lld uSec", rttCommon);
            ALOGV("Dropping sync response with RTT of %" PRId64 " uSec", rttCommon);
            mClient_ExpiredSyncRespsRXedFromCurMaster++;
            if (shouldPanicNotGettingGoodData())
                return becomeInitial("RX panic, no good data");
            return true;
        } else {
            result = mClockRecovery.pushDisciplineEvent(avgLocal, avgCommon, rttCommon);
            mClient_LastGoodSyncRX = clientRxLocalTime;
Loading