Skip to content

Commit a8e6d05

Browse files
Jan WielemakerJan Wielemaker
Jan Wielemaker
authored and
Jan Wielemaker
committed
FIXED: Various ignored return values in Windows branches.
1 parent a137d35 commit a8e6d05

File tree

2 files changed

+24
-41
lines changed

2 files changed

+24
-41
lines changed

process.c

+17-35
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ static atom_t ATOM_infinite;
6363
static functor_t FUNCTOR_error2;
6464
static functor_t FUNCTOR_type_error2;
6565
static functor_t FUNCTOR_domain_error2;
66-
static functor_t FUNCTOR_resource_error1;
6766
static functor_t FUNCTOR_process_error2;
6867
static functor_t FUNCTOR_system_error2;
6968
static functor_t FUNCTOR_pipe1;
@@ -145,22 +144,6 @@ domain_error(term_t actual, const char *expected)
145144
}
146145

147146

148-
static int
149-
resource_error(const char *resource)
150-
{ term_t ex;
151-
152-
if ( (ex=PL_new_term_ref()) &&
153-
PL_unify_term(ex,
154-
PL_FUNCTOR, FUNCTOR_error2,
155-
PL_FUNCTOR, FUNCTOR_resource_error1,
156-
PL_CHARS, resource,
157-
PL_VARIABLE) )
158-
return PL_raise_exception(ex);
159-
160-
return FALSE;
161-
}
162-
163-
164147
/*******************************
165148
* ADMIN *
166149
*******************************/
@@ -299,10 +282,11 @@ parse_environment(term_t t, p_options *info)
299282
term_t head = PL_new_term_ref();
300283
term_t tmp = PL_new_term_ref();
301284
ecbuf *eb = &info->envbuf;
302-
int count = 0, c = 0;
285+
int count = 0;
303286
#ifndef __WINDOWS__
304287
echar *q;
305288
char **ep;
289+
int c = 0;
306290
#endif
307291

308292
assert(eb->size == 0);
@@ -732,7 +716,7 @@ win_command_line(term_t t, int arity, const wchar_t *exe, wchar_t **cline)
732716
cmdlen = av[0].len+(av[0].quote?2:0)+1;
733717

734718
for( i=1; i<=arity; i++)
735-
{ PL_get_arg(i, t, arg);
719+
{ _PL_get_arg(i, t, arg);
736720

737721
if ( !PL_get_wchars(arg, &av[i].len, &av[i].text,
738722
CVT_ATOMIC|CVT_EXCEPTION|BUF_MALLOC) )
@@ -834,9 +818,8 @@ find_process_from_pid(DWORD pid, const char *pred)
834818
if ( pred )
835819
{ term_t ex = PL_new_term_ref();
836820

837-
PL_put_integer(ex, pid);
838-
pl_error(NULL, 2, NULL, ERR_EXISTENCE,
839-
"process", ex);
821+
if ( PL_put_integer(ex, pid) )
822+
PL_existence_error("process", ex);
840823
}
841824

842825
return (HANDLE)0;
@@ -937,17 +920,17 @@ win_wait_success(atom_t exe, HANDLE process)
937920
return FALSE;
938921

939922
if ( rc != 0 )
940-
{ term_t code = PL_new_term_ref();
941-
term_t ex = PL_new_term_ref();
942-
943-
PL_unify_term(ex,
944-
PL_FUNCTOR, FUNCTOR_error2,
945-
PL_FUNCTOR, FUNCTOR_process_error2,
946-
PL_ATOM, exe,
947-
PL_FUNCTOR, FUNCTOR_exit1,
948-
PL_LONG, rc,
949-
PL_VARIABLE);
950-
return PL_raise_exception(ex);
923+
{ term_t ex = PL_new_term_ref();
924+
925+
if ( PL_unify_term(ex,
926+
PL_FUNCTOR, FUNCTOR_error2,
927+
PL_FUNCTOR, FUNCTOR_process_error2,
928+
PL_ATOM, exe,
929+
PL_FUNCTOR, FUNCTOR_exit1,
930+
PL_LONG, rc,
931+
PL_VARIABLE) )
932+
return PL_raise_exception(ex);
933+
return FALSE;
951934
}
952935

953936
return TRUE;
@@ -1179,7 +1162,7 @@ create_pipes(p_options *info)
11791162
} else
11801163
{ if ( pipe(s->fd) )
11811164
{ assert(errno = EMFILE);
1182-
return resource_error("open_files");
1165+
return PL_resource_error("open_files");
11831166
}
11841167
}
11851168
}
@@ -1595,7 +1578,6 @@ install_process()
15951578
MKFUNCTOR(domain_error, 2);
15961579
MKFUNCTOR(process_error, 2);
15971580
MKFUNCTOR(system_error, 2);
1598-
MKFUNCTOR(resource_error, 1);
15991581
MKFUNCTOR(exit, 1);
16001582
MKFUNCTOR(killed, 1);
16011583

win_error.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ win_error(const char *op)
5757
{ atom_t msg = WinError();
5858
term_t ex = PL_new_term_ref();
5959

60-
PL_unify_term(ex, PL_FUNCTOR, FUNCTOR_error2,
61-
PL_FUNCTOR, FUNCTOR_system_error2,
62-
PL_CHARS, op,
63-
PL_ATOM, msg,
64-
PL_VARIABLE);
60+
if ( PL_unify_term(ex, PL_FUNCTOR, FUNCTOR_error2,
61+
PL_FUNCTOR, FUNCTOR_system_error2,
62+
PL_CHARS, op,
63+
PL_ATOM, msg,
64+
PL_VARIABLE) )
65+
return PL_raise_exception(ex);
6566

66-
return PL_raise_exception(ex);
67+
return FALSE;
6768
}

0 commit comments

Comments
 (0)