xdtoi turns an (unsigned) 8-bit character from a string into a hex digit
value, which is also an unsigned 8-bit byte value; make it take a u_char
as an argument and return a u_char, and make the octet value accumulated
in pcap_next_etherent() a u_char as well.
Use a size_t variable for a size.
#include "os-proto.h"
#endif
#include "os-proto.h"
#endif
-static inline int xdtoi(int);
static inline int skip_space(FILE *);
static inline int skip_line(FILE *);
/* Hex digit to integer. */
static inline int skip_space(FILE *);
static inline int skip_line(FILE *);
/* Hex digit to integer. */
-static inline int
-xdtoi(int c)
+static inline u_char
+xdtoi(u_char c)
+ return (u_char)(c - '0');
+ return (u_char)(c - 'a' + 10);
+ return (u_char)(c - 'A' + 10);
struct pcap_etherent *
pcap_next_etherent(FILE *fp)
{
struct pcap_etherent *
pcap_next_etherent(FILE *fp)
{
+ register int c, i;
+ u_char d;
static struct pcap_etherent e;
memset((char *)&e, 0, sizeof(e));
static struct pcap_etherent e;
memset((char *)&e, 0, sizeof(e));
/* pick up name */
bp = e.name;
/* pick up name */
bp = e.name;
- /* Use 'd' to prevent buffer overflow. */
- d = sizeof(e.name) - 1;
+ /* Use 'namesize' to prevent buffer overflow. */
+ namesize = sizeof(e.name) - 1;
do {
*bp++ = c;
c = getc(fp);
if (c == EOF)
return (NULL);
do {
*bp++ = c;
c = getc(fp);
if (c == EOF)
return (NULL);
- } while (!isspace(c) && --d > 0);
+ } while (!isspace(c) && --namesize != 0);
*bp = '\0';
/* Eat trailing junk */
*bp = '\0';
/* Eat trailing junk */