elm: Unified the usage of strncmp.

- Use strlen instead of sizeof(x) - 1 for string length calculation.
- Use !strncmp for null check.
This commit is contained in:
Daniel Juyung Seo 2014-01-27 02:07:44 +09:00
parent 51e18105ba
commit 5f0ca660b4
5 changed files with 11 additions and 12 deletions

View File

@ -183,7 +183,7 @@ _access_object_from_path(const char *path)
Elm_Atspi_Object *eo = NULL;
const char *tmp = path;
int len = (sizeof(ELM_ACCESS_OBJECT_PATH_PREFIX) / sizeof(char)) - 1;
int len = strlen(ELM_ACCESS_OBJECT_PATH_PREFIX);
if (strncmp(path, ELM_ACCESS_OBJECT_PATH_PREFIX, len))
return NULL;

View File

@ -994,7 +994,7 @@ _elm_image_smart_file_set(Eo *obj, void *_pd, va_list *list)
sd->remote = NULL;
for (i = 0; i < sizeof (remote_uri) / sizeof (remote_uri[0]); ++i)
if (strncmp(remote_uri[i], file, strlen(remote_uri[i])) == 0)
if (!strncmp(remote_uri[i], file, strlen(remote_uri[i])))
{
// Found a remote target !
evas_object_hide(sd->img);

View File

@ -124,8 +124,8 @@ _icon_signal_emit(Elm_Layout_Smart_Data *sd,
(strcmp("elm.swallow.icon", sub_d->part) &&
(strcmp("elm.swallow.end", sub_d->part)))) return;
if (strncmp(sub_d->part, "elm.swallow.", sizeof("elm.swallow.") - 1) == 0)
type = sub_d->part + sizeof("elm.swallow.") - 1;
if (!strncmp(sub_d->part, "elm.swallow.", strlen("elm.swallow.")))
type = sub_d->part + strlen("elm.swallow.");
else
type = sub_d->part;
@ -153,8 +153,8 @@ _text_signal_emit(Elm_Layout_Smart_Data *sd,
ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);
if (strncmp(sub_d->part, "elm.text.", sizeof("elm.text.") - 1) == 0)
type = sub_d->part + sizeof("elm.text.") - 1;
if (!strncmp(sub_d->part, "elm.text.", strlen("elm.text.")))
type = sub_d->part + strlen("elm.text.");
else
type = sub_d->part;

View File

@ -2635,11 +2635,11 @@ _xml_name_attrs_dump_cb(void *data,
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON)))
if (!strncmp(key, NOMINATIM_ATTR_LON, strlen(NOMINATIM_ATTR_LON)))
dump->lon = _elm_atof(value);
else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT)))
else if (!strncmp(key, NOMINATIM_ATTR_LAT, strlen(NOMINATIM_ATTR_LAT)))
dump->lat = _elm_atof(value);
else if (!strncmp(key, NOMINATIM_ATTR_ADDRESS, sizeof(NOMINATIM_ATTR_ADDRESS)))
else if (!strncmp(key, NOMINATIM_ATTR_ADDRESS, strlen(NOMINATIM_ATTR_ADDRESS)))
{
if (!dump->address)
dump->address = strdup(value);
@ -2726,8 +2726,7 @@ _xml_name_dump_cb(void *data,
attrs = eina_simple_xml_tag_attributes_find(value, length);
if (attrs)
{
if (!strncmp(value, NOMINATIM_RESULT,
sizeof(NOMINATIM_RESULT) - 1))
if (!strncmp(value, NOMINATIM_RESULT, strlen(NOMINATIM_RESULT)))
dump->id = NAME_XML_NAME;
else dump->id = NAME_XML_NONE;

View File

@ -1636,7 +1636,7 @@ _file_set(Eo *obj, void *_pd, va_list *list)
sd->remote = NULL;
for (i = 0; i < sizeof (remote_uri) / sizeof (remote_uri[0]); ++i)
if (strncmp(remote_uri[i], file, strlen(remote_uri[i])) == 0)
if (!strncmp(remote_uri[i], file, strlen(remote_uri[i])))
{
// Found a remote target !
sd->remote = _elm_url_download(file,