common: no logic changes, code cleanup

master
Jay Sorg 13 years ago
parent 0944509cf0
commit 7dc5a77116

@ -329,7 +329,7 @@ g_getchar(void)
int APP_CC
g_tcp_set_no_delay(int sck)
{
int ret = 1 ; /*error*/
int ret = 1; /* error */
#if defined(_WIN32)
int option_value;
int option_len;
@ -347,10 +347,10 @@ g_tcp_set_no_delay(int sck)
{
option_value = 1;
option_len = sizeof(option_value);
if(setsockopt(sck, IPPROTO_TCP, TCP_NODELAY, (char*)&option_value,
option_len)==0)
if (setsockopt(sck, IPPROTO_TCP, TCP_NODELAY, (char*)&option_value,
option_len) == 0)
{
ret = 0 ; /* success */
ret = 0; /* success */
}
}
}
@ -366,7 +366,7 @@ g_tcp_set_no_delay(int sck)
int APP_CC
g_tcp_set_keepalive(int sck)
{
int ret = 1 ; /*error*/
int ret = 1; /* error */
#if defined(_WIN32)
int option_value;
int option_len;
@ -384,10 +384,10 @@ g_tcp_set_keepalive(int sck)
{
option_value = 1;
option_len = sizeof(option_value);
if(setsockopt(sck, SOL_SOCKET, SO_KEEPALIVE, (char*)&option_value,
option_len)==0)
if (setsockopt(sck, SOL_SOCKET, SO_KEEPALIVE, (char*)&option_value,
option_len) == 0)
{
ret = 0 ; /* success */
ret = 0; /* success */
}
}
}
@ -1124,42 +1124,46 @@ g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs, int wcount,
}
FD_ZERO(&rfds);
FD_ZERO(&wfds);
/*Find the highest descriptor number in read_obj */
if(read_objs!=NULL){
/* Find the highest descriptor number in read_obj */
if (read_objs!=NULL)
{
for (i = 0; i < rcount; i++)
{
sck = (int)(read_objs[i]);
if (sck > 0) {
if (sck > 0)
{
FD_SET(sck, &rfds);
if (sck > max)
{
max = sck; /*max holds the highest socket/descriptor number */
max = sck; /* max holds the highest socket/descriptor number */
}
}
}
}
else if(rcount>0)
else if (rcount>0)
{
g_writeln("Programming error read_objs is null");
return 1; /*error*/
return 1; /* error */
}
if(write_objs!=NULL){
if (write_objs!=NULL)
{
for (i = 0; i < wcount; i++)
{
sck = (int)(write_objs[i]);
if (sck > 0) {
if (sck > 0)
{
FD_SET(sck, &wfds);
if (sck > max)
{
max = sck; /*max holds the highest socket/descriptor number */
max = sck; /* max holds the highest socket/descriptor number */
}
}
}
}
else if(wcount>0)
else if (wcount > 0)
{
g_writeln("Programming error write_objs is null");
return 1; /*error*/
return 1; /* error */
}
res = select(max + 1, &rfds, &wfds, 0, ptime);
if (res < 0)
@ -1172,7 +1176,7 @@ g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs, int wcount,
{
return 0;
}
return 1; /*error*/
return 1; /* error */
}
return 0;
#endif
@ -1632,7 +1636,8 @@ g_strdup(const char* in)
}
len = g_strlen(in);
p = (char*)g_malloc(len + 1, 0);
if (p != NULL) {
if (p != NULL)
{
g_strcpy(p, in);
}
return p;
@ -1652,9 +1657,9 @@ g_strndup(const char* in, const unsigned int maxlen)
return 0;
}
len = g_strlen(in);
if(len>maxlen)
if (len>maxlen)
{
len = maxlen-1 ;
len = maxlen - 1;
}
p = (char*)g_malloc(len + 2, 0);
if (p != NULL)

Loading…
Cancel
Save