From c05105e2d70e93f445fec1471c5f83e8cc9f2d78 Mon Sep 17 00:00:00 2001 From: Kyle Repinski Date: Tue, 8 Mar 2016 13:12:32 -0600 Subject: libsecril-shim: Use CC_(UN)LIKELY macros from cutils. This is what's generally used in the frameworks. --- ril/libsecril-shim/secril-shim.c | 20 +++++++++++--------- ril/libsecril-shim/secril-shim.h | 8 +++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ril/libsecril-shim/secril-shim.c b/ril/libsecril-shim/secril-shim.c index 5ca5a5a..c83a4ae 100644 --- a/ril/libsecril-shim/secril-shim.c +++ b/ril/libsecril-shim/secril-shim.c @@ -22,7 +22,7 @@ static void onRequestShim(int request, void *data, size_t datalen, RIL_Token t) } else if (tunaVariant == VARIANT_TORO || tunaVariant == VARIANT_TOROPLUS) { raf = RAF_LTE | RAF_IS95A | RAF_IS95B | RAF_1xRTT | RAF_EVDO_0 | RAF_EVDO_A | RAF_EVDO_B | RAF_EHRPD; } - if (__predict_true(raf != RAF_UNKNOWN)) { + if (CC_LIKELY(raf != RAF_UNKNOWN)) { RIL_RadioCapability rc[1] = { { /* rc[0] */ @@ -79,7 +79,7 @@ const RIL_RadioFunctions* RIL_Init(const struct RIL_Env *env, int argc, char **a void *origRil; char propBuf[PROPERTY_VALUE_MAX]; - if (__predict_true(tunaVariant == VARIANT_INIT)) { + if (CC_LIKELY(tunaVariant == VARIANT_INIT)) { property_get("ro.product.subdevice", propBuf, "unknown"); if (!strcmp(propBuf, "maguro")) { tunaVariant = VARIANT_MAGURO; @@ -98,23 +98,21 @@ const RIL_RadioFunctions* RIL_Init(const struct RIL_Env *env, int argc, char **a /* Open and Init the original RIL. */ origRil = dlopen(RIL_LIB_PATH, RTLD_LOCAL); - if (__predict_false(!origRil)) { + if (CC_UNLIKELY(!origRil)) { RLOGE("%s: failed to load '" RIL_LIB_PATH "': %s\n", __func__, dlerror()); return NULL; } origRilInit = dlsym(origRil, "RIL_Init"); - if (__predict_false(!origRilInit)) { + if (CC_UNLIKELY(!origRilInit)) { RLOGE("%s: couldn't find original RIL_Init!\n", __func__); - dlclose(origRil); - return NULL; + goto fail_after_dlopen; } origRilFunctions = origRilInit(env, argc, argv); - if (__predict_false(!origRilFunctions)) { + if (CC_UNLIKELY(!origRilFunctions)) { RLOGE("%s: the original RIL_Init derped.\n", __func__); - dlclose(origRil); - return NULL; + goto fail_after_dlopen; } /* Shim functions as needed. */ @@ -122,4 +120,8 @@ const RIL_RadioFunctions* RIL_Init(const struct RIL_Env *env, int argc, char **a shimmedFunctions.onRequest = onRequestShim; return &shimmedFunctions; + +fail_after_dlopen: + dlclose(origRil); + return NULL; } diff --git a/ril/libsecril-shim/secril-shim.h b/ril/libsecril-shim/secril-shim.h index f64d053..b1ee607 100644 --- a/ril/libsecril-shim/secril-shim.h +++ b/ril/libsecril-shim/secril-shim.h @@ -4,13 +4,15 @@ #define LOG_TAG "secril-shim" #define RIL_SHLIB +#include +#include +#include + +#include #include #include #include #include -#include -#include -#include #define RIL_LIB_PATH "/vendor/lib/libsec-ril.so" -- cgit v1.1