Hello,
In lex(1) the macro flex_die() never returns, so putting control statements
immediately after it is misleading. The macro is wrapped in do{}while(0)
so it can safely appear in 'if' statements without braces.
- Michael
Index: tables.c
===================================================================
RCS file: /cvs/src/usr.bin/lex/tables.c,v
retrieving revision 1.4
diff -u -p -u -r1.4 tables.c
--- tables.c 17 Aug 2017 19:27:09 -0000 1.4
+++ tables.c 27 Aug 2017 09:44:35 -0000
@@ -221,24 +221,18 @@ int yytbl_data_fwrite (struct yytbl_writ
default:
flex_die (_("invalid td_flags detected"));
}
- if (rv < 0) {
+ if (rv < 0)
flex_die (_("error while writing tables"));
- return -1;
- }
bwritten += rv;
}
/* Sanity check */
- if (bwritten != (int) (12 + total_len * YYTDFLAGS2BYTES
(td->td_flags))) {
+ if (bwritten != (int) (12 + total_len * YYTDFLAGS2BYTES (td->td_flags)))
flex_die (_("insanity detected"));
- return -1;
- }
/* add padding */
- if ((rv = yytbl_write_pad64 (wr)) < 0) {
+ if ((rv = yytbl_write_pad64 (wr)) < 0)
flex_die (_("pad64 failed"));
- return -1;
- }
bwritten += rv;
/* Now go back and update the th_hsize member */
@@ -247,7 +241,6 @@ int yytbl_data_fwrite (struct yytbl_writ
|| yytbl_write32 (wr, wr->total_written) < 0
|| fsetpos (wr->out, &pos)) {
flex_die (_("get|set|fwrite32 failed"));
- return -1;
}
else
/* Don't count the int we just wrote. */
@@ -346,7 +339,6 @@ static flex_int32_t yytbl_data_geti (con
return ((flex_int32_t *) (tbl->td_data))[i];
default:
flex_die (_("invalid td_flags detected"));
- break;
}
return 0;
}
@@ -374,7 +366,6 @@ static void yytbl_data_seti (const struc
break;
default:
flex_die (_("invalid td_flags detected"));
- break;
}
}
@@ -433,10 +424,8 @@ void yytbl_data_compress (struct yytbl_d
/* No change in this table needed. */
return;
- if (newsz > (int) YYTDFLAGS2BYTES (tbl->td_flags)) {
+ if (newsz > (int) YYTDFLAGS2BYTES (tbl->td_flags))
flex_die (_("detected negative compression"));
- return;
- }
total_len = yytbl_calc_total_len (tbl);
newtbl.td_data = calloc (total_len, newsz);