Skip to content

Commit 3c79e33

Browse files
h-eastchrisbra
authored andcommitted
patch 9.2.0298: Some internal variables are not modified
Problem: Some internal variables are not modified Solution: Add const qualifier to static table data (Hirohito Higashi). Several static arrays that are never modified at runtime were missing the const qualifier. Add const to move them from .data to .rodata section. closes: #19901 Signed-off-by: Hirohito Higashi <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 77e7a40 commit 3c79e33

10 files changed

Lines changed: 19 additions & 17 deletions

File tree

src/crypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ sodium_enabled(int verbose)
342342
#endif
343343

344344
#define CRYPT_MAGIC_LEN 12 // cannot change
345-
static char crypt_magic_head[] = "VimCrypt~";
345+
static const char crypt_magic_head[] = "VimCrypt~";
346346

347347
/*
348348
* Return int value for crypt method name.

src/ex_docmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2734,7 +2734,7 @@ ex_errmsg(char *msg, char_u *arg)
27342734
* The "+" string used in place of an empty command in Ex mode.
27352735
* This string is used in pointer comparison.
27362736
*/
2737-
static char exmode_plus[] = "+";
2737+
static const char exmode_plus[] = "+";
27382738

27392739
/*
27402740
* Handle a range without a command.

src/hardcopy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ static int prt_use_courier;
13941394
static int prt_in_ascii;
13951395
static int prt_half_width;
13961396
static char *prt_ascii_encoding;
1397-
static char_u prt_hexchar[] = "0123456789abcdef";
1397+
static const char_u prt_hexchar[] = "0123456789abcdef";
13981398

13991399
static void
14001400
prt_write_file_raw_len(char_u *buffer, int bytes)

src/memline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ typedef struct pointer_entry PTR_EN; // block/line-count pair
6969
#define BLOCK0_ID1_C4 's' // block 0 id 1 'cm' 4
7070

7171
#if defined(FEAT_CRYPT)
72-
static int id1_codes[] = {
72+
static const int id1_codes[] = {
7373
BLOCK0_ID1_C0, // CRYPT_M_ZIP
7474
BLOCK0_ID1_C1, // CRYPT_M_BF
7575
BLOCK0_ID1_C2, // CRYPT_M_BF2

src/pty.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ mch_openpty(char **ttyn)
354354
#ifndef PTY_DONE
355355

356356
# ifdef hpux
357-
static char PtyProto[] = "/dev/ptym/ptyXY";
358-
static char TtyProto[] = "/dev/pty/ttyXY";
357+
static const char PtyProto[] = "/dev/ptym/ptyXY";
358+
static const char TtyProto[] = "/dev/pty/ttyXY";
359359
# else
360360
# ifdef __HAIKU__
361-
static char PtyProto[] = "/dev/pt/XY";
362-
static char TtyProto[] = "/dev/tt/XY";
361+
static const char PtyProto[] = "/dev/pt/XY";
362+
static const char TtyProto[] = "/dev/tt/XY";
363363
# else
364-
static char PtyProto[] = "/dev/ptyXY";
365-
static char TtyProto[] = "/dev/ttyXY";
364+
static const char PtyProto[] = "/dev/ptyXY";
365+
static const char TtyProto[] = "/dev/ttyXY";
366366
# endif
367367
# endif
368368

src/regexp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static int reg_strict; // "[abc" is illegal
377377
*/
378378

379379
// META[] is used often enough to justify turning it into a table.
380-
static char_u META_flags[] = {
380+
static const char_u META_flags[] = {
381381
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
382382
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
383383
// % & ( ) * + .
@@ -2908,7 +2908,7 @@ static regengine_T nfa_regengine =
29082908
static int regexp_engine = 0;
29092909

29102910
#ifdef DEBUG
2911-
static char_u regname[][30] = {
2911+
static const char_u regname[][30] = {
29122912
"AUTOMATIC Regexp Engine",
29132913
"BACKTRACKING Regexp Engine",
29142914
"NFA Regexp Engine"

src/regexp_bt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static int one_exactly = FALSE; // only do one char for EXACTLY
253253

254254
// When making changes to classchars also change nfa_classcodes.
255255
static char_u *classchars = (char_u *)".iIkKfFpPsSdDxXoOwWhHaAlLuU";
256-
static int classcodes[] = {
256+
static const int classcodes[] = {
257257
ANY, IDENT, SIDENT, KWORD, SKWORD,
258258
FNAME, SFNAME, PRINT, SPRINT,
259259
WHITE, NWHITE, DIGIT, NDIGIT,

src/regexp_nfa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ enum
233233
};
234234

235235
// Keep in sync with classchars.
236-
static int nfa_classcodes[] = {
236+
static const int nfa_classcodes[] = {
237237
NFA_ANY, NFA_IDENT, NFA_SIDENT, NFA_KWORD,NFA_SKWORD,
238238
NFA_FNAME, NFA_SFNAME, NFA_PRINT, NFA_SPRINT,
239239
NFA_WHITE, NFA_NWHITE, NFA_DIGIT, NFA_NDIGIT,

src/term.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ static tcap_entry_T builtin_sync_output[] = {
689689
/*
690690
* List of DECRQM modes that Vim supports
691691
*/
692-
static int dec_modes[] = {
692+
static const int dec_modes[] = {
693693
2026, // Synchronized output
694694
#ifdef UNIX
695695
2048 // In-band terminal resize events
@@ -7827,11 +7827,11 @@ swap_tcap(void)
78277827

78287828

78297829
#if (defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))) || defined(FEAT_TERMINAL)
7830-
static int cube_value[] = {
7830+
static const int cube_value[] = {
78317831
0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF
78327832
};
78337833

7834-
static int grey_ramp[] = {
7834+
static const int grey_ramp[] = {
78357835
0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76,
78367836
0x80, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE
78377837
};

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
298,
737739
/**/
738740
297,
739741
/**/

0 commit comments

Comments
 (0)