pulsecore: Use pa_streq instead of strcmp.

This commit is contained in:
Arti Trivedi Bora 2012-06-06 01:28:14 +05:30 committed by Tanu Kaskinen
parent e5954aca8e
commit 96a52257a9
8 changed files with 27 additions and 22 deletions

View file

@ -168,7 +168,7 @@ char *pa_win32_get_toplevel(HANDLE handle) {
*p = '\0';
p = strrchr(toplevel, PA_PATH_SEP_CHAR);
if (p && (strcmp(p + 1, "bin") == 0))
if (p && pa_streq(p + 1, "bin"))
*p = '\0';
}
@ -892,9 +892,9 @@ int pa_parse_boolean(const char *v) {
pa_assert(v);
/* First we check language independent */
if (!strcmp(v, "1") || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T' || !strcasecmp(v, "on"))
if (pa_streq(v, "1") || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T' || !strcasecmp(v, "on"))
return 1;
else if (!strcmp(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || !strcasecmp(v, "off"))
else if (pa_streq(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || !strcasecmp(v, "off"))
return 0;
#ifdef HAVE_LANGINFO_H
@ -1100,7 +1100,7 @@ static int is_group(gid_t gid, const char *name) {
goto finish;
}
r = strcmp(name, group->gr_name) == 0;
r = pa_streq(name, group->gr_name);
finish:
pa_getgrgid_free(group);
@ -1998,7 +1998,7 @@ pa_bool_t pa_endswith(const char *s, const char *sfx) {
l1 = strlen(s);
l2 = strlen(sfx);
return l1 >= l2 && strcmp(s+l1-l2, sfx) == 0;
return l1 >= l2 && pa_streq(s + l1 - l2, sfx);
}
pa_bool_t pa_is_path_absolute(const char *fn) {

View file

@ -110,13 +110,13 @@ pa_bool_t pa_cpu_init_arm(pa_cpu_arm_flag_t *flags) {
char *current;
while ((current = pa_split_spaces(line, &state))) {
if (!strcmp(current, "vfp"))
if (pa_streq(current, "vfp"))
*flags |= PA_CPU_ARM_VFP;
else if (!strcmp(current, "edsp"))
else if (pa_streq(current, "edsp"))
*flags |= PA_CPU_ARM_EDSP;
else if (!strcmp(current, "neon"))
else if (pa_streq(current, "neon"))
*flags |= PA_CPU_ARM_NEON;
else if (!strcmp(current, "vfpv3"))
else if (pa_streq(current, "vfpv3"))
*flags |= PA_CPU_ARM_VFPV3;
pa_xfree(current);

View file

@ -64,7 +64,7 @@ static int add_key_value(pa_modargs *ma, char *key, char *value, const char* con
if (valid_keys) {
const char*const* v;
for (v = valid_keys; *v; v++)
if (strcmp(*v, key) == 0)
if (pa_streq(*v, key))
break;
if (!*v) {

View file

@ -80,7 +80,7 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
/* OK, the module only wants to be loaded once, let's make sure it is */
PA_IDXSET_FOREACH(i, c->modules, idx) {
if (strcmp(name, i->name) == 0) {
if (pa_streq(name, i->name)) {
pa_log("Module \"%s\" should be loaded once at most. Refusing to load.", name);
goto fail;
}

View file

@ -39,7 +39,7 @@
#include <pulsecore/macro.h>
#include <pulsecore/strbuf.h>
#include <pulsecore/remap.h>
#include <pulsecore/core-util.h>
#include "ffmpeg/avcodec.h"
#include "resampler.h"
@ -545,13 +545,13 @@ pa_resample_method_t pa_parse_resample_method(const char *string) {
pa_assert(string);
for (m = 0; m < PA_RESAMPLER_MAX; m++)
if (!strcmp(string, resample_methods[m]))
if (pa_streq(string, resample_methods[m]))
return m;
if (!strcmp(string, "speex-fixed"))
if (pa_streq(string, "speex-fixed"))
return PA_RESAMPLER_SPEEX_FIXED_BASE + 3;
if (!strcmp(string, "speex-float"))
if (pa_streq(string, "speex-float"))
return PA_RESAMPLER_SPEEX_FLOAT_BASE + 3;
return PA_RESAMPLER_INVALID;

View file

@ -35,23 +35,28 @@
#define _GNU_SOURCE
#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <pulsecore/core-util.h>
static pid_t _gettid(void) {
return (pid_t) syscall(SYS_gettid);
}
static int translate_error(const char *name) {
if (strcmp(name, DBUS_ERROR_NO_MEMORY) == 0)
if (pa_streq(name, DBUS_ERROR_NO_MEMORY))
return -ENOMEM;
if (strcmp(name, DBUS_ERROR_SERVICE_UNKNOWN) == 0 ||
strcmp(name, DBUS_ERROR_NAME_HAS_NO_OWNER) == 0)
if (pa_streq(name, DBUS_ERROR_SERVICE_UNKNOWN) ||
pa_streq(name, DBUS_ERROR_NAME_HAS_NO_OWNER))
return -ENOENT;
if (strcmp(name, DBUS_ERROR_ACCESS_DENIED) == 0 ||
strcmp(name, DBUS_ERROR_AUTH_FAILED) == 0)
if (pa_streq(name, DBUS_ERROR_ACCESS_DENIED) ||
pa_streq(name, DBUS_ERROR_AUTH_FAILED))
return -EACCES;
return -EIO;

View file

@ -1124,7 +1124,7 @@ void pa_source_output_set_name(pa_source_output *o, const char *name) {
old = pa_proplist_gets(o->proplist, PA_PROP_MEDIA_NAME);
if (old && name && !strcmp(old, name))
if (old && name && pa_streq(old, name))
return;
if (name)

View file

@ -74,7 +74,7 @@ pa_strlist* pa_strlist_remove(pa_strlist *l, const char *s) {
pa_assert(s);
while (l) {
if (!strcmp(ITEM_TO_TEXT(l), s)) {
if (pa_streq(ITEM_TO_TEXT(l), s)) {
pa_strlist *n = l->next;
if (!prev) {