File: 0013-asn1_test-enable-the-testcase-only-when-GRUB_LONG_MA.patch

package info (click to toggle)
grub2 2.14~git20250718.0e36779-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 60,688 kB
  • sloc: ansic: 541,811; asm: 68,074; sh: 9,803; cpp: 2,095; makefile: 1,895; python: 1,518; sed: 446; lex: 393; yacc: 268; awk: 85; lisp: 54; perl: 31
file content (48 lines) | stat: -rw-r--r-- 1,809 bytes parent folder | download
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
From 6d308d9053447dcc003a9ca740c47c00932d3569 Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Mon, 7 Oct 2024 11:33:19 +0800
Subject: [PATCH 13/13] asn1_test: enable the testcase only when GRUB_LONG_MAX
 is larger than GRUB_INT_MAX

There is a testcase to test the values larger than 'int' but smaller
than 'long'. However, for some architectures, 'long' and 'int' are the
same, and the compiler may issue a warning like this:

grub-core/tests/asn1/tests/Test_overflow.c:48:50: error: left shift of negative value [-Werror=shift-negative-value]
       unsigned long num = ((long) GRUB_UINT_MAX) << 2;
                                                  ^~

To avoid unnecessary error the testcase is enabled only when
GRUB_LONG_MAX is larger than GRUB_INT_MAX.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/tests/asn1/tests/Test_overflow.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/grub-core/tests/asn1/tests/Test_overflow.c b/grub-core/tests/asn1/tests/Test_overflow.c
index 65843abf6..fdeff5634 100644
--- a/grub-core/tests/asn1/tests/Test_overflow.c
+++ b/grub-core/tests/asn1/tests/Test_overflow.c
@@ -43,7 +43,7 @@ test_overflow (void)
 
   /* Test that values larger than int but smaller than long are
      rejected.  This limitation was introduced with libtasn1 2.12. */
-  if (GRUB_LONG_MAX > GRUB_INT_MAX)
+#if (GRUB_LONG_MAX > GRUB_INT_MAX)
     {
       unsigned long num = ((long) GRUB_UINT_MAX) << 2;
       unsigned char der[20];
@@ -61,6 +61,7 @@ test_overflow (void)
 	  return 1;
 	}
     }
+#endif
 
   /* Test that values larger than would fit in the input string are
      rejected.  This problem was fixed in libtasn1 2.12. */
-- 
2.43.0