[master] 69693970c vsl: Don't make copies of VSL_FILE_ID

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Mar 6 14:27:06 UTC 2023


commit 69693970cef5e19e60e0220fc4e8fb35a7a0297e
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Mar 6 10:14:41 2023 +0100

    vsl: Don't make copies of VSL_FILE_ID
    
    It will no longer be valid for assignments, and in one case the
    assignment was superfluous.

diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c
index 8b0f095fa..5179d4fdf 100644
--- a/lib/libvarnishapi/vsl.c
+++ b/lib/libvarnishapi/vsl.c
@@ -413,8 +413,8 @@ VSL_PrintTransactions(struct VSL_data *vsl, struct VSL_transaction * const pt[],
 FILE*
 VSL_WriteOpen(struct VSL_data *vsl, const char *name, int append, int unbuf)
 {
-	const char head[] = VSL_FILE_ID;
 	FILE* f;
+
 	if (!strcmp(name, "-"))
 		f = stdout;
 	else
@@ -426,7 +426,8 @@ VSL_WriteOpen(struct VSL_data *vsl, const char *name, int append, int unbuf)
 	if (unbuf)
 		setbuf(f, NULL);
 	if (ftell(f) == 0 || f == stdout) {
-		if (fwrite(head, 1, sizeof head, f) != sizeof head) {
+		if (fwrite(VSL_FILE_ID, 1, sizeof VSL_FILE_ID, f) !=
+		    sizeof VSL_FILE_ID) {
 			vsl_diag(vsl, "%s", strerror(errno));
 			(void)fclose(f);
 			return (NULL);
diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c
index 8cf259394..1dedb3cc9 100644
--- a/lib/libvarnishapi/vsl_cursor.c
+++ b/lib/libvarnishapi/vsl_cursor.c
@@ -527,7 +527,7 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name, unsigned options)
 	struct vslc_file *c;
 	int fd;
 	int close_fd = 0;
-	char buf[] = VSL_FILE_ID;
+	char buf[sizeof VSL_FILE_ID];
 	ssize_t i;
 
 	CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);


More information about the varnish-commit mailing list