elm: Unified the usage of strncmp.
authorDaniel Juyung Seo <seojuyung2@gmail.com>
Sun, 26 Jan 2014 17:07:44 +0000 (02:07 +0900)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Sun, 26 Jan 2014 17:07:44 +0000 (02:07 +0900)
- Use strlen instead of sizeof(x) - 1 for string length calculation.
- Use !strncmp for null check.

src/lib/elm_atspi_bridge.c
src/lib/elm_image.c
src/lib/elm_layout.c
src/lib/elm_map.c
src/lib/elm_photocam.c

index 0178d12..5963e6a 100644 (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;
index 7215b15..94a536f 100644 (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);
index 4e3fbdc..4f10c3b 100644 (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;
 
index 39a1df0..77e5000 100644 (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;
 
index fa1e03e..7c127ed 100644 (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,