[PATCH 1/2] build: fix ncurses cflags and ldflags
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
Makefile | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index 1429aca..dd5aed2 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,6 @@ all::
#
# Define NO_NCURSES if not linking with ncurses.
-
VERSION-FILE: FORCE
@$(SHELL_PATH) ./GEN-VERSION-FILE
-include VERSION-FILE
@@ -208,13 +207,12 @@ NCURSES_LDFLAGS += $(NCURSES6_LDFLAGS)
endif
NCURSES5_CFLAGS := $(shell ncurses5-config --cflags 2>/dev/null)
-ifneq ($(NCURSES5_LDFLAGS),)
-NCURSES_LDFLAGS += $(NCURSES5_CFLAGS)
+ifneq ($(NCURSES5_CFLAGS),)
+NCURSES_CFLAGS += $(NCURSES5_CFLAGS)
endif
-
-NCURSES_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
-ifneq ($(NCURSES_LDFLAGS),)
-NCURSES_LDFLAGS += $(NCURSES_LDFLAGS)
+NCURSES5_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
+ifneq ($(NCURSES5_LDFLAGS),)
+NCURSES_LDFLAGS += $(NCURSES5_LDFLAGS)
endif
NCURSES_LDFLAGS += -lpanel
@@ -329,7 +327,7 @@ endif
ifndef CHECK_HEADER_DEPENDENCIES
$(OBJECTS): %.o: %.c $(missing_dep_dirs)
- $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
+ $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(NCURSES_CFLAGS) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
endif
ifdef USE_COMPUTED_HEADER_DEPENDENCIES
--
1.7.10
11 years, 11 months
Bug report: window resize and ncursesw support
by Ricardo Catalinas Jiménez
1. Using iptraf-ng 1.1.2 on Arch Linux x86_64, window resize seems
broken. A segmentation fault happens when the terminal size changes.
But probably you are aware of this bug :-/
2. Arch Linux uses ncurses compiled with wide character support by
default but with symlinks from libncursesw.so to libncurses.so for
compatibility. But only `ncursesw5-config' is installed. Would be
great to improve configure.ac:
---8<-- configure.ac ---------------------------------------------------
dnl checks for libraries ncurses[5,6]
dnl removed ncursesw[5,6]; iptraf-ng does not use it
AC_CHECK_PROG([ncurses5_config], [ncurses5-config], [yes])
AC_CHECK_PROG([ncurses6_config], [ncurses6-config], [yes])
if test "x$ncurses6_config" = "xyes"; then
libncurses_CFLAGS=$("ncurses6-config" --cflags)
libncurses_LIBS=$("ncurses6-config" --libs)
elif test "x$ncurses5_config" = "xyes"; then
libncurses_CFLAGS=$("ncurses5-config" --cflags)
libncurses_LIBS=$("ncurses5-config" --libs)
else
AC_MSG_ERROR([Install ncurses5-dev or ncurses6-dev])
fi
---8<-------------------------------------------------------------------
Basically, Arch Linux have only `ncursesw5-config' so check for its
presence and use it. So, could be possible to add?:
AC_CHECK_PROG([ncursesw5_config], [ncursesw5-config], [yes])
AC_CHECK_PROG([ncursesw6_config], [ncursesw6-config], [yes])
And adding the elif branches using it in the same way would suffice.
Just suggesting..., any feedback will be welcomed :-)
Best regards and thanks for such a great project!
--
Ricardo (http://r.untroubled.be/)
11 years, 11 months
[PATCH 0/3] iptraf-ng
by Vitezslav Samel
Cleanups:
- logging needs far more work than this
Don't forget to set the correct date in CHANGES file when you decide
to release new version!
Vitezslav Samel (3):
sanitize check_rotate_flag() calls
fix dependency for files with IPTRAF_NAME and/or IPTRAF_VERSION
prepare CHANGES for new release
CHANGES | 9 +++++++++
Makefile | 1 +
src/detstats.c | 31 +++++++++++++++++--------------
src/hostmon.c | 22 +++++++++++++---------
src/ifstats.c | 23 +++++++++++++----------
src/itrafmon.c | 48 ++++++++++++++++++++++++------------------------
src/log.c | 4 ++--
src/log.h | 2 +-
src/pktsize.c | 20 ++++++++++++--------
src/serv.c | 21 ++++++++++++---------
10 files changed, 104 insertions(+), 77 deletions(-)
--
1.7.8.4
11 years, 11 months
[PATCH] kill NULL pointer casting
by Vitezslav Samel
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/detstats.c | 4 ++--
src/fltedit.c | 2 +-
src/hostmon.c | 2 +-
src/ifstats.c | 4 ++--
src/itrafmon.c | 5 ++---
src/log.c | 4 ++--
src/othptab.c | 2 +-
src/packet.c | 2 +-
src/pktsize.c | 2 +-
src/rvnamed.c | 5 ++---
src/serv.c | 2 +-
src/tui/menurt.c | 4 ++--
12 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/src/detstats.c b/src/detstats.c
index 6b13898..015621c 100644
--- a/src/detstats.c
+++ b/src/detstats.c
@@ -483,7 +483,7 @@ void detstats(char *iface, const struct OPTIONS *options, time_t facilitytime,
peakactivity, peakpps, peakactivity_in,
peakpps_in, peakactivity_out, peakpps_out,
&ifcounts,
- time((time_t *) NULL) - statbegin,
+ time(NULL) - statbegin,
logfile);
startlog = now;
@@ -619,7 +619,7 @@ err:
writedstatlog(iface, options->actmode,
peakactivity, peakpps, peakactivity_in,
peakpps_in, peakactivity_out, peakpps_out,
- &ifcounts, time((time_t *) NULL) - statbegin,
+ &ifcounts, time(NULL) - statbegin,
logfile);
writelog(logging, logfile,
"******** Detailed interface statistics stopped ********");
diff --git a/src/fltedit.c b/src/fltedit.c
index c602e69..aed3936 100644
--- a/src/fltedit.c
+++ b/src/fltedit.c
@@ -514,7 +514,7 @@ void definefilter(int *aborted)
clear_flt_tag();
return;
}
- genname(time((time_t *) NULL), fntemp);
+ genname(time(NULL), fntemp);
pfd =
open(get_path(T_WORKDIR, fntemp), O_CREAT | O_WRONLY | O_TRUNC,
diff --git a/src/hostmon.c b/src/hostmon.c
index 87b0b46..186617b 100644
--- a/src/hostmon.c
+++ b/src/hostmon.c
@@ -1069,7 +1069,7 @@ err:
if (logging) {
signal(SIGUSR1, SIG_DFL);
writeethlog(table.head, options->actmode,
- time((time_t *) NULL) - statbegin, logfile);
+ time(NULL) - statbegin, logfile);
writelog(logging, logfile,
"******** LAN traffic monitor stopped ********");
fclose(logfile);
diff --git a/src/ifstats.c b/src/ifstats.c
index 0746a13..fe3cadd 100644
--- a/src/ifstats.c
+++ b/src/ifstats.c
@@ -541,7 +541,7 @@ void ifstats(const struct OPTIONS *options, struct filterstate *ofilter,
}
if (((now - startlog) >= options->logspan) && (logging)) {
writegstatlog(&table, options->actmode,
- time((time_t *) NULL) - statbegin,
+ time(NULL) - statbegin,
logfile);
startlog = now;
}
@@ -650,7 +650,7 @@ err:
if (logging) {
signal(SIGUSR1, SIG_DFL);
writegstatlog(&table, options->actmode,
- time((time_t *) NULL) - statbegin, logfile);
+ time(NULL) - statbegin, logfile);
writelog(logging, logfile,
"******** General interface statistics stopped ********");
fclose(logfile);
diff --git a/src/itrafmon.c b/src/itrafmon.c
index 34c9fb8..e26f6b9 100644
--- a/src/itrafmon.c
+++ b/src/itrafmon.c
@@ -192,7 +192,7 @@ static void scrolllowerwin(struct othptable *table, int direction)
table->htstat = NOHTIND;
}
printothpentry(table, table->lastvisible,
- table->oimaxy - 1, 0, (FILE *) NULL);
+ table->oimaxy - 1, 0, NULL);
}
} else {
if (table->firstvisible != table->head) {
@@ -205,8 +205,7 @@ static void scrolllowerwin(struct othptable *table, int direction)
whline(table->borderwin, ACS_HLINE, 8);
table->htstat = NOHTIND;
}
- printothpentry(table, table->firstvisible, 0, 0,
- (FILE *) NULL);
+ printothpentry(table, table->firstvisible, 0, 0, NULL);
}
}
}
diff --git a/src/log.c b/src/log.c
index d2b8b03..2a3d12d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -104,7 +104,7 @@ void writelog(int logging, FILE * fd, char *msg)
char atime[TIME_TARGET_MAX];
if (logging) {
- genatime(time((time_t *) NULL), atime);
+ genatime(time(NULL), atime);
fprintf(fd, "%s; %s\n", atime, msg);
}
@@ -116,7 +116,7 @@ void write_daemon_err(char *msg, va_list vararg)
char atime[TIME_TARGET_MAX];
FILE *fd;
- genatime(time((time_t *) NULL), atime);
+ genatime(time(NULL), atime);
fd = fopen(DAEMONLOG, "a");
fprintf(fd, "%s iptraf[%u]: ", atime, getpid());
vfprintf(fd, msg, vararg);
diff --git a/src/othptab.c b/src/othptab.c
index 08574fb..dbd392c 100644
--- a/src/othptab.c
+++ b/src/othptab.c
@@ -766,7 +766,7 @@ void refresh_othwindow(struct othptable *table)
entry = table->firstvisible;
while ((entry != NULL) && (entry != table->lastvisible->next_entry)) {
- printothpentry(table, entry, target_row, 0, (FILE *) NULL);
+ printothpentry(table, entry, target_row, 0, NULL);
target_row++;
entry = entry->next_entry;
}
diff --git a/src/packet.c b/src/packet.c
index 841a495..3e7181a 100644
--- a/src/packet.c
+++ b/src/packet.c
@@ -122,7 +122,7 @@ static int packet_adjust(struct pkt_hdr *pkt)
/* return a NULL packet to signal an unrecognized link */
/* protocol to the caller. Hopefully, this switch statement */
/* will grow. */
- pkt->pkt_payload = (char *) NULL;
+ pkt->pkt_payload = NULL;
retval = -1;
break;
}
diff --git a/src/pktsize.c b/src/pktsize.c
index c6317ea..4715eff 100644
--- a/src/pktsize.c
+++ b/src/pktsize.c
@@ -49,7 +49,7 @@ static void write_size_log(struct ifstat_brackets *brackets,
char atime[TIME_TARGET_MAX];
int i;
- genatime(time((time_t *) NULL), atime);
+ genatime(time(NULL), atime);
fprintf(logfile, "*** Packet Size Distribution, generated %s\n\n",
atime);
fprintf(logfile, "Interface: %s MTU: %u\n\n", ifname, mtu);
diff --git a/src/rvnamed.c b/src/rvnamed.c
index b4795a6..6171f17 100644
--- a/src/rvnamed.c
+++ b/src/rvnamed.c
@@ -169,7 +169,7 @@ static void writervnlog(FILE * fd, char *msg)
time_t now;
char atime[TIME_TARGET_MAX] = "";
- now = time((time_t *) NULL);
+ now = time(NULL);
strcpy(atime, ctime(&now));
atime[strlen(atime) - 1] = '\0';
@@ -283,8 +283,7 @@ int main(void)
FD_SET(ifd, &sockset);
do {
- ss = select(ifd + 1, &sockset, NULL, NULL,
- (struct timeval *) NULL);
+ ss = select(ifd + 1, &sockset, NULL, NULL, NULL);
} while ((ss < 0) && (errno != ENOMEM));
if (errno == ENOMEM) {
diff --git a/src/serv.c b/src/serv.c
index 210d013..9a7e4e8 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -1137,7 +1137,7 @@ err_close:
err:
if (logging) {
signal(SIGUSR1, SIG_DFL);
- writeutslog(list.head, time((time_t *) NULL) - starttime,
+ writeutslog(list.head, time(NULL) - starttime,
options->actmode, logfile);
writelog(logging, logfile,
"******** TCP/UDP service monitor stopped ********");
diff --git a/src/tui/menurt.c b/src/tui/menurt.c
index 68dc689..b64a4c1 100644
--- a/src/tui/menurt.c
+++ b/src/tui/menurt.c
@@ -116,9 +116,9 @@ void tx_showitem(struct MENU *menu, struct ITEM *itemptr, int selected)
wattrset(menu->menuwin, loattr);
wprintw(menu->menuwin, "%s", strtok(curoption, "^"));
wattrset(menu->menuwin, hiattr);
- wprintw(menu->menuwin, "%s", strtok((char *) NULL, "^"));
+ wprintw(menu->menuwin, "%s", strtok(NULL, "^"));
wattrset(menu->menuwin, loattr);
- wprintw(menu->menuwin, "%s", strtok((char *) NULL, "^"));
+ wprintw(menu->menuwin, "%s", strtok(NULL, "^"));
strcpy(padding, "");
--
1.7.8.4
11 years, 11 months
[PATCH] use IPTRAF_NAME where appropriate
by Vitezslav Samel
Change hard-coded "iptraf-ng" string into IPTRAF_NAME define.
Also print IPTRAF_VERSION in the first line.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
Makefile | 3 ++-
src/iptraf.c | 8 ++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 00661ed..9db7942 100644
--- a/Makefile
+++ b/Makefile
@@ -268,7 +268,8 @@ iptraf-ng: $(iptraf-o)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ \
$(iptraf-o) $(ALL_LDFLAGS) $(NCURSES_LDFLAGS)
-src/deskman.o: EXTRA_CPPFLAGS = -DIPTRAF_VERSION='"$(IPTRAF_VERSION)"' \
+src/deskman.o src/iptraf.o: EXTRA_CPPFLAGS = \
+ -DIPTRAF_VERSION='"$(IPTRAF_VERSION)"' \
-DIPTRAF_NAME='"iptraf-ng"'
rvnamed-ng: $(rvnamed-o)
diff --git a/src/iptraf.c b/src/iptraf.c
index a6c3192..0cf91b9 100644
--- a/src/iptraf.c
+++ b/src/iptraf.c
@@ -286,8 +286,8 @@ static void mark_first_instance(void)
}
static const char *const iptraf_ng_usage[] = {
- "iptraf-ng [options]",
- "iptraf-ng [options] -B [-i <iface> | -d <iface> | -s <iface> | -z <iface> | -l <iface> | -g]",
+ IPTRAF_NAME " [options]",
+ IPTRAF_NAME " [options] -B [-i <iface> | -d <iface> | -s <iface> | -z <iface> | -l <iface> | -g]",
NULL
};
@@ -442,7 +442,7 @@ int main(int argc, char **argv)
options.logging = 1;
break;
case -1: /* error */
- die("Fork error, iptraf-ng cannot run in background");
+ die("Fork error, %s cannot run in background", IPTRAF_NAME);
default: /* parent */
exit(0);
}
@@ -523,7 +523,7 @@ int main(int argc, char **argv)
* */
draw_desktop();
attrset(STATUSBARATTR);
- mvprintw(0, 1, "iptraf-ng");
+ mvprintw(0, 1, "%s %s", IPTRAF_NAME, IPTRAF_VERSION);
/* simplify */
if (g_opt)
--
1.7.8.4
11 years, 11 months
[PATCH v2 0/4] iptraf-ng: rate: moving average
by Vitezslav Samel
This patch series implements better rate printing using
moving average. This gives us rate printed every second
averaged over last 5 seconds.
It's done only for ifstats() and detstats(), the others
will come later.
v2:
- style fixes
- change modulus into if/else
- kill __timeval_diff_msec()
v1:
- first try
Vitezslav Samel (4):
add moving average computing functions
add timeval_diff_msec() function
use struct rate in ifstats()
use struct rate in detstats()
Makefile | 2 +
src/detstats.c | 178 ++++++++++++++++++++++++------------------------
src/ifstats.c | 70 +++++++++----------
src/iptraf-ng-compat.h | 20 ++++++
src/rate.c | 106 ++++++++++++++++++++++++++++
src/rate.h | 34 +++++++++
6 files changed, 284 insertions(+), 126 deletions(-)
create mode 100644 src/rate.c
create mode 100644 src/rate.h
--
1.7.8.4
11 years, 11 months
[PATCH 0/4] iptraf-ng: rate: moving average
by Vitezslav Samel
This patch series implements better rate printing using
moving average. This gives us rate printed every second
averaged over last 5 seconds.
It's done only for ifstats() and detstats(), the others
will come later.
Vitezslav Samel (4):
add moving average computing functions
add timeval_diff_msec() function
use struct rate in ifstats()
use struct rate in detstats()
Makefile | 2 +
src/detstats.c | 178 ++++++++++++++++++++++++------------------------
src/ifstats.c | 70 +++++++++----------
src/iptraf-ng-compat.h | 27 +++++++
src/rate.c | 100 +++++++++++++++++++++++++++
src/rate.h | 33 +++++++++
6 files changed, 284 insertions(+), 126 deletions(-)
create mode 100644 src/rate.c
create mode 100644 src/rate.h
--
1.7.8.4
11 years, 11 months
[PATCH 0/3] iptraf-ng: build system fixes
by Vitezslav Samel
Vitezslav Samel (3):
Makefile: dependency fix
set the right default version
Makefile: link rvnamed with $(ALL_LDFLAGS)
GEN-VERSION-FILE | 2 +-
Makefile | 23 ++++++++++-------------
2 files changed, 11 insertions(+), 14 deletions(-)
--
1.7.8.4
11 years, 11 months
[PATCH] use xmallocz()
by Vitezslav Samel
Replace xmalloc() followed by memset( ..., 0, ...) with xmallocz().
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/fltedit.c | 14 ++------------
src/ipfrag.c | 3 +--
src/othptab.c | 3 +--
src/tcptable.c | 9 +++------
4 files changed, 7 insertions(+), 22 deletions(-)
diff --git a/src/fltedit.c b/src/fltedit.c
index f5746c9..c602e69 100644
--- a/src/fltedit.c
+++ b/src/fltedit.c
@@ -175,14 +175,6 @@ void update_hp_screen(struct filterent *firstvisible, WINDOW * win)
scrollok(win, 1);
}
-int new_hp_entry(struct filterent **ftemp)
-{
- *ftemp = xmalloc(sizeof(struct filterent));
- memset(*ftemp, 0, sizeof(struct filterent));
- return 1;
-}
-
-
void modify_host_parameters(struct filterlist *fl)
{
WINDOW *bwin;
@@ -292,8 +284,7 @@ void modify_host_parameters(struct filterlist *fl)
case 'i':
case 'I':
case KEY_IC:
- if (!new_hp_entry(&ftemp))
- break;
+ ftemp = xmallocz(sizeof(struct filterent));
gethostparams(&(ftemp->hp), "", "", "", "", "", "", "",
"", "I", "N", &gh_aborted);
@@ -335,8 +326,7 @@ void modify_host_parameters(struct filterlist *fl)
case 'a':
case 'A':
case 1:
- if (!new_hp_entry(&ftemp))
- break;
+ ftemp = xmallocz(sizeof(struct filterent));
gethostparams(&(ftemp->hp), "", "", "", "", "", "", "",
"", "I", "N", &gh_aborted);
diff --git a/src/ipfrag.c b/src/ipfrag.c
index 5e92da4..15a06f1 100644
--- a/src/ipfrag.c
+++ b/src/ipfrag.c
@@ -26,7 +26,7 @@ static struct fragent *addnewdgram(struct iphdr *packet)
{
struct fragent *ptmp;
- ptmp = xmalloc(sizeof(struct fragent));
+ ptmp = xmallocz(sizeof(struct fragent));
if (fraglist == NULL) {
fraglist = ptmp;
ptmp->prev_entry = NULL;
@@ -35,7 +35,6 @@ static struct fragent *addnewdgram(struct iphdr *packet)
fragtail->next_entry = ptmp;
ptmp->prev_entry = fragtail;
}
- memset(ptmp, 0, sizeof(struct fragent));
ptmp->fragdesclist = xmalloc(sizeof(struct fragdescent));
ptmp->fragdesclist->min = 0;
ptmp->fragdesclist->max = 65535;
diff --git a/src/othptab.c b/src/othptab.c
index 77efe6e..08574fb 100644
--- a/src/othptab.c
+++ b/src/othptab.c
@@ -175,8 +175,7 @@ struct othptabent *add_othp_entry(struct othptable *table, struct pkt_hdr *pkt,
struct in_addr isaddr, idaddr;
char *packet = pkt->pkt_buf;
- new_entry = xmalloc(sizeof(struct othptabent));
- memset(new_entry, 0, sizeof(struct othptabent));
+ new_entry = xmallocz(sizeof(struct othptabent));
new_entry->is_ip = is_ip;
new_entry->fragment = fragment;
diff --git a/src/tcptable.c b/src/tcptable.c
index a26607a..bcc24ff 100644
--- a/src/tcptable.c
+++ b/src/tcptable.c
@@ -141,8 +141,7 @@ static void add_tcp_hash_entry(struct tcptable *table, struct tcptableent *entry
entry->sport, entry->daddr.s_addr,
entry->d6addr.s6_addr32, entry->dport, entry->ifname);
- ptmp = xmalloc(sizeof(struct tcp_hashentry));
- memset(ptmp, 0, sizeof(struct tcp_hashentry));
+ ptmp = xmallocz(sizeof(struct tcp_hashentry));
/*
* Add backpointer from screen node to hash node for deletion later
* (Actually point to its predecessor coz of the header cell).
@@ -518,13 +517,11 @@ struct tcptableent *in_table(struct tcptable *table, unsigned long saddr,
hashptr = table->hash_table[hp];
if (s6addr == NULL) {
- s6addr = xmalloc(sizeof(struct in6_addr));
- memset(s6addr, 0, 16);
+ s6addr = xmallocz(sizeof(struct in6_addr));
sfree = 1;
}
if (d6addr == NULL) {
- d6addr = xmalloc(sizeof(struct in6_addr));
- memset(d6addr, 0, 16);
+ d6addr = xmallocz(sizeof(struct in6_addr));
dfree = 1;
}
while (hashptr != NULL) {
--
1.7.8.4
11 years, 11 months
[PATCH] use xmallocz()
by Vitezslav Samel
Replace xmalloc() followed by memset( ..., 0, ...) with xmallocz().
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/fltedit.c | 3 +--
src/ipfrag.c | 3 +--
src/othptab.c | 3 +--
src/tcptable.c | 9 +++------
4 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/src/fltedit.c b/src/fltedit.c
index f5746c9..90cf471 100644
--- a/src/fltedit.c
+++ b/src/fltedit.c
@@ -177,8 +177,7 @@ void update_hp_screen(struct filterent *firstvisible, WINDOW * win)
int new_hp_entry(struct filterent **ftemp)
{
- *ftemp = xmalloc(sizeof(struct filterent));
- memset(*ftemp, 0, sizeof(struct filterent));
+ *ftemp = xmallocz(sizeof(struct filterent));
return 1;
}
diff --git a/src/ipfrag.c b/src/ipfrag.c
index 5e92da4..15a06f1 100644
--- a/src/ipfrag.c
+++ b/src/ipfrag.c
@@ -26,7 +26,7 @@ static struct fragent *addnewdgram(struct iphdr *packet)
{
struct fragent *ptmp;
- ptmp = xmalloc(sizeof(struct fragent));
+ ptmp = xmallocz(sizeof(struct fragent));
if (fraglist == NULL) {
fraglist = ptmp;
ptmp->prev_entry = NULL;
@@ -35,7 +35,6 @@ static struct fragent *addnewdgram(struct iphdr *packet)
fragtail->next_entry = ptmp;
ptmp->prev_entry = fragtail;
}
- memset(ptmp, 0, sizeof(struct fragent));
ptmp->fragdesclist = xmalloc(sizeof(struct fragdescent));
ptmp->fragdesclist->min = 0;
ptmp->fragdesclist->max = 65535;
diff --git a/src/othptab.c b/src/othptab.c
index 77efe6e..08574fb 100644
--- a/src/othptab.c
+++ b/src/othptab.c
@@ -175,8 +175,7 @@ struct othptabent *add_othp_entry(struct othptable *table, struct pkt_hdr *pkt,
struct in_addr isaddr, idaddr;
char *packet = pkt->pkt_buf;
- new_entry = xmalloc(sizeof(struct othptabent));
- memset(new_entry, 0, sizeof(struct othptabent));
+ new_entry = xmallocz(sizeof(struct othptabent));
new_entry->is_ip = is_ip;
new_entry->fragment = fragment;
diff --git a/src/tcptable.c b/src/tcptable.c
index a26607a..bcc24ff 100644
--- a/src/tcptable.c
+++ b/src/tcptable.c
@@ -141,8 +141,7 @@ static void add_tcp_hash_entry(struct tcptable *table, struct tcptableent *entry
entry->sport, entry->daddr.s_addr,
entry->d6addr.s6_addr32, entry->dport, entry->ifname);
- ptmp = xmalloc(sizeof(struct tcp_hashentry));
- memset(ptmp, 0, sizeof(struct tcp_hashentry));
+ ptmp = xmallocz(sizeof(struct tcp_hashentry));
/*
* Add backpointer from screen node to hash node for deletion later
* (Actually point to its predecessor coz of the header cell).
@@ -518,13 +517,11 @@ struct tcptableent *in_table(struct tcptable *table, unsigned long saddr,
hashptr = table->hash_table[hp];
if (s6addr == NULL) {
- s6addr = xmalloc(sizeof(struct in6_addr));
- memset(s6addr, 0, 16);
+ s6addr = xmallocz(sizeof(struct in6_addr));
sfree = 1;
}
if (d6addr == NULL) {
- d6addr = xmalloc(sizeof(struct in6_addr));
- memset(d6addr, 0, 16);
+ d6addr = xmallocz(sizeof(struct in6_addr));
dfree = 1;
}
while (hashptr != NULL) {
--
1.7.8.4
11 years, 11 months