Minor fixes
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 4s

This commit is contained in:
Stephen Seo 2024-07-17 15:01:39 +09:00
parent ea845f2552
commit bbdcd660a5

View file

@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "platforms.h"
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \ #if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \ SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
@ -476,20 +477,23 @@ int simple_archiver_print_archive_info(FILE *in_f) {
int simple_archiver_de_compress(int pipe_fd_in, int pipe_fd_out, int simple_archiver_de_compress(int pipe_fd_in, int pipe_fd_out,
const char *cmd) { const char *cmd) {
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
posix_spawn_file_actions_t file_actions; posix_spawn_file_actions_t file_actions;
memset(&file_actions, 0, sizeof(file_actions)); memset(&file_actions, 0, sizeof(file_actions));
if (posix_spawn_file_actions_init(&file_actions) != 0) { if (posix_spawn_file_actions_init(&file_actions) != 0) {
close(pipe_fd_in); close(pipe_fd_in);
close(pipe_fd_out); close(pipe_fd_out);
return 1; return 1;
} else if (posix_spawn_file_actions_adddup2(&file_actions, pipe_fd_in, 0) != } else if (posix_spawn_file_actions_adddup2(&file_actions, pipe_fd_in,
0) { STDIN_FILENO) != 0) {
posix_spawn_file_actions_destroy(&file_actions); posix_spawn_file_actions_destroy(&file_actions);
close(pipe_fd_in); close(pipe_fd_in);
close(pipe_fd_out); close(pipe_fd_out);
return 2; return 2;
} else if (posix_spawn_file_actions_adddup2(&file_actions, pipe_fd_out, 1) != } else if (posix_spawn_file_actions_adddup2(&file_actions, pipe_fd_out,
0) { STDOUT_FILENO) != 0) {
posix_spawn_file_actions_destroy(&file_actions); posix_spawn_file_actions_destroy(&file_actions);
close(pipe_fd_in); close(pipe_fd_in);
close(pipe_fd_out); close(pipe_fd_out);
@ -510,4 +514,7 @@ int simple_archiver_de_compress(int pipe_fd_in, int pipe_fd_out,
posix_spawn_file_actions_destroy(&file_actions); posix_spawn_file_actions_destroy(&file_actions);
return 0; return 0;
#else
return 1;
#endif
} }