[PATCH] fwts: treewide: voidify return from close(), closedir() and fclose()
Colin King
colin.king at canonical.com
Tue Sep 6 09:13:59 UTC 2016
From: Colin Ian King <colin.king at canonical.com>
This code style change ensures we use the same idiom across all of
fwts to voidify the integer return from close(), closedir() and fclose().
This is just a cosmetic hint to say we're really ignoring any error
returns from these functions.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/acpi/brightness/brightness-helper.c | 10 +++---
src/acpi/dmar/dmar.c | 2 +-
src/acpi/mcfg/mcfg.c | 2 +-
src/acpica/source/compiler/fwts_iasl_interface.c | 6 ++--
src/bios/hdaaudio/hdaaudio.c | 6 ++--
src/bios/mtrr/mtrr.c | 10 +++---
src/dmi/dmicheck/dmicheck.c | 2 +-
src/hotkey/hotkey/hotkey.c | 10 +++---
src/lib/src/fwts_ac_adapter.c | 2 +-
src/lib/src/fwts_acpi_tables.c | 8 ++---
src/lib/src/fwts_acpid.c | 6 ++--
src/lib/src/fwts_alloc.c | 2 +-
src/lib/src/fwts_battery.c | 40 ++++++++++++------------
src/lib/src/fwts_button.c | 2 +-
src/lib/src/fwts_cpu.c | 6 ++--
src/lib/src/fwts_dump.c | 16 +++++-----
src/lib/src/fwts_efi_module.c | 2 +-
src/lib/src/fwts_fileio.c | 2 +-
src/lib/src/fwts_get.c | 4 +--
src/lib/src/fwts_gpe.c | 4 +--
src/lib/src/fwts_hwinfo.c | 16 +++++-----
src/lib/src/fwts_iasl.c | 4 +--
src/lib/src/fwts_ipmi.c | 10 +++---
src/lib/src/fwts_keymap.c | 4 +--
src/lib/src/fwts_klog.c | 4 +--
src/lib/src/fwts_log.c | 2 +-
src/lib/src/fwts_memorymap.c | 4 +--
src/lib/src/fwts_mmap.c | 2 +-
src/lib/src/fwts_olog.c | 2 +-
src/lib/src/fwts_pipeio.c | 34 ++++++++++----------
src/lib/src/fwts_set.c | 2 +-
src/lib/src/fwts_smbios.c | 2 +-
src/lib/src/fwts_uefi.c | 16 +++++-----
src/opal/mtd_info.c | 14 ++++-----
src/opal/prd_info.c | 4 +--
src/pci/aspm/aspm.c | 4 +--
src/pci/maxreadreq/maxreadreq.c | 6 ++--
37 files changed, 136 insertions(+), 136 deletions(-)
diff --git a/src/acpi/brightness/brightness-helper.c b/src/acpi/brightness/brightness-helper.c
index 26141be..3072db3 100644
--- a/src/acpi/brightness/brightness-helper.c
+++ b/src/acpi/brightness/brightness-helper.c
@@ -92,7 +92,7 @@ int brightness_deinit(fwts_framework *fw)
FWTS_UNUSED(fw);
if (brightness_dir)
- closedir(brightness_dir);
+ (void)closedir(brightness_dir);
brightness_path = NULL;
brightness_dir = NULL;
@@ -114,11 +114,11 @@ int brightness_get_setting(const char *entry_name, const char *setting, int *val
return FWTS_ERROR;
if (fscanf(fp, "%d", value) != 1) {
- fclose(fp);
+ (void)fclose(fp);
return FWTS_ERROR;
}
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
@@ -137,11 +137,11 @@ int brightness_set_setting(const char *entry_name, const char *setting, const in
return FWTS_ERROR;
if (fprintf(fp, "%d", value) < 1) {
- fclose(fp);
+ (void)fclose(fp);
return FWTS_ERROR;
}
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
diff --git a/src/acpi/dmar/dmar.c b/src/acpi/dmar/dmar.c
index 6dbc1f3..655220f 100644
--- a/src/acpi/dmar/dmar.c
+++ b/src/acpi/dmar/dmar.c
@@ -115,7 +115,7 @@ static int read_pci_device_secondary_bus_number(const uint8_t seg,
return -1;
count = fread(configs, sizeof(char), 64, file);
- fclose(file);
+ (void)fclose(file);
if (count < 64)
return -1;
diff --git a/src/acpi/mcfg/mcfg.c b/src/acpi/mcfg/mcfg.c
index 119ba8b..dc94199 100644
--- a/src/acpi/mcfg/mcfg.c
+++ b/src/acpi/mcfg/mcfg.c
@@ -59,7 +59,7 @@ static int compare_config_space(
return FWTS_ERROR;
}
n = fread(config_space, 1, sizeof(config_space), fp);
- fclose(fp);
+ (void)fclose(fp);
if (n != sizeof(config_space)) {
fwts_log_warning(fw, "Could only read %zd bytes from %s, expecting %zd.", n, path, sizeof(config_space));
return FWTS_ERROR;
diff --git a/src/acpica/source/compiler/fwts_iasl_interface.c b/src/acpica/source/compiler/fwts_iasl_interface.c
index 3be4146..b110c10 100644
--- a/src/acpica/source/compiler/fwts_iasl_interface.c
+++ b/src/acpica/source/compiler/fwts_iasl_interface.c
@@ -134,7 +134,7 @@ int fwts_iasl_disassemble_aml(
_exit(1);
}
if ((fperr = freopen("/dev/null", "w", stderr)) == NULL) {
- fclose(fpout);
+ (void)fclose(fpout);
_exit(1);
}
@@ -145,8 +145,8 @@ int fwts_iasl_disassemble_aml(
if (AcpiGbl_ExternalFileList)
AcpiDmClearExternalFileList();
- fclose(fperr);
- fclose(fpout);
+ (void)fclose(fperr);
+ (void)fclose(fpout);
_exit(0);
break;
default:
diff --git a/src/bios/hdaaudio/hdaaudio.c b/src/bios/hdaaudio/hdaaudio.c
index cd943ee..02744f4 100644
--- a/src/bios/hdaaudio/hdaaudio.c
+++ b/src/bios/hdaaudio/hdaaudio.c
@@ -48,14 +48,14 @@ static int hda_audio_read_pins(const char *path, const char *file, fwts_list *se
pin_setting = calloc(1, sizeof(hda_audio_pin_setting));
if (pin_setting == NULL) {
fwts_list_free_items(settings, free);
- fclose(fp);
+ (void)fclose(fp);
return FWTS_ERROR;
}
pin_setting->pin = pin;
pin_setting->setting = setting;
fwts_list_append(settings, pin_setting);
}
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
@@ -172,7 +172,7 @@ static int hda_audio_test1(fwts_framework *fw)
fwts_log_nl(fw);
}
- closedir(dir);
+ (void)closedir(dir);
if (!checked)
fwts_skipped(fw, "Cannot find any BIOS set audio pin configurations.");
diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c
index 08ce90b..887796a 100644
--- a/src/bios/mtrr/mtrr.c
+++ b/src/bios/mtrr/mtrr.c
@@ -103,7 +103,7 @@ static int get_mtrrs(void)
if ((entry = calloc(1, sizeof(struct mtrr_entry))) == NULL) {
fwts_list_free(mtrr_list, free);
- fclose(fp);
+ (void)fclose(fp);
return FWTS_ERROR;
}
@@ -162,7 +162,7 @@ static int get_mtrrs(void)
fwts_list_append(mtrr_list, entry);
}
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
@@ -252,7 +252,7 @@ static int check_prefetchable(
}
n = read(fd, config, sizeof(config));
- close(fd);
+ (void)close(fd);
/* config space too small? ignore for now */
if (n < 64)
@@ -410,7 +410,7 @@ static int validate_iomem(fwts_framework *fw)
/* This has failed, give up at this point */
fwts_skipped(fw,
"Could not guess cache type.");
- fclose(file);
+ (void)fclose(file);
return FWTS_ERROR;
}
@@ -442,7 +442,7 @@ static int validate_iomem(fwts_framework *fw)
}
}
- fclose(file);
+ (void)fclose(file);
if (!failed)
fwts_passed(fw, "Memory ranges seem to have correct attributes.");
diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c
index 65b50b0..51ccd26 100644
--- a/src/dmi/dmicheck/dmicheck.c
+++ b/src/dmi/dmicheck/dmicheck.c
@@ -305,7 +305,7 @@ static int dmi_load_file(const char* filename, void *buf, size_t size)
if ((fd = open(filename, O_RDONLY)) < 0)
return FWTS_ERROR;
ret = read(fd, buf, size);
- close(fd);
+ (void)close(fd);
if (ret != (ssize_t)size)
return FWTS_ERROR;
return FWTS_OK;
diff --git a/src/hotkey/hotkey/hotkey.c b/src/hotkey/hotkey/hotkey.c
index 8a72fec..9bbecd9 100644
--- a/src/hotkey/hotkey/hotkey.c
+++ b/src/hotkey/hotkey/hotkey.c
@@ -84,7 +84,7 @@ static int hotkey_test(fwts_framework *fw, char *dev, fwts_list *hotkeys)
if (ioctl(fd, EVIOCGRAB, (void*)1)) { /* Get focus */
fwts_log_error(fw, "Cannot grab device %s.", path);
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
@@ -104,10 +104,10 @@ static int hotkey_test(fwts_framework *fw, char *dev, fwts_list *hotkeys)
if (ioctl(fd, EVIOCGRAB, (void*)0)) { /* Release */
fwts_log_error(fw, "Cannot un-grab device %s.", path);
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
- close(fd);
+ (void)close(fd);
return FWTS_OK;
}
@@ -130,7 +130,7 @@ static char *hotkey_device(char *path)
break;
}
}
- closedir(scan);
+ (void)closedir(scan);
return dev;
}
@@ -170,7 +170,7 @@ static char *hotkey_find_keyboard(char *path)
}
}
- closedir(dir);
+ (void)closedir(dir);
return dev;
}
diff --git a/src/lib/src/fwts_ac_adapter.c b/src/lib/src/fwts_ac_adapter.c
index 7cc963d..c861907 100644
--- a/src/lib/src/fwts_ac_adapter.c
+++ b/src/lib/src/fwts_ac_adapter.c
@@ -129,7 +129,7 @@ int fwts_ac_adapter_get_state(const int state, int *matching, int *not_matching)
}
} while (entry);
- closedir(ac_power_dir);
+ (void)closedir(ac_power_dir);
return FWTS_OK;
}
diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
index eb1184f..5e0fe1d 100644
--- a/src/lib/src/fwts_acpi_tables.c
+++ b/src/lib/src/fwts_acpi_tables.c
@@ -711,7 +711,7 @@ static int fwts_acpi_load_tables_from_acpidump(fwts_framework *fw)
fwts_acpi_add_table(name, table, addr, length, FWTS_ACPI_TABLE_FROM_FILE);
}
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
@@ -823,12 +823,12 @@ static int fwts_acpi_load_tables_from_file_generic(
if (fstat(fd, &buf) < 0) {
fwts_log_error(fw, "Cannot stat file '%s'\n", path);
- close(fd);
+ (void)close(fd);
continue;
}
/* Must be a regular file */
if (!S_ISREG(buf.st_mode)) {
- close(fd);
+ (void)close(fd);
continue;
}
@@ -871,7 +871,7 @@ static int fwts_acpi_load_tables_from_file_generic(
FWTS_ACPI_TABLE_FROM_FILE);
}
}
- close(fd);
+ (void)close(fd);
} else
fwts_log_error(fw, "Cannot load ACPI table from file '%s'\n", path);
}
diff --git a/src/lib/src/fwts_acpid.c b/src/lib/src/fwts_acpid.c
index 8db16a0..ba4b6cb 100644
--- a/src/lib/src/fwts_acpid.c
+++ b/src/lib/src/fwts_acpid.c
@@ -56,12 +56,12 @@ int fwts_acpi_event_open(void)
strcpy(addr.sun_path, ACPID_SOCKET);
if ((ret = connect(fd, (struct sockaddr *)&addr, sizeof(addr))) < 0) {
- close(fd);
+ (void)close(fd);
return ret;
}
if ((ret = fcntl(fd, F_SETFD, FD_CLOEXEC)) < 0) {
- close(fd);
+ (void)close(fd);
return ret;
}
@@ -129,5 +129,5 @@ char *fwts_acpi_event_read(const int fd, size_t *length, const int timeout)
*/
void fwts_acpi_event_close(const int fd)
{
- close(fd);
+ (void)close(fd);
}
diff --git a/src/lib/src/fwts_alloc.c b/src/lib/src/fwts_alloc.c
index 96e87c6..3c8f727 100644
--- a/src/lib/src/fwts_alloc.c
+++ b/src/lib/src/fwts_alloc.c
@@ -187,7 +187,7 @@ static void *fwts_low_mmap(const size_t requested_size)
last_addr_end = addr_end;
}
- fclose(fp);
+ (void)fclose(fp);
/*
* The "intelligent" memory hole finding strategy failed,
diff --git a/src/lib/src/fwts_battery.c b/src/lib/src/fwts_battery.c
index 65e490c..4becd39 100644
--- a/src/lib/src/fwts_battery.c
+++ b/src/lib/src/fwts_battery.c
@@ -101,7 +101,7 @@ static int fwts_battery_get_capacity_sys_fs(fwts_framework *fw,
(*count)++;
}
}
- fclose(fp);
+ (void)fclose(fp);
}
}
} while (entry);
@@ -169,7 +169,7 @@ static int fwts_battery_get_capacity_proc_fs(fwts_framework *fw,
break;
}
}
- fclose(fp);
+ (void)fclose(fp);
}
}
} while (entry);
@@ -320,7 +320,7 @@ static int fwts_battery_get_cycle_count_sys_fs(
*cycle_count = val;
}
}
- fclose(fp);
+ (void)fclose(fp);
}
}
} while (entry);
@@ -368,7 +368,7 @@ static int fwts_battery_get_cycle_count_proc_fs(
break;
}
}
- fclose(fp);
+ (void)fclose(fp);
}
}
} while (entry);
@@ -413,7 +413,7 @@ static int fwts_battery_set_trip_point_sys_fs(
char buffer[512];
sprintf(buffer, "%d", trip_point * 1000);
fputs(buffer, fp);
- fclose(fp);
+ (void)fclose(fp);
}
}
} while (entry);
@@ -463,7 +463,7 @@ static int fwts_battery_get_trip_point_sys_fs(
sscanf(buffer, "%d", &val);
*trip_point = val / 1000;
}
- fclose(fp);
+ (void)fclose(fp);
}
}
} while (entry);
@@ -498,7 +498,7 @@ static int fwts_battery_set_trip_point_proc_fs(
char buffer[512];
sprintf(buffer, "%d", trip_point);
fputs(buffer, fp);
- fclose(fp);
+ (void)fclose(fp);
}
}
} while (entry);
@@ -541,7 +541,7 @@ static int fwts_battery_get_trip_point_proc_fs(
break;
}
}
- fclose(fp);
+ (void)fclose(fp);
}
}
} while (entry);
@@ -559,10 +559,10 @@ int fwts_battery_set_trip_point(
if ((dir = opendir(FWTS_SYS_CLASS_POWER_SUPPLY)) != NULL) {
ret = fwts_battery_set_trip_point_sys_fs(fw, dir, index, trip_point);
- closedir(dir);
+ (void)closedir(dir);
} else if ((dir = opendir(FWTS_PROC_ACPI_BATTERY)) != NULL) {
ret = fwts_battery_set_trip_point_proc_fs(fw, dir, index, trip_point);
- closedir(dir);
+ (void)closedir(dir);
} else {
return FWTS_ERROR;
}
@@ -579,10 +579,10 @@ int fwts_battery_get_trip_point(
if ((dir = opendir(FWTS_SYS_CLASS_POWER_SUPPLY)) != NULL) {
ret = fwts_battery_get_trip_point_sys_fs(fw, dir, index, trip_point);
- closedir(dir);
+ (void)closedir(dir);
} else if ((dir = opendir(FWTS_PROC_ACPI_BATTERY)) != NULL) {
ret = fwts_battery_get_trip_point_proc_fs(fw, dir, index, trip_point);
- closedir(dir);
+ (void)closedir(dir);
} else {
return FWTS_ERROR;
}
@@ -615,10 +615,10 @@ int fwts_battery_get_cycle_count(
if ((dir = opendir(FWTS_SYS_CLASS_POWER_SUPPLY)) != NULL) {
ret = fwts_battery_get_cycle_count_sys_fs(fw, dir, index, cycle_count);
- closedir(dir);
+ (void)closedir(dir);
} else if ((dir = opendir(FWTS_PROC_ACPI_BATTERY)) != NULL) {
ret = fwts_battery_get_cycle_count_proc_fs(fw, dir, index, cycle_count);
- closedir(dir);
+ (void)closedir(dir);
} else {
return FWTS_ERROR;
}
@@ -638,10 +638,10 @@ int fwts_battery_get_name(
if ((dir = opendir(FWTS_SYS_CLASS_POWER_SUPPLY)) != NULL) {
ret = fwts_battery_get_name_sys_fs(dir, index, name);
- closedir(dir);
+ (void)closedir(dir);
} else if ((dir = opendir(FWTS_PROC_ACPI_BATTERY)) != NULL) {
ret = fwts_battery_get_name_proc_fs(dir, index, name);
- closedir(dir);
+ (void)closedir(dir);
} else {
return FWTS_ERROR;
}
@@ -658,10 +658,10 @@ int fwts_battery_get_count(fwts_framework *fw, int *count)
if ((dir = opendir(FWTS_SYS_CLASS_POWER_SUPPLY)) != NULL) {
ret = fwts_battery_get_count_sys_fs(dir, count);
- closedir(dir);
+ (void)closedir(dir);
} else if ((dir = opendir(FWTS_PROC_ACPI_BATTERY)) != NULL) {
ret = fwts_battery_get_count_proc_fs(dir, count);
- closedir(dir);
+ (void)closedir(dir);
} else {
return FWTS_ERROR;
}
@@ -683,10 +683,10 @@ int fwts_battery_get_capacity(fwts_framework *fw,
if ((dir = opendir(FWTS_SYS_CLASS_POWER_SUPPLY)) != NULL) {
ret = fwts_battery_get_capacity_sys_fs(fw, dir, type, index, capacity_mAh, capacity_mWh, &n);
- closedir(dir);
+ (void)closedir(dir);
} else if ((dir = opendir(FWTS_PROC_ACPI_BATTERY)) != NULL) {
ret = fwts_battery_get_capacity_proc_fs(fw, dir, type, index, capacity_mAh, capacity_mWh, &n);
- closedir(dir);
+ (void)closedir(dir);
} else {
fwts_log_info(fw, "No battery information present: cannot test.");
return FWTS_ERROR;
diff --git a/src/lib/src/fwts_button.c b/src/lib/src/fwts_button.c
index 0cfe894..f3c1caa 100644
--- a/src/lib/src/fwts_button.c
+++ b/src/lib/src/fwts_button.c
@@ -91,7 +91,7 @@ static int fwts_button_match_state_proc(
}
} while (entry);
- closedir(dir);
+ (void)closedir(dir);
return FWTS_OK;
}
diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c
index b28fb59..e4828cb 100644
--- a/src/lib/src/fwts_cpu.c
+++ b/src/lib/src/fwts_cpu.c
@@ -73,7 +73,7 @@ int fwts_cpu_readmsr(const int cpu, const uint32_t reg, uint64_t *val)
}
ret = pread(fd, &value, 8, reg);
- close(fd);
+ (void)close(fd);
*val = value;
@@ -165,7 +165,7 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu)
continue;
}
}
- fclose(fp);
+ (void)fclose(fp);
if (!found) {
free(cpu);
@@ -396,7 +396,7 @@ static int perf_read_counter(int fd, unsigned long long *result)
rc = FWTS_ERROR;
}
- close(fd);
+ (void)close(fd);
return rc;
}
diff --git a/src/lib/src/fwts_dump.c b/src/lib/src/fwts_dump.c
index 3ff888b..86f5f69 100644
--- a/src/lib/src/fwts_dump.c
+++ b/src/lib/src/fwts_dump.c
@@ -43,11 +43,11 @@ static int dump_data(const char *filename, char *data, const size_t len)
return FWTS_ERROR;
if ((fwrite(data, sizeof(char), len, fp) != len)) {
- fclose(fp);
+ (void)fclose(fp);
return FWTS_ERROR;
}
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
@@ -174,7 +174,7 @@ static int dump_acpi_tables(fwts_framework *fw)
int ret = fwts_acpi_get_table(fw, i, &table);
if (ret != FWTS_OK) {
fprintf(stderr, "Cannot read ACPI tables.\n");
- fclose(fp);
+ (void)fclose(fp);
return ret;
}
if (table == NULL)
@@ -182,7 +182,7 @@ static int dump_acpi_tables(fwts_framework *fw)
dump_acpi_table(table, fp);
}
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
@@ -217,7 +217,7 @@ static int dump_readme(void)
free(str);
}
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
@@ -236,15 +236,15 @@ static int dump_cpuinfo(void)
return FWTS_ERROR;
if ((target = fopen("cpuinfo.log", "w")) == NULL) {
- fclose(source);
+ (void)fclose(source);
return FWTS_ERROR;
}
while (0 < (bytes = fread(buffer, 1, sizeof(buffer), source)))
fwrite(buffer, 1, bytes, target);
- fclose(source);
- fclose(target);
+ (void)fclose(source);
+ (void)fclose(target);
return FWTS_OK;
}
diff --git a/src/lib/src/fwts_efi_module.c b/src/lib/src/fwts_efi_module.c
index f95ee63..d7bf9f2 100644
--- a/src/lib/src/fwts_efi_module.c
+++ b/src/lib/src/fwts_efi_module.c
@@ -51,7 +51,7 @@ static int check_module_loaded(
break;
}
}
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
fwts_log_error(fw, "Could not open /proc/modules to check if efi module '%s' is loaded.", module);
diff --git a/src/lib/src/fwts_fileio.c b/src/lib/src/fwts_fileio.c
index 2bea5d5..775aeb7 100644
--- a/src/lib/src/fwts_fileio.c
+++ b/src/lib/src/fwts_fileio.c
@@ -57,7 +57,7 @@ fwts_list* fwts_file_open_and_read(const char *file)
return NULL;
list = fwts_file_read(fp);
- fclose(fp);
+ (void)fclose(fp);
return list;
}
diff --git a/src/lib/src/fwts_get.c b/src/lib/src/fwts_get.c
index c464968..62217a9 100644
--- a/src/lib/src/fwts_get.c
+++ b/src/lib/src/fwts_get.c
@@ -36,11 +36,11 @@ char *fwts_get(const char *file)
return NULL;
if (fgets(buffer, sizeof(buffer), fp) == NULL) {
- fclose(fp);
+ (void)fclose(fp);
return NULL;
}
- fclose(fp);
+ (void)fclose(fp);
return strdup(buffer);
}
diff --git a/src/lib/src/fwts_gpe.c b/src/lib/src/fwts_gpe.c
index e141000..7a656d9 100644
--- a/src/lib/src/fwts_gpe.c
+++ b/src/lib/src/fwts_gpe.c
@@ -83,13 +83,13 @@ int fwts_gpe_read(fwts_gpe **gpes)
}
}
- closedir(dir);
+ (void)closedir(dir);
return n;
error:
fwts_gpe_free(*gpes, n);
*gpes = NULL;
- closedir(dir);
+ (void)closedir(dir);
return FWTS_ERROR;
}
diff --git a/src/lib/src/fwts_hwinfo.c b/src/lib/src/fwts_hwinfo.c
index 8af2e68..083b94d 100644
--- a/src/lib/src/fwts_hwinfo.c
+++ b/src/lib/src/fwts_hwinfo.c
@@ -177,7 +177,7 @@ static int fwts_hwinfo_bluetooth_get(
}
fwts_list_add_ordered(devices, bluetooth_config, fwts_hwinfo_bluetooth_name_cmp);
}
- closedir(dp);
+ (void)closedir(dp);
return FWTS_OK;
}
@@ -294,7 +294,7 @@ static int fwts_hwinfo_input_get(
}
fwts_list_add_ordered(devices, input_config, fwts_hwinfo_input_name_cmp);
}
- closedir(dp);
+ (void)closedir(dp);
return FWTS_OK;
}
@@ -375,7 +375,7 @@ static int fwts_hwinfo_net_get(
if ((dp = opendir(FWTS_HWINFO_SYS_NET)) == NULL) {
fwts_log_error(fw, "Cannot open %s to scan network devices.", FWTS_HWINFO_SYS_NET);
- close(sock);
+ (void)close(sock);
return FWTS_ERROR;
}
@@ -425,8 +425,8 @@ static int fwts_hwinfo_net_get(
}
fwts_list_add_ordered(devices, net_config, fwts_hwinfo_net_name_cmp);
}
- closedir(dp);
- close(sock);
+ (void)closedir(dp);
+ (void)close(sock);
return FWTS_OK;
}
@@ -486,10 +486,10 @@ static int fwts_hwinfo_pci_get(
if ((n = read(fd, config, sizeof(config))) < 0) {
fwts_log_error(fw, "Cannot read PCI config from %s.", d->d_name);
- close(fd);
+ (void)close(fd);
continue;
}
- close(fd);
+ (void)close(fd);
if (config[FWTS_PCI_CONFIG_CLASS_CODE] != class_code)
continue;
@@ -504,7 +504,7 @@ static int fwts_hwinfo_pci_get(
fwts_list_append(configs, pci_config);
}
- closedir(pci);
+ (void)closedir(pci);
return FWTS_OK;
}
diff --git a/src/lib/src/fwts_iasl.c b/src/lib/src/fwts_iasl.c
index ea1355c..8c37c1d 100644
--- a/src/lib/src/fwts_iasl.c
+++ b/src/lib/src/fwts_iasl.c
@@ -61,11 +61,11 @@ static int fwts_iasl_dump_aml_to_file(
if (write(fd, data, length) != length) {
fwts_log_error(fw, "Cannot write all data to temporary file");
- close(fd);
+ (void)close(fd);
(void)unlink(filename);
return FWTS_ERROR;
}
- close(fd);
+ (void)close(fd);
return FWTS_OK;
}
diff --git a/src/lib/src/fwts_ipmi.c b/src/lib/src/fwts_ipmi.c
index d4492cc..1e18dad 100644
--- a/src/lib/src/fwts_ipmi.c
+++ b/src/lib/src/fwts_ipmi.c
@@ -51,7 +51,7 @@ int fwts_ipmi_exec_query(
fwts_send_rc = ioctl(fd, IPMICTL_SEND_COMMAND, (char *)fwts_ipmi_req);
if (fwts_send_rc != 0) {
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
@@ -59,7 +59,7 @@ int fwts_ipmi_exec_query(
fwts_pfd.fd = fd;
fwts_pollfd_rc = poll(&fwts_pfd, 1, 5000);
if (fwts_pollfd_rc <= 0) {
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
@@ -71,7 +71,7 @@ int fwts_ipmi_exec_query(
fwts_recv_rc = ioctl(fd, IPMICTL_RECEIVE_MSG_TRUNC, &fwts_ipmi_recv);
if (fwts_recv_rc != 0) {
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
@@ -79,11 +79,11 @@ int fwts_ipmi_exec_query(
/* Future completion_code non-zero with good results to pass back */
if (fwts_base_rsp->completion_code != 0) {
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
- close(fd);
+ (void)close(fd);
return FWTS_OK;
}
diff --git a/src/lib/src/fwts_keymap.c b/src/lib/src/fwts_keymap.c
index cdd9e10..3e7d94b 100644
--- a/src/lib/src/fwts_keymap.c
+++ b/src/lib/src/fwts_keymap.c
@@ -106,7 +106,7 @@ fwts_list *fwts_keymap_load(const char *machine)
}
if ((key = (fwts_keycode*)calloc(1, sizeof(fwts_keycode))) == NULL) {
- fclose(fp);
+ (void)fclose(fp);
fwts_keymap_free(keymap_list);
return NULL;
} else {
@@ -117,7 +117,7 @@ fwts_list *fwts_keymap_load(const char *machine)
}
}
- fclose(fp);
+ (void)fclose(fp);
return keymap_list;
}
diff --git a/src/lib/src/fwts_klog.c b/src/lib/src/fwts_klog.c
index 5dbd4ed..334f49d 100644
--- a/src/lib/src/fwts_klog.c
+++ b/src/lib/src/fwts_klog.c
@@ -399,7 +399,7 @@ static int fwts_klog_check(fwts_framework *fw,
fwts_log_error(fw, "Cannot read file %s, check the path and check that the file exists, you may need to specify -j or -J.", json_data_path);
return FWTS_ERROR;
}
- close(fd);
+ (void)close(fd);
klog_objs = json_object_from_file(json_data_path);
if (FWTS_JSON_ERROR(klog_objs)) {
@@ -556,7 +556,7 @@ int fwts_klog_write(fwts_framework *fw, const char *msg)
fprintf(fp, "<7>fwts: %s", msg);
fflush(fp);
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
index 5bc966c..109967d 100644
--- a/src/lib/src/fwts_log.c
+++ b/src/lib/src/fwts_log.c
@@ -725,7 +725,7 @@ int fwts_log_close(fwts_log *log)
/* Close opened log file */
if (log_file->fp &&
log_file->filename_type == LOG_FILENAME_TYPE_FILE)
- fclose(log_file->fp);
+ (void)fclose(log_file->fp);
}
/* ..and free log files */
diff --git a/src/lib/src/fwts_memorymap.c b/src/lib/src/fwts_memorymap.c
index 7579231..63db7d9 100644
--- a/src/lib/src/fwts_memorymap.c
+++ b/src/lib/src/fwts_memorymap.c
@@ -300,7 +300,7 @@ fwts_list *fwts_memory_map_table_load(fwts_framework *fw)
return fwts_memory_map_table_load_from_klog(fw);
if ((memory_map_list = fwts_list_new()) == NULL) {
- closedir(dir);
+ (void)closedir(dir);
return NULL;
}
@@ -310,7 +310,7 @@ fwts_list *fwts_memory_map_table_load(fwts_framework *fw)
fwts_list_add_ordered(memory_map_list, entry, fwts_fwts_memory_map_entry_compare);
}
}
- closedir(dir);
+ (void)closedir(dir);
return memory_map_list;
}
diff --git a/src/lib/src/fwts_mmap.c b/src/lib/src/fwts_mmap.c
index e4f9aa2..506c226 100644
--- a/src/lib/src/fwts_mmap.c
+++ b/src/lib/src/fwts_mmap.c
@@ -66,7 +66,7 @@ void *fwts_mmap(const off_t start, const size_t size)
if ((mem = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fd, start - offset)) != MAP_FAILED)
ret = (void *)((uint8_t *)mem + offset);
- close(fd);
+ (void)close(fd);
return ret;
}
diff --git a/src/lib/src/fwts_olog.c b/src/lib/src/fwts_olog.c
index 45e436d..f3cf90f 100644
--- a/src/lib/src/fwts_olog.c
+++ b/src/lib/src/fwts_olog.c
@@ -83,7 +83,7 @@ fwts_list *fwts_olog_read(fwts_framework *fw)
* stat fails so not PPC with OPAL msglog and
* no -o OLOG sent
*/
- fclose(msglog_f);
+ (void)fclose(msglog_f);
return NULL;
}
diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c
index 68f1ff6..ecd4e33 100644
--- a/src/lib/src/fwts_pipeio.c
+++ b/src/lib/src/fwts_pipeio.c
@@ -85,23 +85,23 @@ int fwts_pipe_open_rw(const char *command, pid_t *childpid,
*/
if (out_pipefds[0] != STDOUT_FILENO) {
dup2(out_pipefds[1], STDOUT_FILENO);
- close(out_pipefds[1]);
+ (void)close(out_pipefds[1]);
}
if (in_pipefds[1] != STDIN_FILENO) {
dup2(in_pipefds[0], STDIN_FILENO);
- close(in_pipefds[0]);
+ (void)close(in_pipefds[0]);
}
- close(out_pipefds[0]);
- close(in_pipefds[1]);
+ (void)close(out_pipefds[0]);
+ (void)close(in_pipefds[1]);
execl(_PATH_BSHELL, "sh", "-c", command, NULL);
if (fp)
- fclose(fp);
+ (void)fclose(fp);
_exit(FWTS_EXEC_ERROR);
default:
/* Parent */
- close(out_pipefds[1]);
- close(in_pipefds[0]);
+ (void)close(out_pipefds[1]);
+ (void)close(in_pipefds[0]);
*childpid = pid;
if (out_fd)
@@ -113,11 +113,11 @@ int fwts_pipe_open_rw(const char *command, pid_t *childpid,
}
err_close_in:
- close(in_pipefds[0]);
- close(in_pipefds[1]);
+ (void)close(in_pipefds[0]);
+ (void)close(in_pipefds[1]);
err_close_out:
- close(out_pipefds[0]);
- close(out_pipefds[1]);
+ (void)close(out_pipefds[0]);
+ (void)close(out_pipefds[1]);
return -1;
}
@@ -249,7 +249,7 @@ int fwts_pipe_close(const int fd, const pid_t pid)
{
int status;
- close(fd);
+ (void)close(fd);
for (;;) {
if (waitpid(pid, &status, WUNTRACED | WCONTINUED) == -1)
@@ -263,7 +263,7 @@ int fwts_pipe_close(const int fd, const pid_t pid)
int fwts_pipe_close2(const int in_fd, const int out_fd, const pid_t pid)
{
- close(out_fd);
+ (void)close(out_fd);
return fwts_pipe_close(in_fd, pid);
}
@@ -406,7 +406,7 @@ int fwts_write_string_file(
}
ret = fwts_write_string_to_file(fw, file, str);
- fclose(file);
+ (void)fclose(file);
return ret;
}
@@ -438,7 +438,7 @@ int fwts_read_file_first_line(
if (!fgets(buffer, sizeof(buffer), file)) {
if (ferror(file)) {
- fclose(file);
+ (void)fclose(file);
fwts_log_error(fw,
"Failed to read first line from %s, error: %d (%s).",
file_name,
@@ -451,7 +451,7 @@ int fwts_read_file_first_line(
temp = strdup(buffer);
if (!temp) {
- fclose(file);
+ (void)fclose(file);
fwts_log_error(fw,
"Failed to read first line from %s: ran out of memory.",
file_name);
@@ -460,7 +460,7 @@ int fwts_read_file_first_line(
fwts_chop_newline(temp);
*line = temp;
- fclose(file);
+ (void)fclose(file);
return FWTS_OK;
}
diff --git a/src/lib/src/fwts_set.c b/src/lib/src/fwts_set.c
index ef2eac3..87d4a90 100644
--- a/src/lib/src/fwts_set.c
+++ b/src/lib/src/fwts_set.c
@@ -35,7 +35,7 @@ int fwts_set(const char *text, const char *file)
return FWTS_ERROR;
fprintf(fp, "%s\n", text);
- fclose(fp);
+ (void)fclose(fp);
return FWTS_OK;
}
diff --git a/src/lib/src/fwts_smbios.c b/src/lib/src/fwts_smbios.c
index fb814b2..21263b4 100644
--- a/src/lib/src/fwts_smbios.c
+++ b/src/lib/src/fwts_smbios.c
@@ -37,7 +37,7 @@ static int fwts_load_file(const char* filename, void *buf, size_t size)
if ((fd = open(filename, O_RDONLY)) < 0)
return FWTS_ERROR;
ret = read(fd, buf, size);
- close(fd);
+ (void)close(fd);
if (ret != (ssize_t)size)
return FWTS_ERROR;
return FWTS_OK;
diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c
index 871188a..78f9d3e 100644
--- a/src/lib/src/fwts_uefi.c
+++ b/src/lib/src/fwts_uefi.c
@@ -107,7 +107,7 @@ static int fwts_uefi_get_interface(char **path)
strcpy(efivar_path, "/sys/firmware/efi/vars");
}
}
- fclose(fp);
+ (void)fclose(fp);
}
*path = NULL;
@@ -214,10 +214,10 @@ static int fwts_uefi_get_variable_sys_fs(const char *varname, fwts_uefi_var *var
/* Read the raw fixed sized data */
if (read(fd, &uefi_sys_fs_var, sizeof(uefi_sys_fs_var)) != sizeof(uefi_sys_fs_var)) {
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
- close(fd);
+ (void)close(fd);
/* Sanity check datalen is OK */
if (uefi_sys_fs_var.datalen > sizeof(uefi_sys_fs_var.data))
@@ -274,14 +274,14 @@ static int fwts_uefi_get_variable_efivars_fs(const char *varname, fwts_uefi_var
return FWTS_ERROR;
if (fstat(fd, &statbuf) < 0) {
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
/* Variable name, less the GUID, in 16 bit ints */
var->varname = calloc(1, (varname_len + 1 - 36) * sizeof(uint16_t));
if (var->varname == NULL) {
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
@@ -290,18 +290,18 @@ static int fwts_uefi_get_variable_efivars_fs(const char *varname, fwts_uefi_var
/* Need to read the data in one read, so allocate a buffer big enough */
if ((efivars_fs_var = calloc(1, statbuf.st_size)) == NULL) {
- close(fd);
+ (void)close(fd);
free(var->varname);
return FWTS_ERROR;
}
if (read(fd, efivars_fs_var, statbuf.st_size) != statbuf.st_size) {
- close(fd);
+ (void)close(fd);
free(var->varname);
free(efivars_fs_var);
return FWTS_ERROR;
}
- close(fd);
+ (void)close(fd);
var->status = 0;
diff --git a/src/opal/mtd_info.c b/src/opal/mtd_info.c
index 5f08e9c..a90e46a 100644
--- a/src/opal/mtd_info.c
+++ b/src/opal/mtd_info.c
@@ -73,7 +73,7 @@ int mtd_hdr_query(fwts_framework *fw, char *mtd_devnode) {
" not able to be"
" verified. Check the system setup.\n",
mtd_devnode);
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
} else {
@@ -82,11 +82,11 @@ int mtd_hdr_query(fwts_framework *fw, char *mtd_devnode) {
" Cannot validate the integrity of the MTD."
" Check the system setup.\n",
mtd_devnode);
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
- close(fd);
+ (void)close(fd);
return FWTS_OK;
}
@@ -127,7 +127,7 @@ int mtd_dev_query(fwts_framework *fw, char *mtd_devnode)
}
if (ioctl(fd, MEMGETINFO, &mtd_info)) {
- close(fd);
+ (void)close(fd);
fwts_failed(fw, LOG_LEVEL_CRITICAL, "OPAL MTD Info",
"Cannot get data from '%s'"
" device interface.", mtd_devnode);
@@ -147,7 +147,7 @@ int mtd_dev_query(fwts_framework *fw, char *mtd_devnode)
mtd_info.erasesize,
mtd_info.writesize,
mtd_info.oobsize);
- close(fd);
+ (void)close(fd);
return FWTS_OK;
}
}
@@ -189,10 +189,10 @@ static int mtd_info_test1(fwts_framework *fw)
" Check the installation "
"for the path %s.\n",
FDT_FLASH_PATH);
- close(fd);
+ (void)close(fd);
return FWTS_ERROR;
}
- close(fd);
+ (void)close(fd);
fdt_node_path[PATH_MAX] = '\0';
fwts_log_info(fw, "MTD Info validated FDT of '%s'.",
fdt_node_path);
diff --git a/src/opal/prd_info.c b/src/opal/prd_info.c
index 93daceb..f507baa 100644
--- a/src/opal/prd_info.c
+++ b/src/opal/prd_info.c
@@ -56,7 +56,7 @@ int prd_dev_query(fwts_framework *fw)
memset(&info, 0, sizeof(info));
if (ioctl(fd, OPAL_PRD_GET_INFO, &info)) {
- close(fd);
+ (void)close(fd);
fwts_failed(fw, LOG_LEVEL_CRITICAL, "OPAL PRD Info",
"Cannot get data from the"
" OPAL PRD device interface.");
@@ -64,7 +64,7 @@ int prd_dev_query(fwts_framework *fw)
} else {
fwts_log_info(fw, "OPAL PRD Version is %lu",
info.version);
- close(fd);
+ (void)close(fd);
return FWTS_OK;
}
}
diff --git a/src/pci/aspm/aspm.c b/src/pci/aspm/aspm.c
index 9c3c143..3e7aaec 100644
--- a/src/pci/aspm/aspm.c
+++ b/src/pci/aspm/aspm.c
@@ -218,10 +218,10 @@ static int pcie_check_aspm_registers(fwts_framework *fw)
if (read(fd, device->config, sizeof(device->config)) < 0) {
fwts_log_warning(fw, "Could not read config from PCI device %s\n", entry->d_name);
free(device);
- close(fd);
+ (void)close(fd);
continue;
}
- close(fd);
+ (void)close(fd);
fwts_list_append(&dev_list, device);
}
}
diff --git a/src/pci/maxreadreq/maxreadreq.c b/src/pci/maxreadreq/maxreadreq.c
index a1a7472..2965bce 100644
--- a/src/pci/maxreadreq/maxreadreq.c
+++ b/src/pci/maxreadreq/maxreadreq.c
@@ -75,10 +75,10 @@ static int maxreadreq_test1(fwts_framework *fw)
}
if ((n = read(fd, config, sizeof(config))) < 0) {
fwts_log_warning(fw, "Could not read %s PCI config data\n", entry->d_name);
- close(fd);
+ (void)close(fd);
continue;
}
- close(fd);
+ (void)close(fd);
/* Ignore Host Bridge */
if ((config[FWTS_PCI_CONFIG_CLASS_CODE] == FWTS_PCI_CLASS_CODE_BRIDGE_CONTROLLER) &&
@@ -122,7 +122,7 @@ static int maxreadreq_test1(fwts_framework *fw)
offset = cap->next_cap_point;
}
}
- closedir(dirp);
+ (void)closedir(dirp);
if (warnings > 0) {
fwts_failed(fw, LOG_LEVEL_LOW,
--
2.9.3
More information about the fwts-devel
mailing list