use safer and more clear eina_streq() instead of strcmp()

This commit is contained in:
Davide Andreoli 2021-04-19 07:14:34 +02:00
parent 765c10c183
commit 0293a50c05
2 changed files with 35 additions and 35 deletions

View File

@ -25,13 +25,13 @@ _places_mount_exe_del_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *eve
Ecore_Exe_Event_Del *e = (Ecore_Exe_Event_Del *)event; Ecore_Exe_Event_Del *e = (Ecore_Exe_Event_Del *)event;
const char *tag = ecore_exe_tag_get(e->exe); const char *tag = ecore_exe_tag_get(e->exe);
if (!tag || (strcmp(tag, MOUNT_TAG) && strcmp(tag, UMOUNT_TAG))) if (!tag || (!eina_streq(tag, MOUNT_TAG) && !eina_streq(tag, UMOUNT_TAG)))
return ECORE_CALLBACK_PASS_ON; return ECORE_CALLBACK_PASS_ON;
Volume *vol = ecore_exe_data_get(e->exe); Volume *vol = ecore_exe_data_get(e->exe);
if (vol && (e->exit_code == 0)) if (vol && (e->exit_code == 0))
{ {
vol->mounted = strcmp(tag, MOUNT_TAG) ? EINA_FALSE : EINA_TRUE; vol->mounted = eina_streq(tag, MOUNT_TAG);
places_volume_update(vol); places_volume_update(vol);
} }
return ECORE_CALLBACK_DONE; return ECORE_CALLBACK_DONE;
@ -43,7 +43,7 @@ _places_mount_exe_error_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e
Ecore_Exe_Event_Data *e = (Ecore_Exe_Event_Data *)event; Ecore_Exe_Event_Data *e = (Ecore_Exe_Event_Data *)event;
const char *tag = ecore_exe_tag_get(e->exe); const char *tag = ecore_exe_tag_get(e->exe);
if (!tag || (strcmp(tag, MOUNT_TAG) && strcmp(tag, UMOUNT_TAG))) if (!tag || (!eina_streq(tag, MOUNT_TAG) && !eina_streq(tag, UMOUNT_TAG)))
return ECORE_CALLBACK_PASS_ON; return ECORE_CALLBACK_PASS_ON;
Ecore_Exe_Event_Data_Line line = e->lines[0]; Ecore_Exe_Event_Data_Line line = e->lines[0];
@ -156,7 +156,7 @@ _places_mount_mtab_parse(void)
EINA_LIST_FOREACH_SAFE(to_search, l, l2, vol) EINA_LIST_FOREACH_SAFE(to_search, l, l2, vol)
{ {
if (strcmp(vol->mount_point, mpoint)) if (!eina_streq(vol->mount_point, mpoint))
continue; continue;
// printf("PLACES: Mounted: %s\n", mpoint); // printf("PLACES: Mounted: %s\n", mpoint);
@ -214,8 +214,8 @@ _places_mount_fstab_parse(void)
if (num_splits != 2) if (num_splits != 2)
continue; continue;
if (!strcmp(fstype, "nfs") || if (eina_streq(fstype, "nfs") ||
!strcmp(fstype, "cifs")) eina_streq(fstype, "cifs"))
{ {
_places_mount_volume_add(mpoint, fstype); _places_mount_volume_add(mpoint, fstype);
} }

View File

@ -229,7 +229,7 @@ places_volume_by_id_get(const char *id)
Eina_List *l; Eina_List *l;
EINA_LIST_FOREACH(volumes, l, v) EINA_LIST_FOREACH(volumes, l, v)
if (!strcmp(v->id, id)) if (eina_streq(v->id, id))
return v; return v;
return NULL; return NULL;
@ -363,35 +363,35 @@ places_fill_box(Evas_Object *main, Eina_Bool horiz)
f1 = f2 = f3 = NULL; f1 = f2 = f3 = NULL;
/* optical discs */ /* optical discs */
// TODO more icons: dvd, blueray.... // TODO more icons: dvd, blueray....
if (!strcmp(vol->drive_type, "cdrom") || if (eina_streq(vol->drive_type, "cdrom") ||
!strcmp(vol->drive_type, "optical_cd")) eina_streq(vol->drive_type, "optical_cd"))
{ {
f1 = "media"; f2 = "optical"; // OR media-optical ?? f1 = "media"; f2 = "optical"; // OR media-optical ??
} }
/* flash cards */ /* flash cards */
else if (!strcmp(vol->drive_type, "sd_mmc") || else if (eina_streq(vol->drive_type, "sd_mmc") ||
!strcmp(vol->model, "SD/MMC")) eina_streq(vol->model, "SD/MMC"))
{ {
f1 = "media"; f2 = "flash"; f3 = "sdmmc"; // NOTE sd-mmc in Oxigen :( f1 = "media"; f2 = "flash"; f3 = "sdmmc"; // NOTE sd-mmc in Oxigen :(
} }
else if (!strcmp(vol->drive_type, "memory_stick") || else if (eina_streq(vol->drive_type, "memory_stick") ||
!strcmp(vol->model, "MS/MS-Pro")) eina_streq(vol->model, "MS/MS-Pro"))
{ {
f1 = "media"; f2 = "flash"; f3 = "ms"; // NOTE memory-stick in Oxigen :( f1 = "media"; f2 = "flash"; f3 = "ms"; // NOTE memory-stick in Oxigen :(
} }
/* iPods */ /* iPods */
else if (!strcmp(vol->model, "iPod")) else if (eina_streq(vol->model, "iPod"))
{ {
f1 = "multimedia-player"; f2 = "apple"; f3 = "ipod"; f1 = "multimedia-player"; f2 = "apple"; f3 = "ipod";
} }
/* generic usb drives */ /* generic usb drives */
else if (!strcmp(vol->bus, "usb")) else if (eina_streq(vol->bus, "usb"))
{ {
f1 = "drive"; f2 = "removable-media"; f3 = "usb"; f1 = "drive"; f2 = "removable-media"; f3 = "usb";
} }
/* network filesystem */ /* network filesystem */
else if (!strcmp(vol->fstype, "nfs") || else if (eina_streq(vol->fstype, "nfs") ||
!strcmp(vol->fstype, "cifs")) eina_streq(vol->fstype, "cifs"))
{ {
f1 = "folder"; f2 = "remote"; f1 = "folder"; f2 = "remote";
} }
@ -421,24 +421,24 @@ places_fill_box(Evas_Object *main, Eina_Bool horiz)
else evas_object_del(icon); else evas_object_del(icon);
//set partition type tag //set partition type tag
if (!strcmp(vol->fstype, "ext2") || if (eina_streq(vol->fstype, "ext2") ||
!strcmp(vol->fstype, "ext3") || eina_streq(vol->fstype, "ext3") ||
!strcmp(vol->fstype, "ext4") || eina_streq(vol->fstype, "ext4") ||
!strcmp(vol->fstype, "reiserfs") || eina_streq(vol->fstype, "reiserfs") ||
!strcmp(vol->fstype, "nfs")) eina_streq(vol->fstype, "nfs"))
edje_object_signal_emit(o, "icon,tag,ext3", "places"); edje_object_signal_emit(o, "icon,tag,ext3", "places");
else if (!strcmp(vol->fstype, "ufs") || else if (eina_streq(vol->fstype, "ufs") ||
!strcmp(vol->fstype, "zfs")) eina_streq(vol->fstype, "zfs"))
edje_object_signal_emit(o, "icon,tag,ufs", "places"); edje_object_signal_emit(o, "icon,tag,ufs", "places");
else if (!strcmp(vol->fstype, "vfat") || else if (eina_streq(vol->fstype, "vfat") ||
!strcmp(vol->fstype, "ntfs") || eina_streq(vol->fstype, "ntfs") ||
!strcmp(vol->fstype, "ntfs-3g") || eina_streq(vol->fstype, "ntfs-3g") ||
!strcmp(vol->fstype, "cifs")) eina_streq(vol->fstype, "cifs"))
edje_object_signal_emit(o, "icon,tag,fat", "places"); edje_object_signal_emit(o, "icon,tag,fat", "places");
else if (!strcmp(vol->fstype, "hfs") || else if (eina_streq(vol->fstype, "hfs") ||
!strcmp(vol->fstype, "hfsplus")) eina_streq(vol->fstype, "hfsplus"))
edje_object_signal_emit(o, "icon,tag,hfs", "places"); edje_object_signal_emit(o, "icon,tag,hfs", "places");
else if (!strcmp(vol->fstype, "udf")) else if (eina_streq(vol->fstype, "udf"))
edje_object_signal_emit(o, "icon,tag,dvd", "places"); edje_object_signal_emit(o, "icon,tag,dvd", "places");
// update labels, gauge and button // update labels, gauge and button
@ -507,7 +507,7 @@ places_volume_mount(Volume *vol)
if (!vol || !vol->mount_func || vol->mounted) if (!vol || !vol->mount_func || vol->mounted)
return; return;
if ((!strcmp(vol->fstype, "vfat")) || (!strcmp(vol->fstype, "ntfs"))) if ((eina_streq(vol->fstype, "vfat")) || (eina_streq(vol->fstype, "ntfs")))
{ {
snprintf(buf, sizeof(buf), "uid=%i", (int)getuid()); snprintf(buf, sizeof(buf), "uid=%i", (int)getuid());
opts = eina_list_append(opts, buf); opts = eina_list_append(opts, buf);
@ -772,7 +772,7 @@ _places_volume_object_update(Volume *vol, Evas_Object *obj)
// printf("PLACES: Object update for vol %s\n", vol->id); // printf("PLACES: Object update for vol %s\n", vol->id);
// the volume label // the volume label
if (vol->mount_point && !strcmp(vol->mount_point, "/")) if (eina_streq(vol->mount_point, "/"))
edje_object_part_text_set(obj, "volume_label", D_("Filesystem")); edje_object_part_text_set(obj, "volume_label", D_("Filesystem"));
else if (vol->label && vol->label[0]) else if (vol->label && vol->label[0])
edje_object_part_text_set(obj, "volume_label", vol->label); edje_object_part_text_set(obj, "volume_label", vol->label);
@ -815,7 +815,7 @@ _places_volume_object_update(Volume *vol, Evas_Object *obj)
// the mount/eject icon // the mount/eject icon
if (vol->mounted && vol->mount_point && vol->unmount_func && if (vol->mounted && vol->mount_point && vol->unmount_func &&
strcmp(vol->mount_point, "/")) !eina_streq(vol->mount_point, "/"))
{ {
edje_object_signal_emit(obj, "icon,eject,show", "places"); edje_object_signal_emit(obj, "icon,eject,show", "places");
edje_object_part_text_set(obj, "eject_label", D_("unmount")); edje_object_part_text_set(obj, "eject_label", D_("unmount"));
@ -998,7 +998,7 @@ places_generate_menu(void *data, E_Menu *em)
EINA_LIST_FOREACH(volumes, l, vol) EINA_LIST_FOREACH(volumes, l, vol)
{ {
if (!vol->valid) continue; if (!vol->valid) continue;
if (vol->mount_point && !strcmp(vol->mount_point, "/")) continue; if (eina_streq(vol->mount_point, "/")) continue;
mi = e_menu_item_new(em); mi = e_menu_item_new(em);
if ((vol->label) && (vol->label[0] != '\0')) if ((vol->label) && (vol->label[0] != '\0'))