#define _SECURE_LOGE(...)
#endif
+#ifndef likely
+#define likely(x) __builtin_expect(!!(x), 1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
+static const char INVALID_EXEC_NAME[] = "";
static app_info_version_e _current_api_ver = APP_INFO_VERSION_2_2;
static int _compat_mode = 0;
static int _app_info_init = 0;
static char __appid[MAX_APPID]={'\0',};
static const char* _pkgid = NULL;
static const char* _appid = NULL;
-static const char* _execname = NULL;
+static const char* _execname = &INVALID_EXEC_NAME;
/**
int
appinfo_init(const char* appid, int is_invalid_appid)
{
- if(!appid && strlen(appid) >= sizeof(__appid))
+ if (!appid && strlen(appid) >= sizeof(__appid))
{
return APP_INFO_ERROR_INVALID_ARG;
}
}
else
{
- if(strlen(appid) < sizeof(MAX_OSP_PKGID))
+ if (strlen(appid) < sizeof(MAX_OSP_PKGID))
{
return APP_INFO_ERROR_INVALID_ARG;
}
app_info_version_e temp_ver;
temp_ver = __get_api_version_from_str(appinfo_get_api_str_by_version(ver));
- if( temp_ver == APP_INFO_VERSION_INVALID)
+ if ( temp_ver == APP_INFO_VERSION_INVALID)
{
return APP_INFO_ERROR_INVALID_ARG;
}
app_info_version_e appinfo_get_api_version_from_str(const char * ver_str)
{
- if(ver_str == NULL)
+ if (ver_str == NULL)
{
return APP_INFO_VERSION_INVALID;
}
- if(!strcmp(ver_str,"3.0"))
+ if (!strcmp(ver_str,"3.0"))
{
return APP_INFO_VERSION_3_0;
}
- else if(!strcmp(ver_str,"2.2"))
+ else if (!strcmp(ver_str,"2.2"))
{
return APP_INFO_VERSION_2_2;
}
- else if(!strcmp(ver_str,"2.1"))
+ else if (!strcmp(ver_str,"2.1"))
{
return APP_INFO_VERSION_2_1;
}
- else if(!strcmp(ver_str,"2.0"))
+ else if (!strcmp(ver_str,"2.0"))
{
return APP_INFO_VERSION_2_0;
}
- else if(!strcmp(ver_str,"1.2"))
+ else if (!strcmp(ver_str,"1.2"))
{
return APP_INFO_VERSION_1_2;
}
- else if(!strcmp(ver_str,"1.1"))
+ else if (!strcmp(ver_str,"1.1"))
{
return APP_INFO_VERSION_1_1;
}
- else if(!strcmp(ver_str,"1.0.2"))
+ else if (!strcmp(ver_str,"1.0.2"))
{
return APP_INFO_VERSION_1_0_2;
}
- else if(!strcmp(ver_str,"1.0"))
+ else if (!strcmp(ver_str,"1.0"))
{
return APP_INFO_VERSION_1_0;
}
int
appinfo_set_compat(int compat)
{
- if(compat == 0 || compat == 1)
+ if (compat == 0 || compat == 1)
{
_compat_mode = compat;
return APP_INFO_ERROR_NONE;
const char*
appinfo_get_appid(void)
{
- if(_app_info_init)
+ if (likely(_app_info_init))
{
return _appid;
}
/**
* @brief Returns the exec name for the application
*
- * @retval application exec name if valid, @c NULL otherwise
+ * @retval application exec name if valid, empty string otherwise
*/
const char*
appinfo_get_execname(void)
{
- if(_app_info_init)
- {
- return _execname;
- }
-
- return NULL;
+ return _execname;
}
const char*
appinfo_get_packageid(void)
{
- if(_app_info_init)
+ if (likely(_app_info_init))
{
return _pkgid;
}
int
appinfo_set_argv(int argc, char** argv)
{
- if(argc > 0 && argv)
+ if (argc > 0 && argv)
{
_argc = argc;
_argv = argv;
int appinfo_get_argv(int* argc, char*** argv)
{
- if(_app_info_init && argc && argv)
+ if (_app_info_init && argc && argv)
{
*argc = _argc;
*argv = _argv;