diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index f81bf298d..5163d4a5e 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -636,7 +636,7 @@ const char * jack_get_version_string(void) { static char name[1024]; - snprintf(name, sizeof(name)-1, "3.0.0.0 (using PipeWire %s)", pw_get_library_version()); + snprintf(name, sizeof(name), "3.0.0.0 (using PipeWire %s)", pw_get_library_version()); return name; } diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c index 0db4eae63..4c3c32d52 100644 --- a/spa/plugins/alsa/alsa-acp-device.c +++ b/spa/plugins/alsa/alsa-acp-device.c @@ -184,7 +184,7 @@ static int emit_node(struct impl *this, struct acp_device *dev) items[2] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PCM_CARD, card_id); items[3] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PCM_STREAM, stream); - snprintf(channels, sizeof(channels)-1, "%d", dev->format.channels); + snprintf(channels, sizeof(channels), "%d", dev->format.channels); items[4] = SPA_DICT_ITEM_INIT(SPA_KEY_AUDIO_CHANNELS, channels); p = positions; @@ -928,7 +928,7 @@ impl_init(const struct spa_handle_factory *factory, if (info) { if ((str = spa_dict_lookup(info, SPA_KEY_API_ALSA_PATH)) != NULL) - snprintf(this->props.device, sizeof(this->props.device)-1, "%s", str); + snprintf(this->props.device, sizeof(this->props.device), "%s", str); if ((str = spa_dict_lookup(info, "api.acp.auto-port")) != NULL) this->props.auto_port = strcmp(str, "true") == 0 || atoi(str) != 0; if ((str = spa_dict_lookup(info, "api.acp.auto-profile")) != NULL) diff --git a/spa/plugins/alsa/alsa-udev.c b/spa/plugins/alsa/alsa-udev.c index 878b5a337..b378ff19d 100644 --- a/spa/plugins/alsa/alsa-udev.c +++ b/spa/plugins/alsa/alsa-udev.c @@ -376,7 +376,7 @@ static bool check_access(struct impl *this, struct device *device) { char path[128]; - snprintf(path, sizeof(path)-1, "/dev/snd/controlC%u", device->id); + snprintf(path, sizeof(path), "/dev/snd/controlC%u", device->id); device->accessible = access(path, R_OK|W_OK) >= 0; spa_log_debug(this->log, "%s accessible:%u", path, device->accessible); diff --git a/spa/plugins/v4l2/v4l2-udev.c b/spa/plugins/v4l2/v4l2-udev.c index eb65ab6cd..874a9074d 100644 --- a/spa/plugins/v4l2/v4l2-udev.c +++ b/spa/plugins/v4l2/v4l2-udev.c @@ -323,7 +323,7 @@ static bool check_access(struct impl *this, struct device *device) { char path[128]; - snprintf(path, sizeof(path)-1, "/dev/video%u", device->id); + snprintf(path, sizeof(path), "/dev/video%u", device->id); device->accessible = access(path, R_OK|W_OK) >= 0; spa_log_debug(this->log, "%s accessible:%u", path, device->accessible); diff --git a/src/examples/media-session/default-nodes.c b/src/examples/media-session/default-nodes.c index 7876d529c..5ef7410d8 100644 --- a/src/examples/media-session/default-nodes.c +++ b/src/examples/media-session/default-nodes.c @@ -221,7 +221,7 @@ static void session_create(void *data, struct sm_object *object) d = (struct find_data){ impl, name, SPA_ID_INVALID }; if (find_name(&d, object)) { char val[16]; - snprintf(val, sizeof(val)-1, "%u", d.id); + snprintf(val, sizeof(val), "%u", d.id); pw_log_info("found %s with id:%s restore as %s", name, val, item->key); pw_metadata_set_property(impl->session->metadata, diff --git a/src/examples/media-session/default-routes.c b/src/examples/media-session/default-routes.c index 0f0235cff..dcce2a984 100644 --- a/src/examples/media-session/default-routes.c +++ b/src/examples/media-session/default-routes.c @@ -433,7 +433,7 @@ static int restore_route(struct device *dev, struct route *r, bool save) if ((ri = find_route_info(dev, r)) == NULL) return -errno; - snprintf(key, sizeof(key)-1, PREFIX"%s:%s:%s", dev->name, + snprintf(key, sizeof(key), PREFIX"%s:%s:%s", dev->name, r->direction == SPA_DIRECTION_INPUT ? "input" : "output", r->name); val = pw_properties_get(impl->to_restore, key); @@ -458,7 +458,7 @@ static int save_route(struct device *dev, struct route *r) if (r->props == NULL) return -EINVAL; - snprintf(key, sizeof(key)-1, PREFIX"%s:%s:%s", dev->name, + snprintf(key, sizeof(key), PREFIX"%s:%s:%s", dev->name, r->direction == SPA_DIRECTION_INPUT ? "input" : "output", r->name); val = serialize_props(dev, r->props); @@ -499,7 +499,7 @@ static int save_profile(struct device *dev) if (pw_array_get_len(&dev->route_info, struct route_info) == 0) return 0; - snprintf(key, sizeof(key)-1, PREFIX"%s:profile:%s", dev->name, dev->profile_name); + snprintf(key, sizeof(key), PREFIX"%s:profile:%s", dev->name, dev->profile_name); val = serialize_routes(dev); if (pw_properties_set(impl->to_restore, key, val)) { @@ -626,7 +626,7 @@ static int handle_profile(struct device *dev) dev->active_profile = pr.index; snprintf(dev->profile_name, sizeof(dev->profile_name), "%s", pr.name); - snprintf(key, sizeof(key)-1, PREFIX"%s:profile:%s", dev->name, dev->profile_name); + snprintf(key, sizeof(key), PREFIX"%s:profile:%s", dev->name, dev->profile_name); json = pw_properties_get(impl->to_restore, key); if (pr.classes != NULL) { @@ -724,7 +724,7 @@ static int handle_route(struct device *dev, struct route *r) if (r == NULL) return -EIO; - snprintf(key, sizeof(key)-1, PREFIX"%s:%s:%s", dev->name, + snprintf(key, sizeof(key), PREFIX"%s:%s:%s", dev->name, r->direction == SPA_DIRECTION_INPUT ? "input" : "output", r->name); if (restore) { diff --git a/src/examples/media-session/media-session.c b/src/examples/media-session/media-session.c index 75cccbd51..2b1723acf 100644 --- a/src/examples/media-session/media-session.c +++ b/src/examples/media-session/media-session.c @@ -1798,7 +1798,7 @@ int sm_media_session_load_conf(struct sm_media_session *sess, const char *name, if (dir == NULL) return -ENOENT; - snprintf(path, sizeof(path)-1, "%s/media-session.d/%s", dir, name); + snprintf(path, sizeof(path), "%s/media-session.d/%s", dir, name); if ((fd = open(path, O_CLOEXEC | O_RDONLY)) < 0) { pw_log_warn(NAME" %p: error loading config '%s': %m", sess, path); return -errno; @@ -1833,7 +1833,7 @@ static int state_dir(struct sm_media_session *sess) home_dir = getenv("XDG_CONFIG_HOME"); if (home_dir != NULL) - snprintf(impl->state_dir, sizeof(impl->state_dir)-1, + snprintf(impl->state_dir, sizeof(impl->state_dir), "%s/pipewire-media-session/", home_dir); else { home_dir = getenv("HOME"); @@ -1849,7 +1849,7 @@ static int state_dir(struct sm_media_session *sess) pw_log_error("Can't determine home directory"); return -ENOTSUP; } - snprintf(impl->state_dir, sizeof(impl->state_dir)-1, + snprintf(impl->state_dir, sizeof(impl->state_dir), "%s/.config/pipewire-media-session/", home_dir); } diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index 97c7fa67e..307d3929c 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -128,7 +128,7 @@ static void node_port_init(void *data, struct pw_impl_port *port) if ((str = pw_properties_get(old, PW_KEY_AUDIO_CHANNEL)) == NULL || strcmp(str, "UNK") == 0) { - snprintf(position, sizeof(position)-1, "%d", pw_impl_port_get_id(port)); + snprintf(position, sizeof(position), "%d", pw_impl_port_get_id(port)); str = position; } if (direction == n->direction) { diff --git a/src/modules/module-protocol-pulse/manager.c b/src/modules/module-protocol-pulse/manager.c index c3da55ff2..c4942aab4 100644 --- a/src/modules/module-protocol-pulse/manager.c +++ b/src/modules/module-protocol-pulse/manager.c @@ -691,7 +691,7 @@ int pw_manager_set_metadata(struct pw_manager *manager, if (type != NULL) { va_start(args, format); - vsnprintf(buf, sizeof(buf)-1, format, args); + vsnprintf(buf, sizeof(buf), format, args); va_end(args); value = buf; } else { diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index bb384199f..661400353 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1109,11 +1109,11 @@ static int reply_create_playback_stream(struct stream *stream) lat.denom = stream->ss.rate; lat_usec = lat.num * SPA_USEC_PER_SEC / lat.denom; - snprintf(latency, sizeof(latency)-1, "%u/%u", lat.num, lat.denom); - snprintf(attr_maxlength, sizeof(attr_maxlength)-1, "%u", stream->attr.maxlength); - snprintf(attr_tlength, sizeof(attr_tlength)-1, "%u", stream->attr.tlength); - snprintf(attr_prebuf, sizeof(attr_prebuf)-1, "%u", stream->attr.prebuf); - snprintf(attr_minreq, sizeof(attr_minreq)-1, "%u", stream->attr.minreq); + snprintf(latency, sizeof(latency), "%u/%u", lat.num, lat.denom); + snprintf(attr_maxlength, sizeof(attr_maxlength), "%u", stream->attr.maxlength); + snprintf(attr_tlength, sizeof(attr_tlength), "%u", stream->attr.tlength); + snprintf(attr_prebuf, sizeof(attr_prebuf), "%u", stream->attr.prebuf); + snprintf(attr_minreq, sizeof(attr_minreq), "%u", stream->attr.minreq); items[0] = SPA_DICT_ITEM_INIT(PW_KEY_NODE_LATENCY, latency); items[1] = SPA_DICT_ITEM_INIT("pulse.attr.maxlength", attr_maxlength); @@ -1241,7 +1241,7 @@ static int reply_create_record_stream(struct stream *stream) lat.denom = stream->ss.rate; lat_usec = lat.num * SPA_USEC_PER_SEC / lat.denom; - snprintf(latency, sizeof(latency)-1, "%u/%u", lat.num, lat.denom); + snprintf(latency, sizeof(latency), "%u/%u", lat.num, lat.denom); items[0] = SPA_DICT_ITEM_INIT(PW_KEY_NODE_LATENCY, latency); items[1] = SPA_DICT_ITEM_INIT("pulse.attr.maxlength", attr_maxlength); @@ -3293,7 +3293,7 @@ static int do_get_server_info(struct client *client, uint32_t command, uint32_t cookie = 0; } - snprintf(name, sizeof(name)-1, "PulseAudio (on PipeWire %s)", pw_get_library_version()); + snprintf(name, sizeof(name), "PulseAudio (on PipeWire %s)", pw_get_library_version()); reply = reply_new(client, tag); message_put(reply, @@ -5302,7 +5302,7 @@ get_runtime_dir(char *buf, size_t buflen, const char *dir) if (getpwuid_r(getuid(), &pwd, buffer, sizeof(buffer), &result) == 0) runtime_dir = result ? result->pw_dir : NULL; } - size = snprintf(buf, buflen-1, "%s/%s", runtime_dir, dir) + 1; + size = snprintf(buf, buflen, "%s/%s", runtime_dir, dir) + 1; if (size > (int) buflen) { pw_log_error(NAME": path %s/%s too long", runtime_dir, dir); return -ENAMETOOLONG; diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index f56ae7a8f..e04671b0e 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -540,7 +540,7 @@ const char *pw_get_prgname(void) return prgname; } #endif - snprintf(prgname, sizeof(prgname)-1, "pid-%d", getpid()); + snprintf(prgname, sizeof(prgname), "pid-%d", getpid()); return prgname; } diff --git a/src/tools/pw-dump.c b/src/tools/pw-dump.c index db4aa54da..deb149639 100644 --- a/src/tools/pw-dump.c +++ b/src/tools/pw-dump.c @@ -306,7 +306,7 @@ static void put_pod_value(struct data *d, const char *key, const struct spa_type uint32_t id = *(uint32_t*)body; str = spa_debug_type_find_short_name(info, *(uint32_t*)body); if (str == NULL) { - snprintf(fallback, sizeof(fallback)-1, "id-%08x", id); + snprintf(fallback, sizeof(fallback), "id-%08x", id); str = fallback; } put_value(d, NULL, str); diff --git a/src/tools/pw-top.c b/src/tools/pw-top.c index 08c202497..4ef31ca98 100644 --- a/src/tools/pw-top.c +++ b/src/tools/pw-top.c @@ -139,7 +139,7 @@ static struct node *add_node(struct data *d, uint32_t id, const char *name) if (name) strncpy(n->name, name, MAX_NAME-1); else - snprintf(n->name, sizeof(n->name)-1, "%u", id); + snprintf(n->name, sizeof(n->name), "%u", id); n->id = id; n->driver = n; spa_list_append(&d->node_list, &n->link);