ret_value_errno_msg_if(!f, -errno,
"Fail to open file %s", path);
+ errno = 0;
ret = fputs(str, f);
- ret_value_errno_msg_if(ret == EOF, errno ? -errno : -EIO,
+ ret_value_errno_msg_if(ret == EOF, -(errno ?: EIO),
"Fail to write file");
return RESOURCED_ERROR_NONE;
ret_value_errno_msg_if(!f, -errno,
"Fail to open %s file.", path);
+ errno = 0;
for (i = 0; i <= n; i++) {
ret = fscanf(f, "%d", &t);
- ret_value_errno_msg_if(ret == EOF, -errno,
+ ret_value_errno_msg_if(ret == EOF, -(errno ?: ENOENT),
"Fail to read file\n");
}
ret_value_errno_msg_if(!f, -errno,
"Fail to open %s file.", path);
+ errno = 0;
for (i = 0; i <= n; i++) {
ret = fscanf(f, "%u", &t);
- ret_value_errno_msg_if(ret == EOF, -errno,
+ ret_value_errno_msg_if(ret == EOF, -(errno ?: ENOENT),
"Fail to read file\n");
}
ret_value_errno_msg_if(!f, -errno,
"Fail to open %s file.", path);
+ errno = 0;
for (i = 0; i <= n; i++) {
ret = fscanf(f, "%lu", &t);
- ret_value_errno_msg_if(ret == EOF, -errno,
+ ret_value_errno_msg_if(ret == EOF, -(errno ?: ENOENT),
"Fail to read file\n");
}