Skip to content

Commit d0062ed

Browse files
committed
Fix a number of warnings and small bugs in newlib glue
1 parent c08e5aa commit d0062ed

File tree

7 files changed

+14
-10
lines changed

7 files changed

+14
-10
lines changed

land/newlib/xelix/crt0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern void __libc_fini_array();
3131

3232
// These are defined as extern in sys/xelix.h
3333
struct _xelix_execdata* _xelix_execdata;
34-
char* _progname;
34+
const char* _progname;
3535
FILE* _xelix_serial = NULL;
3636

3737
void __attribute__((fastcall, noreturn)) _start(void) {

land/newlib/xelix/inet_addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ inet_addr(cp)
9494
{
9595
in_addr_t val;
9696

97-
if (inet_aton(cp, &val))
97+
if (inet_aton(cp, (struct in_addr*)&val))
9898
return (val);
9999
return (INADDR_NONE);
100100
}

land/newlib/xelix/mntent.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@ free_mem (void)
7272
free (getmntent_buffer);
7373
}
7474

75-
text_set_element (__libc_subfreeres, free_mem);
75+
// FIXME
76+
//text_set_element (__libc_subfreeres, free_mem);

land/newlib/xelix/openpty.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <fcntl.h>
2222
#include <termios.h>
2323
#include <limits.h>
24+
#include <unistd.h>
2425

2526
int openpty(int* ptm, int* pts, char *name, const struct termios* termios,
2627
const struct winsize* winsize) {
@@ -31,20 +32,20 @@ int openpty(int* ptm, int* pts, char *name, const struct termios* termios,
3132
}
3233

3334
if(ioctl(*ptm, TIOCGPTN, pts) < 0) {
34-
close(ptm);
35+
close(*ptm);
3536
return -1;
3637
}
3738

3839
if(termios) {
3940
if(ioctl(*pts, TCSETS, termios) < 0) {
40-
close(ptm);
41+
close(*ptm);
4142
return -1;
4243
}
4344
}
4445

4546
if(winsize) {
4647
if(ioctl(*pts, TIOCSWINSZ, winsize) < 0) {
47-
close(ptm);
48+
close(*ptm);
4849
return -1;
4950
}
5051
}
@@ -73,7 +74,7 @@ pid_t forkpty(int* ptm, char* name, const struct termios* termios,
7374
close(pts);
7475
return pid;
7576
} else {
76-
close(ptm);
77+
close(*ptm);
7778

7879
// Map stdin/out to pts
7980
close(1);

land/newlib/xelix/stubs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <pthread.h>
4343
#include <syslog.h>
4444
#include <sched.h>
45+
#include <netdb.h>
4546

4647
#ifdef NOISY_STUBS
4748
#define STUBWARN(cmd) fprintf(stderr, "xelix-newlib: " #cmd " stub called.\n");
@@ -135,7 +136,7 @@ STUB(int, initgroups, (const char *user, gid_t group), -1);
135136
STUB(void, sync, (void));
136137
STUB(int, getsockopt, (int sockfd, int level, int optname, void* optval, socklen_t* optlen), -1);
137138
STUB(ssize_t, recvmsg, (int sockfd, struct msghdr *msg, int flags), -1);
138-
STUB(dev_t, makedev, (unsigned int maj, unsigned int min), NULL);
139+
STUB(dev_t, makedev, (unsigned int maj, unsigned int min), (dev_t)0);
139140
STUB(int, daemon, (int nochdir, int noclose), -1);
140141
STUB(int, seteuid, (uid_t euid), -1);
141142
STUB(int, setegid, (gid_t egid), -1);

land/newlib/xelix/sys/xelix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct _xelix_execdata {
4545
};
4646

4747
extern struct _xelix_execdata* _xelix_execdata;
48-
extern char* _progname;
48+
extern const char* _progname;
4949
extern FILE* _xelix_serial;
5050

5151
int _strace(void);

land/newlib/xelix/syscalls.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <sys/select.h>
2929
#include <sys/errno.h>
3030
#include <sys/xelix.h>
31+
#include <sys/mman.h>
3132
#include <sys/utsname.h>
3233
#include <sys/wait.h>
3334
#include <netinet/in.h>
@@ -196,7 +197,7 @@ ssize_t send(int socket, const void *buffer, size_t length, int flags) {
196197
return syscall(3, socket, buffer, length);
197198
}
198199

199-
int _execve(char *name, char **argv, char **env) {
200+
int _execve(char *name, char* const argv[], char* const env[]) {
200201
return syscall(32, name, argv, env);
201202
}
202203

0 commit comments

Comments
 (0)