[pulseaudio-discuss] [PATCH 2/4] pulsecore: use pa_streq instead of strcmp
Arti Trivedi Bora
tbaarti at gmail.com
Tue Jun 5 12:58:14 PDT 2012
---
src/pulsecore/core-util.c | 10 +++++-----
src/pulsecore/cpu-arm.c | 8 ++++----
src/pulsecore/modargs.c | 2 +-
src/pulsecore/module.c | 2 +-
src/pulsecore/resampler.c | 8 ++++----
src/pulsecore/rtkit.c | 15 ++++++++++-----
src/pulsecore/source-output.c | 2 +-
src/pulsecore/strlist.c | 2 +-
8 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 82480c6..1256861 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -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) {
diff --git a/src/pulsecore/cpu-arm.c b/src/pulsecore/cpu-arm.c
index 9c654a3..a724309 100644
--- a/src/pulsecore/cpu-arm.c
+++ b/src/pulsecore/cpu-arm.c
@@ -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);
diff --git a/src/pulsecore/modargs.c b/src/pulsecore/modargs.c
index 555c4d0..58a7045 100644
--- a/src/pulsecore/modargs.c
+++ b/src/pulsecore/modargs.c
@@ -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) {
diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c
index 5eb3572..bf554af 100644
--- a/src/pulsecore/module.c
+++ b/src/pulsecore/module.c
@@ -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;
}
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index cd95c5b..9f19559 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -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;
diff --git a/src/pulsecore/rtkit.c b/src/pulsecore/rtkit.c
index a7dc3d9..d47610f 100644
--- a/src/pulsecore/rtkit.c
+++ b/src/pulsecore/rtkit.c
@@ -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;
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 844dd22..1297ec7 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -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)
diff --git a/src/pulsecore/strlist.c b/src/pulsecore/strlist.c
index b2ba12b..4c06fee 100644
--- a/src/pulsecore/strlist.c
+++ b/src/pulsecore/strlist.c
@@ -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) {
--
1.7.4.1
More information about the pulseaudio-discuss
mailing list