[master] db83e59a6 That was just a warning

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Dec 6 13:36:07 UTC 2019


commit db83e59a6c75919e39d0dbce2e4ee0dfcb577a81
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Nov 8 13:52:44 2019 +0100

    That was just a warning

diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 74871e421..9e1875c8b 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -374,6 +374,7 @@ void vcc_Coord(const struct vcc *tl, struct vsb *vsb,
 void vcc_ErrToken(const struct vcc *tl, const struct token *t);
 void vcc_ErrWhere(struct vcc *, const struct token *);
 void vcc_ErrWhere2(struct vcc *, const struct token *, const struct token *);
+void vcc_Warn(struct vcc *);
 
 void vcc__Expect(struct vcc *tl, unsigned tok, unsigned line);
 int vcc_IdIs(const struct token *t, const char *p);
diff --git a/lib/libvcc/vcc_token.c b/lib/libvcc/vcc_token.c
index 04e10f96b..20caadabe 100644
--- a/lib/libvcc/vcc_token.c
+++ b/lib/libvcc/vcc_token.c
@@ -183,6 +183,16 @@ vcc_markline(const struct vcc *tl, const char *l, const char *le,
 	VSB_putc(tl->sb, '\n');
 }
 
+void
+vcc_Warn(struct vcc *tl)
+{
+
+	AN(tl);
+	AN(tl->err);
+	VSB_cat(tl->sb, "(That was just a warning)\n");
+	tl->err = 0;
+}
+
 /*--------------------------------------------------------------------*/
 /* XXX: should take first+last token */
 
diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c
index c0e598532..3270e203a 100644
--- a/lib/libvcc/vcc_utils.c
+++ b/lib/libvcc/vcc_utils.c
@@ -281,10 +281,9 @@ Emit_UDS_Path(struct vcc *tl, const struct token *t_path, const char *errid)
 		VSB_printf(tl->sb, "%s: Cannot stat: %s\n", errid,
 			   strerror(errno));
 		vcc_ErrWhere(tl, t_path);
-		if (err == ENOENT || err == EACCES) {
-			VSB_cat(tl->sb, "(That was just a warning)\n");
-			tl->err = 0;
-		} else
+		if (err == ENOENT || err == EACCES)
+			vcc_Warn(tl);
+		else
 			return;
 	} else if (!S_ISSOCK(st.st_mode)) {
 		VSB_printf(tl->sb, "%s: Not a socket:\n", errid);
diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c
index e5f5f2858..fbabf77ce 100644
--- a/lib/libvcc/vcc_xref.c
+++ b/lib/libvcc/vcc_xref.c
@@ -83,10 +83,8 @@ vcc_checkref(struct vcc *tl, const struct symbol *sym)
 		VSB_printf(tl->sb, "Unused %s %.*s, defined:\n",
 		    sym->kind->name, PF(sym->def_b));
 		vcc_ErrWhere(tl, sym->def_b);
-		if (!tl->err_unref) {
-			VSB_cat(tl->sb, "(That was just a warning)\n");
-			tl->err = 0;
-		}
+		if (!tl->err_unref)
+			vcc_Warn(tl);
 	}
 }
 
@@ -233,10 +231,8 @@ vcc_checkaction2(struct vcc *tl, const struct symbol *sym)
 		return;
 	VSB_cat(tl->sb, "Function unused\n");
 	vcc_ErrWhere(tl, p->name);
-	if (!tl->err_unref) {
-		VSB_cat(tl->sb, "(That was just a warning)\n");
-		tl->err = 0;
-	}
+	if (!tl->err_unref)
+		vcc_Warn(tl);
 }
 
 int


More information about the varnish-commit mailing list