From: Michihiro NAKAJIMA Date: Thu, 1 Sep 2011 08:25:09 +0000 (-0400) Subject: Issue 176: Const-ify several static arrays. X-Git-Tag: v3.0.0a~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3caa7d2f3d95edba576892770a650d433d6d1ad2;p=thirdparty%2Flibarchive.git Issue 176: Const-ify several static arrays. SVN-Revision: 3666 --- diff --git a/cpio/test/test_owner_parse.c b/cpio/test/test_owner_parse.c index 8f9343ab9..a9f605398 100644 --- a/cpio/test/test_owner_parse.c +++ b/cpio/test/test_owner_parse.c @@ -30,8 +30,8 @@ __FBSDID("$FreeBSD$"); #if !defined(_WIN32) #define ROOT "root" -static int root_uids[] = { 0 }; -static int root_gids[] = { 0, 1 }; +static const int root_uids[] = { 0 }; +static const int root_gids[] = { 0, 1 }; #elif defined(__CYGWIN__) /* On cygwin, the Administrator user most likely exists (unless * it has been renamed or is in a non-English localization), but @@ -42,13 +42,13 @@ static int root_gids[] = { 0, 1 }; * Use CreateWellKnownSID() and LookupAccountName()? */ #define ROOT "Administrator" -static int root_uids[] = { 500 }; -static int root_gids[] = { 513, 545, 544 }; +static const int root_uids[] = { 500 }; +static const int root_gids[] = { 513, 545, 544 }; #endif #if defined(ROOT) static int -int_in_list(int i, int *l, size_t n) +int_in_list(int i, const int *l, size_t n) { while (n-- > 0) if (*l++ == i) diff --git a/libarchive/archive_read_support_format_cab.c b/libarchive/archive_read_support_format_cab.c index 67bc71275..715dd0477 100644 --- a/libarchive/archive_read_support_format_cab.c +++ b/libarchive/archive_read_support_format_cab.c @@ -138,7 +138,7 @@ struct lzx_dec { int error; }; -static int slots[] = { +static const int slots[] = { 30, 32, 34, 36, 38, 42, 50, 66, 98, 162, 290 }; #define SLOT_BASE 15 @@ -190,7 +190,7 @@ struct lzx_stream { #define CFDATA_cbData 4 #define CFDATA_cbUncomp 6 -static char *compression_name[] = { +static const char *compression_name[] = { "NONE", "MSZIP", "Quantum", diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c index 400b8e22f..3dc87c585 100644 --- a/libarchive/archive_read_support_format_lha.c +++ b/libarchive/archive_read_support_format_lha.c @@ -1209,7 +1209,7 @@ lha_read_file_extended_header(struct archive_read *a, struct lha *lha, if (datasize >= 2) { lha->header_crc = archive_le16dec(extdheader); if (crc != NULL) { - static char zeros[2] = {0, 0}; + static const char zeros[2] = {0, 0}; *crc = lha_crc16(*crc, h, extdsize - datasize); /* CRC value itself as zero */ diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c index 44196f4c2..4c1828c11 100644 --- a/libarchive/archive_string.c +++ b/libarchive/archive_string.c @@ -2326,7 +2326,7 @@ best_effort_strncat_in_locale(struct archive_string *as, const void *_p, static int _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) { - static char utf8_count[256] = { + static const char utf8_count[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 00 - 0F */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 10 - 1F */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 20 - 2F */ diff --git a/libarchive/archive_write_add_filter_compress.c b/libarchive/archive_write_add_filter_compress.c index 32b065828..465ff0e77 100644 --- a/libarchive/archive_write_add_filter_compress.c +++ b/libarchive/archive_write_add_filter_compress.c @@ -215,7 +215,7 @@ archive_compressor_compress_open(struct archive_write_filter *f) * code in turn. When the buffer fills up empty it and start over. */ -static unsigned char rmask[9] = +static const unsigned char rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; static int diff --git a/libarchive/test/main.c b/libarchive/test/main.c index 6fa54ded7..81abe3e5f 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -441,7 +441,7 @@ assertion_equal_int(const char *file, int line, static int _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) { - static char utf8_count[256] = { + static const char utf8_count[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 00 - 0F */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 10 - 1F */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 20 - 2F */