usr.bin/indent nearly builds clean with -Wall -Werror.  The diff below
adds both to CFLAGS and fixes the minor fallout.  Arguably, this
doesn't buy us that much, but it makes me feel a little warmer before
I start making too many more changes.

I believe initializing tabs_to_var to zero is safe because when
tabs_to_var is set on line 894 in indent.c it defaults to 0 when not
using tabs anyways:

tabs_to_var = (use_tabs ? ps.decl_indent > 0 : 0);

I believe initializing target_col to one is safe because target_col
is set on line 138 in io.c:

target_col = compute_code_target();

And compute_code_target(void) initializes target_col to one when the
indentation level is zero:

int
compute_code_target(void)
{
    int target_col;

    target_col = ps.ind_size * ps.ind_level + 1;
...

This diff should be applied in usr.bin/indent/.  (I just noticed that
"RCS file" in these diffs is pointing to my local cvsync mirror; will
that cause problems for others when trying to apply these diffs?)


Index: Makefile
===================================================================
RCS file: /work/cvsroot/src/usr.bin/indent/Makefile,v
retrieving revision 1.2
diff -p -u -r1.2 Makefile
--- Makefile    26 Jun 1996 05:34:27 -0000      1.2
+++ Makefile    24 Dec 2013 19:11:24 -0000
@@ -3,4 +3,6 @@
 PROG=  indent
 SRCS=  indent.c io.c lexi.c parse.c pr_comment.c args.c
 
+CFLAGS+= -Wall -Werror
+
 .include <bsd.prog.mk>
Index: indent.c
===================================================================
RCS file: /work/cvsroot/src/usr.bin/indent/indent.c,v
retrieving revision 1.23
diff -p -u -r1.23 indent.c
--- indent.c    26 Nov 2013 13:21:17 -0000      1.23
+++ indent.c    24 Dec 2013 19:14:22 -0000
@@ -132,6 +132,7 @@ main(int argc, char **argv)
 
     output = 0;
 
+    tabs_to_var = 0;
 
 
     /*--------------------------------------------------*\
Index: io.c
===================================================================
RCS file: /work/cvsroot/src/usr.bin/indent/io.c,v
retrieving revision 1.13
diff -p -u -r1.13 io.c
--- io.c        26 Nov 2013 13:21:17 -0000      1.13
+++ io.c        24 Dec 2013 19:13:51 -0000
@@ -53,6 +53,8 @@ dump_line(void)
     int         cur_col, target_col;
     static int  not_first_line;
 
+    target_col = 1;
+
     if (ps.procname[0]) {
        if (troff) {
            if (comment_open) {

Reply via email to