[PATCH 1 of 2] revlog: explicitly initialize static variables

Yuya Nishihara yuya at tcha.org
Tue Oct 9 12:58:51 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1539038525 -32400
#      Tue Oct 09 07:42:05 2018 +0900
# Node ID fec6a0498695298ec0507a76cd26334794da93be
# Parent  8a08aefa9273e6f328f238e4793f9a43f314e471
revlog: explicitly initialize static variables

I know .bss section is zero-filled, but explicit initialization should be
better as we rely on that.

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -94,8 +94,8 @@ static Py_ssize_t index_length(const ind
 	return self->length + PyList_GET_SIZE(self->added);
 }
 
-static PyObject *nullentry;
-static const char nullid[20];
+static PyObject *nullentry = NULL;
+static const char nullid[20] = {0};
 
 static Py_ssize_t inline_scan(indexObject *self, const char **offsets);
 


More information about the Mercurial-devel mailing list