[PATCH 17/18] Added const to a constant variable.

Alejandro Colomar alx.manpages at gmail.com
Thu Jun 2 18:05:11 UTC 2022


This fixes an error triggered by making these functions C99 inline
(instead of nxt_always_inline), and improves const correctness
(and probably it also helps optimize a little bit, by moving the
code to a read-only section).
---
 src/nxt_http.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/nxt_http.h b/src/nxt_http.h
index c916ae5..1756c8a 100644
--- a/src/nxt_http.h
+++ b/src/nxt_http.h
@@ -280,11 +280,12 @@ nxt_always_inline
 inline u_char *
 nxt_http_date(u_char *buf, struct tm *tm)
 {
-    static const char  *week[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
-                                   "Sat" };
+    static const char *const  week[] = { "Sun", "Mon", "Tue", "Wed", "Thu",
+                                         "Fri", "Sat" };
 
-    static const char  *month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
-                                    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+    static const char *const  month[] = { "Jan", "Feb", "Mar", "Apr", "May",
+                                          "Jun", "Jul", "Aug", "Sep", "Oct",
+                                          "Nov", "Dec" };
 
     return nxt_sprintf(buf, buf + NXT_HTTP_DATE_LEN,
                        "%s, %02d %s %4d %02d:%02d:%02d GMT",
-- 
2.36.1



More information about the unit mailing list