mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zpcictl: Use fopen() instead of open() for writes
Be consistent with the rest of the code and use fopen() rather than open(). Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -155,17 +155,19 @@ static unsigned int sysfs_read_value(struct zpci_device *pdev, const char *attr)
|
||||
|
||||
static void sysfs_write_data(struct zpci_report_error *report, char *slot)
|
||||
{
|
||||
size_t r_size;
|
||||
char *path;
|
||||
int fd, rc;
|
||||
FILE *fp;
|
||||
|
||||
r_size = sizeof(*report);
|
||||
|
||||
path = util_path_sysfs("bus/pci/devices/%s/report_error", slot);
|
||||
fd = open(path, O_WRONLY);
|
||||
if (!fd)
|
||||
fp = fopen(path, "w");
|
||||
if (!fp)
|
||||
fopen_err(path);
|
||||
rc = write(fd, report, sizeof(*report));
|
||||
if (rc == -1)
|
||||
if (fwrite(report, 1, r_size, fp) != r_size)
|
||||
warnx("Could not write to file: %s: %s", path, strerror(errno));
|
||||
if (close(fd))
|
||||
if (fclose(fp))
|
||||
warnx("Could not close file: %s: %s", path, strerror(errno));
|
||||
free(path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user