Make all fopen() calls use O_CLOEXEC

by adding "e" to the mode strings.
This commit is contained in:
Demi Marie Obenour 2022-09-23 10:40:55 -04:00 committed by Wim Taymans
parent 400860f63c
commit bb4f274ae0
10 changed files with 23 additions and 23 deletions

View file

@ -256,7 +256,7 @@ static int check_device_pcm_class(const char *devname)
/* Check device class */
spa_scnprintf(path, sizeof(path), "/sys/class/sound/%s/pcm_class",
devname);
f = fopen(path, "r");
f = fopen(path, "re");
if (f == NULL)
return -errno;
sz = fread(buf, 1, sizeof(buf) - 1, f);
@ -361,7 +361,7 @@ static int check_device_available(struct impl *this, struct device *device, int
spa_scnprintf(path, sizeof(path), "/proc/asound/card%u/%s/%s/status",
(unsigned int)device->id, entry->d_name, entry_pcm->d_name);
f = fopen(path, "r");
f = fopen(path, "re");
if (f == NULL)
goto done;
sz = fread(buf, 1, 6, f);

View file

@ -949,7 +949,7 @@ static int adapter_init_modalias(struct spa_bt_monitor *monitor, struct spa_bt_a
if (str == NULL)
goto fail;
snprintf(path, sizeof(path), "/sys/class/bluetooth/%s/device/modalias", str);
if ((f = fopen(path, "rb")) == NULL) {
if ((f = fopen(path, "rbe")) == NULL) {
res = -errno;
goto fail;
}

View file

@ -357,7 +357,7 @@ impl_init(const struct spa_handle_factory *factory,
if ((str = spa_dict_lookup(info, SPA_KEY_LOG_LEVEL)) != NULL)
this->log.level = atoi(str);
if ((str = spa_dict_lookup(info, SPA_KEY_LOG_FILE)) != NULL) {
this->file = fopen(str, "w");
this->file = fopen(str, "we");
if (this->file == NULL)
fprintf(stderr, "Warning: failed to open file %s: (%m)", str);
else