1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-18 21:49:01 +00:00

Code cleanup.

Removed unused nse.time_created field.
Use bitfields instead of integers for nse.eof and nse.event_done
Indentation fixes.
This commit is contained in:
henri
2013-04-19 23:21:40 +00:00
parent 13abd4df8a
commit 6d9a68ecb9
3 changed files with 13 additions and 18 deletions

View File

@@ -94,10 +94,10 @@ static int netutils_debugging = 0;
* process and return that maximum value (note -- you better not actually open * process and return that maximum value (note -- you better not actually open
* this many -- stdin, stdout, other files opened by libraries you use, etc. all * this many -- stdin, stdout, other files opened by libraries you use, etc. all
* count toward this limit. Leave a little slack */ * count toward this limit. Leave a little slack */
int maximize_fdlimit(void) { int maximize_fdlimit(void) {
#ifndef WIN32 #ifndef WIN32
struct rlimit r; struct rlimit r;
static int maxfds = -1; static int maxfds = -1;
if (maxfds > 0) if (maxfds > 0)
@@ -146,12 +146,12 @@ int maximize_fdlimit(void) {
#if HAVE_SYS_UN_H #if HAVE_SYS_UN_H
/* Get the UNIX domain socket path or empty string if the address family != AF_UNIX. */ /* Get the UNIX domain socket path or empty string if the address family != AF_UNIX. */
const char *get_unixsock_path(const struct sockaddr_storage *addr) const char *get_unixsock_path(const struct sockaddr_storage *addr) {
{ struct sockaddr_un *su = (struct sockaddr_un *)addr;
if (!addr || addr->ss_family != AF_UNIX) if (!addr || addr->ss_family != AF_UNIX)
return ""; return "";
struct sockaddr_un *su = (struct sockaddr_un *)addr;
return (const char *)su->sun_path; return (const char *)su->sun_path;
} }
#endif #endif
@@ -160,8 +160,7 @@ const char *get_unixsock_path(const struct sockaddr_storage *addr)
* In case we have support for UNIX domain sockets, function returns * In case we have support for UNIX domain sockets, function returns
* string containing path to UNIX socket if the address family is AF_UNIX, * string containing path to UNIX socket if the address family is AF_UNIX,
* otherwise it returns string containing "<address>:<port>". */ * otherwise it returns string containing "<address>:<port>". */
char *get_peeraddr_string(const msiod *iod) char *get_peeraddr_string(const msiod *iod) {
{
static char buffer[PEER_STR_LEN]; static char buffer[PEER_STR_LEN];
#if HAVE_SYS_UN_H #if HAVE_SYS_UN_H

View File

@@ -438,12 +438,12 @@ msevent *msevent_new(mspool *nsp, enum nse_type type, msiod *msiod, int timeout_
nse->iod = msiod; nse->iod = msiod;
nse->handler = handler; nse->handler = handler;
nse->userdata = userdata; nse->userdata = userdata;
nse->time_created = nsock_tod;
if (nse->iod == NULL) if (nse->iod == NULL)
nsock_log_debug(nsp, "msevent_new (IOD #NULL) (EID #%li)", nse->id); nsock_log_debug(nsp, "msevent_new (IOD #NULL) (EID #%li)", nse->id);
else else
nsock_log_debug(nsp, "msevent_new (IOD #%li) (EID #%li)", nse->iod->id, nse->id); nsock_log_debug(nsp, "msevent_new (IOD #%li) (EID #%li)", nse->iod->id,
nse->id);
return nse; return nse;
} }

View File

@@ -312,7 +312,6 @@ typedef struct {
/* nsock_event_t handles a single event. Its ID is generally returned when the /* nsock_event_t handles a single event. Its ID is generally returned when the
* event is created, and the event is included in callbacks */ * event is created, and the event is included in callbacks */
typedef struct { typedef struct {
/* Every event has an ID which is unique for a given nsock unless you blow /* Every event has an ID which is unique for a given nsock unless you blow
* through more than 500,000,000 events */ * through more than 500,000,000 events */
nsock_event_id id; nsock_event_id id;
@@ -340,8 +339,6 @@ typedef struct {
/* If we return a status of NSE_STATUS_ERROR, this must be set */ /* If we return a status of NSE_STATUS_ERROR, this must be set */
int errnum; int errnum;
int eof;
/* The nsock I/O descriptor related to event (if applicable) */ /* The nsock I/O descriptor related to event (if applicable) */
msiod *iod; msiod *iod;
@@ -355,9 +352,8 @@ typedef struct {
* event_done is nonzero. Used when event is finished at unexpected time and * event_done is nonzero. Used when event is finished at unexpected time and
* we want to dispatch it later to avoid duplicating stat update code and all * we want to dispatch it later to avoid duplicating stat update code and all
* that other crap */ * that other crap */
int event_done; unsigned int event_done: 1;
unsigned int eof: 1;
struct timeval time_created;
} msevent; } msevent;