Skip to content

Commit

Permalink
Fix some cast warnings (that C warns about even with warnings turned …
Browse files Browse the repository at this point in the history
…down)
  • Loading branch information
hostilefork committed Jul 7, 2015
1 parent 08bd143 commit 9605232
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/core/b-init.c
Expand Up @@ -705,7 +705,8 @@ extern const REBYTE Str_Banner[];
}

if (codi->action == CODI_ENCODE) {
u16 * data = codi->data = Alloc_Mem(codi->len * sizeof(u16));
u16 * data = ALLOC_ARRAY(u16, codi->len);
codi->data = r_cast(unsigned char *, data);
if (codi->w == 1) {
/* in ASCII */
REBCNT i = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/core/d-crash.c
Expand Up @@ -66,7 +66,7 @@ enum Crash_Msg_Nums {
{
va_list args;
REBYTE buf[CRASH_BUF_SIZE];
REBYTE *msg;
const REBYTE *msg;
REBINT n = 0;

va_start(args, id);
Expand Down
2 changes: 1 addition & 1 deletion src/core/f-stubs.c
Expand Up @@ -46,7 +46,7 @@

/***********************************************************************
**
*/ REBCNT Bytes_To_REBCNT(REBYTE * const in)
*/ REBCNT Bytes_To_REBCNT(const REBYTE *in)
/*
***********************************************************************/
{
Expand Down
13 changes: 9 additions & 4 deletions src/core/n-io.c
Expand Up @@ -701,10 +701,15 @@ static REBSER *Read_All_File(char *fname)
Trap_Arg(arg);
}

r = OS_CREATE_PROCESS(cmd, argc, argv, flags, &pid, &exit_code,
input_type, os_input, input_len,
output_type, &os_output, &output_len,
err_type, &os_err, &err_len);
r = OS_CREATE_PROCESS(
// const cast is needed for standard C limitation:
// http://stackoverflow.com/a/19505361/211160
cmd, argc, c_cast(const char**, argv),
flags, &pid, &exit_code,
input_type, os_input, input_len,
output_type, &os_output, &output_len,
err_type, &os_err, &err_len
);

if (output_type == STRING_TYPE) {
if (output != NULL
Expand Down
2 changes: 1 addition & 1 deletion src/core/p-signal.c
Expand Up @@ -35,7 +35,7 @@

static void update(REBREQ *req, REBINT len, REBVAL *arg)
{
const siginfo_t *sig = req->data;
const siginfo_t *sig = r_cast(siginfo_t *, req->data);
int i = 0;

Extend_Series(VAL_SERIES(arg), len);
Expand Down
14 changes: 8 additions & 6 deletions src/os/linux/host-lib.c
Expand Up @@ -873,7 +873,7 @@ static const void * backtrace_buf [1024];

/***********************************************************************
**
*/ int OS_Create_Process(REBCHR *call, int argc, char* argv[], u32 flags, u64 *pid, int *exit_code, u32 input_type, void *input, u32 input_len, u32 output_type, void **output, u32 *output_len, u32 err_type, void **err, u32 *err_len)
*/ int OS_Create_Process(REBCHR *call, int argc, const char* argv[], u32 flags, u64 *pid, int *exit_code, u32 input_type, void *input, u32 input_len, u32 output_type, void **output, u32 *output_len, u32 err_type, void **err, u32 *err_len)
/*
* flags:
* 1: wait, is implied when I/O redirection is enabled
Expand Down Expand Up @@ -1037,8 +1037,8 @@ static const void * backtrace_buf [1024];

//printf("flag_shell in child: %hhu\n", flag_shell);
if (flag_shell) {
const char* sh = NULL;
const char ** argv_new = NULL;
char *sh = NULL;
char **argv_new = NULL;
sh = getenv("SHELL");
if (sh == NULL) {
int err = 2; /* shell does not exist */
Expand All @@ -1050,9 +1050,11 @@ static const void * backtrace_buf [1024];
argv_new[1] = "-c";
memcpy(&argv_new[2], argv, argc * sizeof(argv[0]));
argv_new[argc + 2] = NULL;
execvp(sh, (char* const*)argv_new);
execvp(sh, argv_new);
} else {
execvp(argv[0], argv);
// const cast needed for standard C limitation:
// http://stackoverflow.com/a/19505361/211160
execvp(argv[0], c_cast(char * const *, argv));
}
child_error:
write(info_pipe[W], &errno, sizeof(errno));
Expand Down Expand Up @@ -1331,7 +1333,7 @@ static const void * backtrace_buf [1024];

static int Try_Browser(char *browser, REBCHR *url)
{
char * const argv[] = {browser, url, NULL};
const char *argv[] = {browser, url, NULL};
return OS_Create_Process(browser, 2, argv, 0,
NULL, /* pid */
NULL, /* exit_code */
Expand Down
2 changes: 1 addition & 1 deletion src/os/win32/host-lib.c
Expand Up @@ -728,7 +728,7 @@ static void *Task_Ready;

/***********************************************************************
**
*/ int OS_Create_Process(REBCHR *call, int argc, char* argv[], u32 flags, u64 *pid, int *exit_code, u32 input_type, void *input, u32 input_len, u32 output_type, void **output, u32 *output_len, u32 err_type, void **err, u32 *err_len)
*/ int OS_Create_Process(REBCHR *call, int argc, const char* argv[], u32 flags, u64 *pid, int *exit_code, u32 input_type, void *input, u32 input_len, u32 output_type, void **output, u32 *output_len, u32 err_type, void **err, u32 *err_len)
/*
** Return -1 on error.
** For right now, set flags to 1 for /wait.
Expand Down

0 comments on commit 9605232

Please sign in to comment.