[PATCH 03/11] Marked a couple of variables 'const'.

Alejandro Colomar alx.manpages at gmail.com
Thu Jun 16 15:46:03 UTC 2022



On 6/16/22 03:00, Andrew Clayton wrote:
> As was pointed out by the cppcheck[0] static code analysis utility we
> can mark a couple of variables as 'const'. This acts as a hint to the
> compiler about our intentions and the compiler will tell us when we
> deviate from them.
> 
> [0]: https://cppcheck.sourceforge.io/

Reviewed-by: Alejandro Colomar <alx.manpages at gmail.com>

> ---
>   src/nxt_time_parse.c       | 2 +-
>   src/nxt_websocket_accept.c | 4 ++--
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/nxt_time_parse.c b/src/nxt_time_parse.c
> index 94c4328..63620b0 100644
> --- a/src/nxt_time_parse.c
> +++ b/src/nxt_time_parse.c
> @@ -22,7 +22,7 @@ nxt_time_parse(const u_char *p, size_t len)
>       nxt_uint_t        year, days;
>       const u_char      *end;
>   
> -    static nxt_int_t  mday[12] = {
> +    static const nxt_int_t  mday[12] = {
>           31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
>       };
>   
> diff --git a/src/nxt_websocket_accept.c b/src/nxt_websocket_accept.c
> index 05cbcb5..0e2cef5 100644
> --- a/src/nxt_websocket_accept.c
> +++ b/src/nxt_websocket_accept.c
> @@ -11,8 +11,8 @@
>   static void
>   nxt_websocket_base64_encode(u_char *d, const uint8_t *s, size_t len)
>   {
> -    u_char         c0, c1, c2;
> -    static u_char  basis[] =
> +    u_char               c0, c1, c2;
> +    static const u_char  basis[] =
>           "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
>   
>       while (len > 2) {

-- 
Alejandro Colomar
<http://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.nginx.org/pipermail/unit/attachments/20220616/6dd287aa/attachment.bin>


More information about the unit mailing list