aboutsummaryrefslogtreecommitdiff
path: root/meta/recipes-bsp/grub/files/0002-i386-x86_64-ppc-fix-switch-fallthrough-cases-with-GC.patch
blob: 94f048c28b026c665745850946b789fcce25b2e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
From 4bd4a88725604471fdbd86316c91967a7f4dba5a Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <arvidjaar@gmail.com>
Date: Tue, 4 Apr 2017 19:23:55 +0300
Subject: [PATCH 2/4] i386, x86_64, ppc: fix switch fallthrough cases with GCC7

In util/getroot and efidisk slightly modify exitsing comment to mostly
retain it but still make GCC7 compliant with respect to fall through
annotation.

In grub-core/lib/xzembed/xz_dec_lzma2.c it adds same comments as
upstream.

In grub-core/tests/setjmp_tets.c declare functions as "noreturn" to
suppress GCC7 warning.

In grub-core/gnulib/regexec.c use new __attribute__, because existing
annotation is not recognized by GCC7 parser (which requires that comment
immediately precedes case statement).

Otherwise add FALLTHROUGH comment.

Closes: 50598
---
Upstream-Status: Backport
Signed-off-by: Khem Raj <raj.khem@gmail.com>

 grub-core/commands/hdparm.c           | 1 +
 grub-core/commands/nativedisk.c       | 1 +
 grub-core/disk/cryptodisk.c           | 1 +
 grub-core/disk/efi/efidisk.c          | 2 +-
 grub-core/efiemu/mm.c                 | 1 +
 grub-core/gdb/cstub.c                 | 1 +
 grub-core/gnulib/regexec.c            | 3 +++
 grub-core/lib/xzembed/xz_dec_lzma2.c  | 4 ++++
 grub-core/lib/xzembed/xz_dec_stream.c | 6 ++++++
 grub-core/loader/i386/linux.c         | 3 +++
 grub-core/tests/setjmp_test.c         | 5 ++++-
 grub-core/video/ieee1275.c            | 1 +
 grub-core/video/readers/jpeg.c        | 1 +
 util/getroot.c                        | 2 +-
 util/grub-install.c                   | 1 +
 util/grub-mkimagexx.c                 | 1 +
 util/grub-mount.c                     | 1 +
 17 files changed, 32 insertions(+), 3 deletions(-)

Index: grub-2.00/grub-core/commands/hdparm.c
===================================================================
--- grub-2.00.orig/grub-core/commands/hdparm.c
+++ grub-2.00/grub-core/commands/hdparm.c
@@ -328,6 +328,7 @@ grub_cmd_hdparm (grub_extcmd_context_t c
 	  ata = ((struct grub_scsi *) disk->data)->data;
 	  break;
 	}
+      /* FALLTHROUGH */
     default:
       return grub_error (GRUB_ERR_IO, "not an ATA device");
     }
Index: grub-2.00/grub-core/disk/cryptodisk.c
===================================================================
--- grub-2.00.orig/grub-core/disk/cryptodisk.c
+++ grub-2.00/grub-core/disk/cryptodisk.c
@@ -268,6 +268,7 @@ grub_cryptodisk_endecrypt (struct grub_c
 	  break;
 	case GRUB_CRYPTODISK_MODE_IV_PLAIN64:
 	  iv[1] = grub_cpu_to_le32 (sector >> 32);
+	  /* FALLTHROUGH */
 	case GRUB_CRYPTODISK_MODE_IV_PLAIN:
 	  iv[0] = grub_cpu_to_le32 (sector & 0xFFFFFFFF);
 	  break;
Index: grub-2.00/grub-core/disk/efi/efidisk.c
===================================================================
--- grub-2.00.orig/grub-core/disk/efi/efidisk.c
+++ grub-2.00/grub-core/disk/efi/efidisk.c
@@ -262,7 +262,7 @@ name_devices (struct grub_efidisk_data *
 	    {
 	    case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
 	      is_hard_drive = 1;
-	      /* Fall through by intention.  */
+	      /* Intentionally fall through.  */
 	    case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
 	      {
 		struct grub_efidisk_data *parent, *parent2;
Index: grub-2.00/grub-core/efiemu/mm.c
===================================================================
--- grub-2.00.orig/grub-core/efiemu/mm.c
+++ grub-2.00/grub-core/efiemu/mm.c
@@ -410,6 +410,7 @@ grub_efiemu_mmap_fill (void)
 	default:
 	  grub_dprintf ("efiemu",
 			"Unknown memory type %d. Assuming unusable\n", type);
+	/* FALLTHROUGH */
 	case GRUB_MEMORY_RESERVED:
 	  return grub_efiemu_add_to_mmap (addr, size,
 					  GRUB_EFI_UNUSABLE_MEMORY);
Index: grub-2.00/grub-core/gdb/cstub.c
===================================================================
--- grub-2.00.orig/grub-core/gdb/cstub.c
+++ grub-2.00/grub-core/gdb/cstub.c
@@ -336,6 +336,7 @@ grub_gdb_trap (int trap_no)
 	/* sAA..AA: Step one instruction from AA..AA(optional).  */
 	case 's':
 	  stepping = 1;
+	  /* FALLTHROUGH */
 
 	/* cAA..AA: Continue at address AA..AA(optional).  */
 	case 'c':
Index: grub-2.00/grub-core/gnulib/regexec.c
===================================================================
--- grub-2.00.orig/grub-core/gnulib/regexec.c
+++ grub-2.00/grub-core/gnulib/regexec.c
@@ -4104,6 +4104,9 @@ check_node_accept (const re_match_contex
     case OP_UTF8_PERIOD:
       if (ch >= ASCII_CHARS)
         return false;
+#if defined __GNUC__ && __GNUC__ >= 7
+      __attribute__ ((fallthrough));
+#endif
       /* FALLTHROUGH */
 #endif
     case OP_PERIOD:
Index: grub-2.00/grub-core/lib/xzembed/xz_dec_lzma2.c
===================================================================
--- grub-2.00.orig/grub-core/lib/xzembed/xz_dec_lzma2.c
+++ grub-2.00/grub-core/lib/xzembed/xz_dec_lzma2.c
@@ -1042,6 +1042,8 @@ enum xz_ret xz_dec_lzma2_run(
 
 			s->lzma2.sequence = SEQ_LZMA_PREPARE;
 
+		/* Fall through */
+
 		case SEQ_LZMA_PREPARE:
 			if (s->lzma2.compressed < RC_INIT_BYTES)
 				return XZ_DATA_ERROR;
@@ -1052,6 +1054,8 @@ enum xz_ret xz_dec_lzma2_run(
 			s->lzma2.compressed -= RC_INIT_BYTES;
 			s->lzma2.sequence = SEQ_LZMA_RUN;
 
+		/* Fall through */
+
 		case SEQ_LZMA_RUN:
 			/*
 			 * Set dictionary limit to indicate how much we want
Index: grub-2.00/grub-core/lib/xzembed/xz_dec_stream.c
===================================================================
--- grub-2.00.orig/grub-core/lib/xzembed/xz_dec_stream.c
+++ grub-2.00/grub-core/lib/xzembed/xz_dec_stream.c
@@ -749,6 +749,7 @@ static enum xz_ret dec_main(struct xz_de
 
 			s->sequence = SEQ_BLOCK_START;
 
+			/* FALLTHROUGH */
 		case SEQ_BLOCK_START:
 			/* We need one byte of input to continue. */
 			if (b->in_pos == b->in_size)
@@ -772,6 +773,7 @@ static enum xz_ret dec_main(struct xz_de
 			s->temp.pos = 0;
 			s->sequence = SEQ_BLOCK_HEADER;
 
+			/* FALLTHROUGH */
 		case SEQ_BLOCK_HEADER:
 			if (!fill_temp(s, b))
 				return XZ_OK;
@@ -782,6 +784,7 @@ static enum xz_ret dec_main(struct xz_de
 
 			s->sequence = SEQ_BLOCK_UNCOMPRESS;
 
+			/* FALLTHROUGH */
 		case SEQ_BLOCK_UNCOMPRESS:
 			ret = dec_block(s, b);
 			if (ret != XZ_STREAM_END)
@@ -809,6 +812,7 @@ static enum xz_ret dec_main(struct xz_de
 
 			s->sequence = SEQ_BLOCK_CHECK;
 
+			/* FALLTHROUGH */
 		case SEQ_BLOCK_CHECK:
 			ret = hash_validate(s, b, 0);
 			if (ret != XZ_STREAM_END)
@@ -863,6 +867,7 @@ static enum xz_ret dec_main(struct xz_de
 
 			s->sequence = SEQ_INDEX_CRC32;
 
+			/* FALLTHROUGH */
 		case SEQ_INDEX_CRC32:
 			ret = hash_validate(s, b, 1);
 			if (ret != XZ_STREAM_END)
@@ -871,6 +876,7 @@ static enum xz_ret dec_main(struct xz_de
 			s->temp.size = STREAM_HEADER_SIZE;
 			s->sequence = SEQ_STREAM_FOOTER;
 
+			/* FALLTHROUGH */
 		case SEQ_STREAM_FOOTER:
 			if (!fill_temp(s, b))
 				return XZ_OK;
Index: grub-2.00/grub-core/loader/i386/linux.c
===================================================================
--- grub-2.00.orig/grub-core/loader/i386/linux.c
+++ grub-2.00/grub-core/loader/i386/linux.c
@@ -977,10 +977,13 @@ grub_cmd_linux (grub_command_t cmd __att
 	      {
 	      case 'g':
 		shift += 10;
+		/* FALLTHROUGH */
 	      case 'm':
 		shift += 10;
+		/* FALLTHROUGH */
 	      case 'k':
 		shift += 10;
+		/* FALLTHROUGH */
 	      default:
 		break;
 	      }
Index: grub-2.00/grub-core/video/readers/jpeg.c
===================================================================
--- grub-2.00.orig/grub-core/video/readers/jpeg.c
+++ grub-2.00/grub-core/video/readers/jpeg.c
@@ -701,6 +701,7 @@ grub_jpeg_decode_jpeg (struct grub_jpeg_
 	case JPEG_MARKER_SOS:	/* Start Of Scan.  */
 	  if (grub_jpeg_decode_sos (data))
 	    break;
+	  /* FALLTHROUGH */
 	case JPEG_MARKER_RST0:	/* Restart.  */
 	case JPEG_MARKER_RST1:
 	case JPEG_MARKER_RST2:
Index: grub-2.00/util/grub-mkimagexx.c
===================================================================
--- grub-2.00.orig/util/grub-mkimagexx.c
+++ grub-2.00/util/grub-mkimagexx.c
@@ -485,6 +485,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e
 									    + sym->st_value
 									    - image_target->vaddr_offset));
 		  }
+		/* FALLTHROUGH */
 		case R_IA64_LTOFF_FPTR22:
 		  *gpptr = grub_host_to_target64 (addend + sym_addr);
 		  add_value_to_slot_21 ((grub_addr_t) target,
Index: grub-2.00/util/grub-mount.c
===================================================================
--- grub-2.00.orig/util/grub-mount.c
+++ grub-2.00/util/grub-mount.c
@@ -487,6 +487,7 @@ argp_parser (int key, char *arg, struct
       if (arg[0] != '-')
 	break;
 
+    /* FALLTHROUGH */
     default:
       if (!arg)
 	return 0;