summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/file.c2
-rw-r--r--unix/socket.c10
2 files changed, 6 insertions, 6 deletions
diff --git a/unix/file.c b/unix/file.c
index 7bbe3bfd00..0d11de6332 100644
--- a/unix/file.c
+++ b/unix/file.c
@@ -50,7 +50,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(fdfile_close_obj, fdfile_close);
static mp_obj_t fdfile_fileno(mp_obj_t self_in) {
mp_obj_fdfile_t *self = self_in;
- return MP_OBJ_NEW_SMALL_INT(self->fd);
+ return MP_OBJ_NEW_SMALL_INT((machine_int_t)self->fd);
}
static MP_DEFINE_CONST_FUN_OBJ_1(fdfile_fileno_obj, fdfile_fileno);
diff --git a/unix/socket.c b/unix/socket.c
index 68e2965bcb..4b160e0bc8 100644
--- a/unix/socket.c
+++ b/unix/socket.c
@@ -86,7 +86,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(socket_close_obj, socket_close);
static mp_obj_t socket_fileno(mp_obj_t self_in) {
mp_obj_socket_t *self = self_in;
- return MP_OBJ_NEW_SMALL_INT(self->fd);
+ return MP_OBJ_NEW_SMALL_INT((machine_int_t)self->fd);
}
static MP_DEFINE_CONST_FUN_OBJ_1(socket_fileno_obj, socket_fileno);
@@ -291,8 +291,8 @@ static mp_obj_t mod_socket_getaddrinfo(uint n_args, const mp_obj_t *args) {
// getaddrinfo accepts port in string notation, so however
// it may seem stupid, we need to convert int to str
if (MP_OBJ_IS_SMALL_INT(args[1])) {
- int port = MP_OBJ_SMALL_INT_VALUE(args[1]);
- static char buf[20];
+ int port = (short)MP_OBJ_SMALL_INT_VALUE(args[1]);
+ char buf[6];
sprintf(buf, "%d", port);
serv = buf;
} else {
@@ -333,7 +333,7 @@ extern mp_obj_type_t sockaddr_in_type;
#define C(name) { #name, name }
-struct sym_entry {
+static const struct sym_entry {
const char *sym;
int val;
} constants[] = {
@@ -369,7 +369,7 @@ void microsocket_init() {
rt_store_attr(m, MP_QSTR_gethostbyname, (mp_obj_t)&mod_socket_gethostbyname_obj);
#endif
rt_store_attr(m, MP_QSTR_getaddrinfo, (mp_obj_t)&mod_socket_getaddrinfo_obj);
- for (struct sym_entry *p = constants; p->sym != NULL; p++) {
+ for (const struct sym_entry *p = constants; p->sym != NULL; p++) {
rt_store_attr(m, QSTR_FROM_STR_STATIC(p->sym), MP_OBJ_NEW_SMALL_INT((machine_int_t)p->val));
}
}