Nmap Development mailing list archives
[PATCH] A couple small changes in *hdump()
From: Kris Katterjohn <kjak () ispwest com>
Date: Wed, 08 Mar 2006 18:33:44 -0600
The attached patch removes a couple unneeded variables and casts from hdump() and lamont_hdump(). 'j' in hdump() and 'bp' in lamont_hdump() can both be removed and the other variables used directly. 'length' was cast to u_int when it's all ready unsigned int. Thanks, Kris
--- utils.cc.orig 2006-03-05 18:00:03.000000000 -0600
+++ utils.cc 2006-03-08 18:17:04.000000000 -0600
@@ -106,13 +106,12 @@ extern NmapOps o;
/* Hex dump */
void hdump(unsigned char *packet, unsigned int len) {
-unsigned int i=0, j=0;
+unsigned int i;
printf("Here it is:\n");
for(i=0; i < len; i++){
- j = (unsigned) (packet[i]);
- printf("%-2X ", j);
+ printf("%-2X ", packet[i]);
if (!((i+1)%16))
printf("\n");
else if (!((i+1)%4))
@@ -129,19 +128,15 @@ void lamont_hdump(char *cp, unsigned int
static const char asciify[] = "................................
!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~.................................................................................................................................";
- const u_short *sp;
- const u_char *ap;
- unsigned char *bp = (unsigned char *) cp;
+ const u_short *sp = (u_short *) cp;
+ const u_char *ap = (u_char *) cp;
u_int i, j;
int nshorts, nshorts2;
int padding;
printf("\n\t");
padding = 0;
- sp = (u_short *)bp;
- ap = (u_char *)bp;
- nshorts = (u_int) length / sizeof(u_short);
- nshorts2 = (u_int) length / sizeof(u_short);
+ nshorts = nshorts2 = length / sizeof(u_short);
i = 0;
j = 0;
while(1) {
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev
Current thread:
- [PATCH] A couple small changes in *hdump() Kris Katterjohn (Mar 08)
