[svn:parrot] r39888 - in trunk: include/parrot src/io
petdance at svn.parrot.org
petdance at svn.parrot.org
Sun Jul 5 05:15:51 UTC 2009
Author: petdance
Date: Sun Jul 5 05:15:50 2009
New Revision: 39888
URL: https://trac.parrot.org/parrot/changeset/39888
Log:
localizing and consting
Modified:
trunk/include/parrot/io.h
trunk/src/io/socket_api.c
trunk/src/io/socket_unix.c
Modified: trunk/include/parrot/io.h
==============================================================================
--- trunk/include/parrot/io.h Sun Jul 5 05:02:03 2009 (r39887)
+++ trunk/include/parrot/io.h Sun Jul 5 05:15:50 2009 (r39888)
@@ -849,12 +849,12 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
INTVAL Parrot_io_socket(PARROT_INTERP,
- ARGMOD_NULLOK(PMC * socket),
+ ARGMOD_NULLOK(PMC *socket),
INTVAL fam,
INTVAL type,
INTVAL proto)
__attribute__nonnull__(1)
- FUNC_MODIFIES(* socket);
+ FUNC_MODIFIES(*socket);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
Modified: trunk/src/io/socket_api.c
==============================================================================
--- trunk/src/io/socket_api.c Sun Jul 5 05:02:03 2009 (r39887)
+++ trunk/src/io/socket_api.c Sun Jul 5 05:15:50 2009 (r39888)
@@ -150,7 +150,7 @@
/*
-=item C<INTVAL Parrot_io_socket(PARROT_INTERP, PMC * socket, INTVAL fam, INTVAL
+=item C<INTVAL Parrot_io_socket(PARROT_INTERP, PMC *socket, INTVAL fam, INTVAL
type, INTVAL proto)>
Creates and returns a socket using the specified address family, socket type,
@@ -165,7 +165,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
INTVAL
-Parrot_io_socket(PARROT_INTERP, ARGMOD_NULLOK(PMC * socket), INTVAL fam,
+Parrot_io_socket(PARROT_INTERP, ARGMOD_NULLOK(PMC *socket), INTVAL fam,
INTVAL type, INTVAL proto)
{
ASSERT_ARGS(Parrot_io_socket)
Modified: trunk/src/io/socket_unix.c
==============================================================================
--- trunk/src/io/socket_unix.c Sun Jul 5 05:02:03 2009 (r39887)
+++ trunk/src/io/socket_unix.c Sun Jul 5 05:15:50 2009 (r39888)
@@ -100,11 +100,10 @@
Parrot_io_sockaddr_in(PARROT_INTERP, ARGIN(STRING *addr), INTVAL port)
{
ASSERT_ARGS(Parrot_io_sockaddr_in)
- PMC * sockaddr;
- char * s;
- s = Parrot_str_to_cstring(interp, addr);
- sockaddr = pmc_new(interp, enum_class_Sockaddr);
+ char * const s = Parrot_str_to_cstring(interp, addr);
+ PMC * const sockaddr = pmc_new(interp, enum_class_Sockaddr);
+
get_sockaddr_in(interp, sockaddr, s, port);
free(s);
return sockaddr;
@@ -131,9 +130,9 @@
Parrot_io_socket_unix(PARROT_INTERP, ARGIN(PMC *s), int fam, int type, int proto)
{
ASSERT_ARGS(Parrot_io_socket_unix)
- int sock, i = 1;
- sock = socket(fam, type, proto);
+ const int sock = socket(fam, type, proto);
if (sock >= 0) {
+ int i = 1;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i));
Parrot_io_set_os_handle(interp, s, sock);
SOCKADDR_REMOTE(s)->sin_family = fam;
@@ -156,7 +155,7 @@
Parrot_io_connect_unix(PARROT_INTERP, ARGMOD(PMC *socket), ARGIN(PMC *r))
{
ASSERT_ARGS(Parrot_io_connect_unix)
- Parrot_Socket_attributes * io = PARROT_SOCKET(socket);
+ const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket);
if (!r)
return -1;
@@ -195,7 +194,7 @@
Parrot_io_bind_unix(PARROT_INTERP, ARGMOD(PMC *socket), ARGMOD(PMC *sockaddr))
{
ASSERT_ARGS(Parrot_io_bind_unix)
- Parrot_Socket_attributes * io = PARROT_SOCKET(socket);
+ const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket);
struct sockaddr_in * saddr;
if (!sockaddr)
@@ -228,7 +227,7 @@
Parrot_io_listen_unix(SHIM_INTERP, ARGMOD(PMC *socket), INTVAL sec)
{
ASSERT_ARGS(Parrot_io_listen_unix)
- Parrot_Socket_attributes * io = PARROT_SOCKET(socket);
+ const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket);
if ((listen(io->os_handle, sec)) == -1) {
return -1;
}
@@ -412,7 +411,7 @@
ASSERT_ARGS(Parrot_io_poll_unix)
fd_set r, w, e;
struct timeval t;
- Parrot_Socket_attributes * io = PARROT_SOCKET(socket);
+ const Parrot_Socket_attributes * const io = PARROT_SOCKET(socket);
t.tv_sec = sec;
t.tv_usec = usec;
@@ -454,11 +453,10 @@
int port)
{
ASSERT_ARGS(get_sockaddr_in)
- struct sockaddr_in *sa;
/* Hard coded to IPv4 for now */
const int family = AF_INET;
- sa = (struct sockaddr_in*)VTABLE_get_pointer(interp, sockaddr);
+ struct sockaddr_in * const sa = (struct sockaddr_in*)VTABLE_get_pointer(interp, sockaddr);
# ifdef PARROT_DEF_INET_ATON
if (inet_aton(host, &sa->sin_addr) != 0) {
# else
More information about the parrot-commits
mailing list