From ee89bb90c8e02abe42e2d1caee072f7f15c0976f Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 14 Feb 2022 15:13:38 +0000 Subject: [PATCH] some minor fixes --- hio/lib/pro.c | 6 +++--- hio/lib/pty.c | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hio/lib/pro.c b/hio/lib/pro.c index e60e68d..0580f91 100644 --- a/hio/lib/pro.c +++ b/hio/lib/pro.c @@ -88,8 +88,8 @@ static int make_param (hio_t* hio, const hio_bch_t* cmd, int flags, param_t* par hio_bch_t* mcmdptr; mcmd = hio_dupbcstr(hio, cmd, HIO_NULL); - if (!mcmd) goto oops; - + if (HIO_UNLIKELY(!mcmd)) goto oops; + fcnt = hio_split_bcstr(mcmd, "", '\"', '\"', '\\'); if (fcnt <= 0) { @@ -105,7 +105,7 @@ static int make_param (hio_t* hio, const hio_bch_t* cmd, int flags, param_t* par else { param->argv = hio_allocmem(hio, (fcnt + 1) * HIO_SIZEOF(argv[0])); - if (!param->argv) goto oops; + if (HIO_UNLIKELY(!param->argv)) goto oops; } mcmdptr = mcmd; diff --git a/hio/lib/pty.c b/hio/lib/pty.c index 465f4f1..42a6383 100644 --- a/hio/lib/pty.c +++ b/hio/lib/pty.c @@ -111,8 +111,8 @@ static int dev_pty_make (hio_dev_t* dev, void* ctx) # error NOT IMPLEMENTED YET #endif - if (hio_makesyshndcloexec(hio, pfds[0]) <= -1) goto oops; - if (hio_makesyshndcloexec(hio, pfds[1]) <= -1) goto oops; + if (hio_makesyshndcloexec(hio, pfds[0]) <= -1 || + hio_makesyshndcloexec(hio, pfds[1]) <= -1) goto oops; pid = fork(); if (pid == -1) @@ -127,7 +127,7 @@ static int dev_pty_make (hio_dev_t* dev, void* ctx) close (pfds[0]); /* close the pty master */ pfds[0] = HIO_SYSHND_INVALID; - /*TODO: close all open file descriptors */ + /*TODO: close all open file descriptors */ setsid (); /* TODO: error check? */ setpgid (0, 0); @@ -160,7 +160,7 @@ static int dev_pty_make (hio_dev_t* dev, void* ctx) oops: if (pfds[0] != HIO_SYSHND_INVALID) close (pfds[0]); - if (pfds[1] != HIO_SYSHND_INVALID) close (pfds[0]); + if (pfds[1] != HIO_SYSHND_INVALID) close (pfds[1]); return -1; } @@ -408,4 +408,3 @@ int hio_dev_pty_close (hio_dev_pty_t* dev) { return hio_dev_ioctl((hio_dev_t*)dev, HIO_DEV_PTY_CLOSE, HIO_NULL); } -