Skip to content

Commit

Permalink
[tools,tests] Fix incorrect errno checking
Browse files Browse the repository at this point in the history
Valid error numbers are all positive numbers in libc.

Signed-off-by: Kailun Qin <kailun.qin@intel.com>
  • Loading branch information
kailun-qin committed Feb 19, 2024
1 parent f0bb306 commit 2cef387
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libos/test/regression/large_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(void) {
ssize_t n;
do {
n = read(fd, &c, 1);
} while (n == -1 && errno == -EINTR);
} while (n == -1 && errno == EINTR);
if (n == -1)
err(1, "read");
if (n != 1)
Expand Down
4 changes: 2 additions & 2 deletions tools/sgx/common/pf_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ int pf_encrypt_file(const char* input_path, const char* output_path, const pf_ke
break;

if (chunk_size < 0) {
if (errno == -EINTR)
if (errno == EINTR)
continue;

ERROR("Failed to read file '%s': %s\n", input_path, strerror(errno));
Expand Down Expand Up @@ -479,7 +479,7 @@ int pf_decrypt_file(const char* input_path, const char* output_path, bool verify
ssize_t written = write(output, chunk, chunk_size);

if (written < 0) {
if (errno == -EINTR)
if (errno == EINTR)
continue;

ERROR("Failed to write file '%s': %s\n", output_path, strerror(errno));
Expand Down

0 comments on commit 2cef387

Please sign in to comment.