Skip to content
Browse files

Make some counts unsigned ("counts" as in "they're always >= 0").

They don't, for example, use -1 as a special value, so just make the
unsigned.  That squelches some warnings.
  • Loading branch information...
1 parent a436304 commit b27471322197b47fe9a98768c5c7e0377f0c27ab @guyharris guyharris committed Dec 9, 2011
Showing with 12 additions and 12 deletions.
  1. +1 −1 gencode.c
  2. +3 −3 gencode.h
  3. +8 −8 optimize.c
View
2 gencode.c
@@ -418,7 +418,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
{
extern int n_errors;
const char * volatile xbuf = buf;
- int len;
+ u_int len;
no_optimize = 0;
n_errors = 0;
View
6 gencode.h
@@ -240,8 +240,8 @@ struct block {
struct slist *stmts; /* side effect stmts */
struct stmt s; /* branch stmt */
int mark;
- int longjt; /* jt branch requires long jump */
- int longjf; /* jf branch requires long jump */
+ u_int longjt; /* jt branch requires long jump */
+ u_int longjf; /* jf branch requires long jump */
int level;
int offset;
int sense;
@@ -330,7 +330,7 @@ void bpf_error(const char *, ...)
void finish_parse(struct block *);
char *sdup(const char *);
-struct bpf_insn *icode_to_fcode(struct block *, int *);
+struct bpf_insn *icode_to_fcode(struct block *, u_int *);
int pcap_parse(void);
void lex_init(const char *);
void lex_cleanup(void);
View
16 optimize.c
@@ -152,10 +152,10 @@ static void deadstmt(struct stmt *, struct stmt *[]);
static void opt_deadstores(struct block *);
static struct block *fold_edge(struct block *, struct edge *);
static inline int eq_blk(struct block *, struct block *);
-static int slength(struct slist *);
+static u_int slength(struct slist *);
static int count_blocks(struct block *);
static void number_blks_r(struct block *);
-static int count_stmts(struct block *);
+static u_int count_stmts(struct block *);
static int convert_code_r(struct block *);
#ifdef BDEBUG
static void opt_dump(struct block *);
@@ -1904,11 +1904,11 @@ opt_cleanup()
/*
* Return the number of stmts in 's'.
*/
-static int
+static u_int
slength(s)
struct slist *s;
{
- int n = 0;
+ u_int n = 0;
for (; s; s = s->next)
if (s->s.code != NOP)
@@ -1970,11 +1970,11 @@ number_blks_r(p)
*
* an extra long jump if the false branch requires it (p->longjf).
*/
-static int
+static u_int
count_stmts(p)
struct block *p;
{
- int n;
+ u_int n;
if (p == 0 || isMarked(p))
return 0;
@@ -2263,9 +2263,9 @@ convert_code_r(p)
struct bpf_insn *
icode_to_fcode(root, lenp)
struct block *root;
- int *lenp;
+ u_int *lenp;
{
- int n;
+ u_int n;
struct bpf_insn *fp;
/*

0 comments on commit b274713

Please sign in to comment.
Something went wrong with that request. Please try again.