From e5954aca8eadfb628c5689812f22e0d6aed41908 Mon Sep 17 00:00:00 2001 From: Arti Trivedi Bora Date: Wed, 6 Jun 2012 01:28:13 +0530 Subject: modules: Use pa_streq instead of strcmp. --- src/modules/alsa/alsa-mixer.c | 12 ++++++------ src/modules/bluetooth/module-bluetooth-proximity.c | 2 +- src/modules/dbus/module-dbus-protocol.c | 6 +++--- src/modules/gconf/module-gconf.c | 4 ++-- src/modules/jack/module-jackdbus-detect.c | 2 +- src/modules/macosx/module-coreaudio-detect.c | 2 +- src/modules/module-augment-properties.c | 4 ++-- src/modules/module-detect.c | 2 +- src/modules/module-device-manager.c | 12 ++++++------ src/modules/module-ladspa-sink.c | 6 +++--- src/modules/module-tunnel.c | 4 ++-- src/modules/module-zeroconf-discover.c | 10 +++++----- src/modules/oss/oss-util.c | 2 +- src/modules/raop/module-raop-discover.c | 2 +- src/modules/raop/raop_client.c | 4 ++-- src/modules/rtp/rtp.c | 8 ++++---- src/modules/rtp/rtsp_client.c | 2 +- src/modules/rtp/sap.c | 2 +- src/modules/x11/module-x11-publish.c | 4 ++-- 19 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 260573c4..1b2207bc 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -2207,22 +2207,22 @@ static int jack_parse_state( return -1; } - if (!strcmp(rvalue,"yes")) + if (pa_streq(rvalue, "yes")) pa = PA_PORT_AVAILABLE_YES; - else if (!strcmp(rvalue,"no")) + else if (pa_streq(rvalue, "no")) pa = PA_PORT_AVAILABLE_NO; - else if (!strcmp(rvalue,"unknown")) + else if (pa_streq(rvalue, "unknown")) pa = PA_PORT_AVAILABLE_UNKNOWN; else { pa_log("[%s:%u] state must be 'yes','no' or 'unknown' in '%s'", filename, line, section); return -1; } - if (!strcmp(lvalue, "state.unplugged")) + if (pa_streq(lvalue, "state.unplugged")) j->state_unplugged = pa; else { j->state_plugged = pa; - pa_assert(!strcmp(lvalue, "state.plugged")); + pa_assert(pa_streq(lvalue, "state.plugged")); } return 0; @@ -3183,7 +3183,7 @@ static void path_set_condense(pa_alsa_path_set *ps, snd_mixer_t *m) { continue; PA_LLIST_FOREACH(jb, p2->jacks) { - if (jb->has_control && !strcmp(jb->alsa_name, ja->alsa_name) && + if (jb->has_control && pa_streq(jb->alsa_name, ja->alsa_name) && (ja->state_plugged == jb->state_plugged) && (ja->state_unplugged == jb->state_unplugged)) { exists = TRUE; diff --git a/src/modules/bluetooth/module-bluetooth-proximity.c b/src/modules/bluetooth/module-bluetooth-proximity.c index 3247017c..7d69e824 100644 --- a/src/modules/bluetooth/module-bluetooth-proximity.c +++ b/src/modules/bluetooth/module-bluetooth-proximity.c @@ -228,7 +228,7 @@ static struct bonding* bonding_new(struct userdata *u, const char *a) { goto fail; } - if (strcmp(class, "phone")) { + if (!pa_streq(class, "phone")) { pa_log_info("Found device '%s' of class '%s', ignoring.", a, class); goto fail; } diff --git a/src/modules/dbus/module-dbus-protocol.c b/src/modules/dbus/module-dbus-protocol.c index c24e1e0e..f81c254c 100644 --- a/src/modules/dbus/module-dbus-protocol.c +++ b/src/modules/dbus/module-dbus-protocol.c @@ -491,13 +491,13 @@ static int get_access_arg(pa_modargs *ma, pa_bool_t *local_access, pa_bool_t *re if (!(value = pa_modargs_get_value(ma, "access", NULL))) return 0; - if (!strcmp(value, "local")) { + if (pa_streq(value, "local")) { *local_access = TRUE; *remote_access = FALSE; - } else if (!strcmp(value, "remote")) { + } else if (pa_streq(value, "remote")) { *local_access = FALSE; *remote_access = TRUE; - } else if (!strcmp(value, "local,remote")) { + } else if (pa_streq(value, "local,remote")) { *local_access = TRUE; *remote_access = TRUE; } else diff --git a/src/modules/gconf/module-gconf.c b/src/modules/gconf/module-gconf.c index 3bad9113..c951d903 100644 --- a/src/modules/gconf/module-gconf.c +++ b/src/modules/gconf/module-gconf.c @@ -173,8 +173,8 @@ static void load_module( if (!is_new) { if (m->items[i].index != PA_INVALID_INDEX && - strcmp(m->items[i].name, name) == 0 && - strcmp(m->items[i].args, args) == 0) + pa_streq(m->items[i].name, name) && + pa_streq(m->items[i].args, args)) return; unload_one_module(u, m, i); diff --git a/src/modules/jack/module-jackdbus-detect.c b/src/modules/jack/module-jackdbus-detect.c index 41933c7e..10408ea3 100644 --- a/src/modules/jack/module-jackdbus-detect.c +++ b/src/modules/jack/module-jackdbus-detect.c @@ -186,7 +186,7 @@ static DBusHandlerResult dbus_filter_handler(DBusConnection *c, DBusMessage *s, DBUS_TYPE_STRING, &new, DBUS_TYPE_INVALID)) goto finish; - if (strcmp(name, JACK_SERVICE_NAME)) + if (!pa_streq(name, JACK_SERVICE_NAME)) goto finish; ensure_ports_stopped(u); diff --git a/src/modules/macosx/module-coreaudio-detect.c b/src/modules/macosx/module-coreaudio-detect.c index f4f2ee28..4652e6fb 100644 --- a/src/modules/macosx/module-coreaudio-detect.c +++ b/src/modules/macosx/module-coreaudio-detect.c @@ -85,7 +85,7 @@ static int ca_device_added(struct pa_module *m, AudioObjectID id) { size = sizeof(tmp); err = AudioObjectGetPropertyData(id, &property_address, 0, NULL, &size, tmp); - if (!err && strcmp(tmp, "pulseaudio.org") == 0) + if (!err && pa_streq(tmp, "pulseaudio.org")) return 0; if (u->ioproc_frames) diff --git a/src/modules/module-augment-properties.c b/src/modules/module-augment-properties.c index 05f6f0a4..f280eaef 100644 --- a/src/modules/module-augment-properties.c +++ b/src/modules/module-augment-properties.c @@ -183,8 +183,8 @@ static void update_rule(struct rule *r) { if ((desktopfiles_dir = opendir(DESKTOPFILEDIR))) { while ((dir = readdir(desktopfiles_dir))) { if (dir->d_type != DT_DIR - || strcmp(dir->d_name, ".") == 0 - || strcmp(dir->d_name, "..") == 0) + || pa_streq(dir->d_name, ".") + || pa_streq(dir->d_name, "..")) continue; pa_xfree(fn); diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index bb4994c6..a16f7fe1 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -142,7 +142,7 @@ static int detect_oss(pa_core *c, int just_one) { line[strcspn(line, "\r\n")] = 0; if (!b) { - b = strcmp(line, "Audio devices:") == 0 || strcmp(line, "Installed devices:") == 0; + b = pa_streq(line, "Audio devices:") || pa_streq(line, "Installed devices:"); continue; } diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c index fe48d4fa..12eddec8 100644 --- a/src/modules/module-device-manager.c +++ b/src/modules/module-device-manager.c @@ -537,7 +537,7 @@ static uint32_t get_role_index(const char* role) { pa_assert(role); for (uint32_t i = ROLE_NONE; i < NUM_ROLES; ++i) - if (strcmp(role, role_names[i]) == 0) + if (pa_streq(role, role_names[i])) return i; return PA_INVALID_INDEX; @@ -551,7 +551,7 @@ static void update_highest_priority_device_indexes(struct userdata *u, const cha pa_assert(u); pa_assert(prefix); - sink_mode = (strcmp(prefix, "sink:") == 0); + sink_mode = pa_streq(prefix, "sink:"); if (sink_mode) indexes = &u->preferred_sinks; @@ -592,7 +592,7 @@ static void update_highest_priority_device_indexes(struct userdata *u, const cha PA_IDXSET_FOREACH(sink, u->core->sinks, idx) { if ((pa_sink*) ignore_device == sink) continue; - if (strcmp(sink->name, device_name) == 0) { + if (pa_streq(sink->name, device_name)) { found = TRUE; idx = sink->index; /* Is this needed? */ break; @@ -604,7 +604,7 @@ static void update_highest_priority_device_indexes(struct userdata *u, const cha PA_IDXSET_FOREACH(source, u->core->sources, idx) { if ((pa_source*) ignore_device == source) continue; - if (strcmp(source->name, device_name) == 0) { + if (pa_streq(source->name, device_name)) { found = TRUE; idx = source->index; /* Is this needed? */ break; @@ -1159,7 +1159,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio if ((device_name = get_name(name, "sink:"))) { pa_sink* s; PA_IDXSET_FOREACH(s, u->core->sinks, idx) { - if (strcmp(s->name, device_name) == 0) { + if (pa_streq(s->name, device_name)) { found_index = s->index; break; } @@ -1168,7 +1168,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio } else if ((device_name = get_name(name, "source:"))) { pa_source* s; PA_IDXSET_FOREACH(s, u->core->sources, idx) { - if (strcmp(s->name, device_name) == 0) { + if (pa_streq(s->name, device_name)) { found_index = s->index; break; } diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c index be05715d..500f8f68 100644 --- a/src/modules/module-ladspa-sink.c +++ b/src/modules/module-ladspa-sink.c @@ -562,7 +562,7 @@ int pa__init(pa_module*m) { goto fail; } - if (strcmp(d->Label, label) == 0) + if (pa_streq(d->Label, label)) break; } @@ -627,7 +627,7 @@ int pa__init(pa_module*m) { for (p = 0; p < d->PortCount; p++) { - if (strcmp(d->PortNames[p], pname) == 0) { + if (pa_streq(d->PortNames[p], pname)) { if (LADSPA_IS_PORT_AUDIO(d->PortDescriptors[p]) && LADSPA_IS_PORT_INPUT(d->PortDescriptors[p])) { input_ladspaport[c] = p; } else { @@ -653,7 +653,7 @@ int pa__init(pa_module*m) { goto fail; } for (p = 0; p < d->PortCount; p++) { - if (strcmp(d->PortNames[p], pname) == 0) { + if (pa_streq(d->PortNames[p], pname)) { if (LADSPA_IS_PORT_AUDIO(d->PortDescriptors[p]) && LADSPA_IS_PORT_OUTPUT(d->PortDescriptors[p])) { output_ladspaport[c] = p; } else { diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index 554eecf6..e336d154 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -1136,7 +1136,7 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t pa_proplist_free(pl); - if (!u->sink_name || strcmp(name, u->sink_name)) + if (!u->sink_name || !pa_streq(name, u->sink_name)) return; pa_xfree(u->device_description); @@ -1347,7 +1347,7 @@ static void source_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa pa_proplist_free(pl); - if (!u->source_name || strcmp(name, u->source_name)) + if (!u->source_name || !pa_streq(name, u->source_name)) return; pa_xfree(u->device_description); diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c index cd076aab..b17f6e5c 100644 --- a/src/modules/module-zeroconf-discover.c +++ b/src/modules/module-zeroconf-discover.c @@ -163,17 +163,17 @@ static void resolver_cb( char *key, *value; pa_assert_se(avahi_string_list_get_pair(l, &key, &value, NULL) == 0); - if (strcmp(key, "device") == 0) { + if (pa_streq(key, "device")) { pa_xfree(device); device = value; value = NULL; - } else if (strcmp(key, "rate") == 0) + } else if (pa_streq(key, "rate")) ss.rate = (uint32_t) atoi(value); - else if (strcmp(key, "channels") == 0) + else if (pa_streq(key, "channels")) ss.channels = (uint8_t) atoi(value); - else if (strcmp(key, "format") == 0) + else if (pa_streq(key, "format")) ss.format = pa_parse_sample_format(value); - else if (strcmp(key, "channel_map") == 0) { + else if (pa_streq(key, "channel_map")) { pa_channel_map_parse(&cm, value); channel_map_set = TRUE; } diff --git a/src/modules/oss/oss-util.c b/src/modules/oss/oss-util.c index 9412a87f..3c7f0eb3 100644 --- a/src/modules/oss/oss-util.c +++ b/src/modules/oss/oss-util.c @@ -359,7 +359,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) { line[strcspn(line, "\r\n")] = 0; if (!b) { - b = strcmp(line, "Audio devices:") == 0; + b = pa_streq(line, "Audio devices:"); continue; } diff --git a/src/modules/raop/module-raop-discover.c b/src/modules/raop/module-raop-discover.c index 4ebe5fc7..7499f634 100644 --- a/src/modules/raop/module-raop-discover.c +++ b/src/modules/raop/module-raop-discover.c @@ -166,7 +166,7 @@ static void resolver_cb( pa_assert_se(avahi_string_list_get_pair(l, &key, &value, NULL) == 0); pa_log_debug("Found key: '%s' with value: '%s'", key, value); - if (strcmp(key, "device") == 0) { + if (pa_streq(key, "device")) { pa_xfree(device); device = value; value = NULL; diff --git a/src/modules/raop/raop_client.c b/src/modules/raop/raop_client.c index bbbce5be..b11cafba 100644 --- a/src/modules/raop/raop_client.c +++ b/src/modules/raop/raop_client.c @@ -303,11 +303,11 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he while ((token = pa_split(aj, delimiters, &token_state))) { if ((pc = strstr(token, "="))) { *pc = 0; - if (!strcmp(token, "type") && !strcmp(pc+1, "digital")) { + if (pa_streq(token, "type") && pa_streq(pc+1, "digital")) { c->jack_type = JACK_TYPE_DIGITAL; } } else { - if (!strcmp(token,"connected")) + if (pa_streq(token, "connected")) c->jack_status = JACK_STATUS_CONNECTED; } pa_xfree(token); diff --git a/src/modules/rtp/rtp.c b/src/modules/rtp/rtp.c index 178717c1..04e756d4 100644 --- a/src/modules/rtp/rtp.c +++ b/src/modules/rtp/rtp.c @@ -398,13 +398,13 @@ const char* pa_rtp_format_to_string(pa_sample_format_t f) { pa_sample_format_t pa_rtp_string_to_format(const char *s) { pa_assert(s); - if (!(strcmp(s, "L16"))) + if (pa_streq(s, "L16")) return PA_SAMPLE_S16BE; - else if (!strcmp(s, "L8")) + else if (pa_streq(s, "L8")) return PA_SAMPLE_U8; - else if (!strcmp(s, "PCMA")) + else if (pa_streq(s, "PCMA")) return PA_SAMPLE_ALAW; - else if (!strcmp(s, "PCMU")) + else if (pa_streq(s, "PCMU")) return PA_SAMPLE_ULAW; else return PA_SAMPLE_INVALID; diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c index 71692c2c..2c8b2dcf 100644 --- a/src/modules/rtp/rtsp_client.c +++ b/src/modules/rtp/rtsp_client.c @@ -187,7 +187,7 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) { *s2p = '\0'; s2p -= 1; } - if (c->waiting && 0 == strcmp("RTSP/1.0 200 OK", s2)) { + if (c->waiting && pa_streq(s2, "RTSP/1.0 200 OK")) { c->waiting = 0; if (c->response_headers) pa_headerlist_free(c->response_headers); diff --git a/src/modules/rtp/sap.c b/src/modules/rtp/sap.c index 4d8bf668..f02d53fb 100644 --- a/src/modules/rtp/sap.c +++ b/src/modules/rtp/sap.c @@ -212,7 +212,7 @@ int pa_sap_recv(pa_sap_context *c, pa_bool_t *goodbye) { e = buf + k; size -= (int) k; - if ((unsigned) size >= sizeof(MIME_TYPE) && !strcmp(e, MIME_TYPE)) { + if ((unsigned) size >= sizeof(MIME_TYPE) && pa_streq(e, MIME_TYPE)) { e += sizeof(MIME_TYPE); size -= (int) sizeof(MIME_TYPE); } else if ((unsigned) size < sizeof(PA_SDP_HEADER)-1 || strncmp(e, PA_SDP_HEADER, sizeof(PA_SDP_HEADER)-1)) { diff --git a/src/modules/x11/module-x11-publish.c b/src/modules/x11/module-x11-publish.c index 643b735e..16ea977e 100644 --- a/src/modules/x11/module-x11-publish.c +++ b/src/modules/x11/module-x11-publish.c @@ -103,7 +103,7 @@ static pa_hook_result_t servers_changed_cb(void *hook_data, void *call_data, voi pa_assert(u); screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper)); - if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) { + if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || !pa_streq(t, u->id)) { pa_log_warn("PulseAudio information vanished from X11!"); return PA_HOOK_OK; } @@ -217,7 +217,7 @@ void pa__done(pa_module*m) { int screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper)); /* Yes, here is a race condition */ - if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) + if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || !pa_streq(t, u->id)) pa_log_warn("PulseAudio information vanished from X11!"); else { pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID"); -- cgit v1.2.3