File: fix-miscellaneous-warnings.patch

package info (click to toggle)
a56 1.3%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 664 kB
  • sloc: yacc: 7,550; ansic: 5,851; makefile: 231; awk: 4; sh: 1
file content (107 lines) | stat: -rw-r--r-- 3,036 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
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
From: Ben Hutchings <benh@debian.org>
Date: Fri, 26 Jul 2024 23:54:35 +0200
Subject: Fix miscellaneous warnings
Forwarded: not-needed as there is no upstream anymore

gcc warns:

a56.y: In function ‘unary_name’:
a56.y:1922:1: warning: control reaches end of non-void function [-Wreturn-type]
 1922 | }
      | ^

It's not clear to me whether this function can be called with a value
that's not handled in the switch(), so add a default case to fix this.

a56.y: In function ‘unary_op’:
a56.y:1927:18: warning: variable ‘result’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]
 1927 |         struct n result;
      |                  ^~~~~~

Fix this by declaring it volatile.

a56.y: In function ‘unary_op’:
a56.y:1959:43: warning: operation on ‘result.val.f’ may be undefined [-Wsequence-point]
 1959 |                         else result.val.f = result.val.f = a1.val.f < 0 ? -a1.val.f : a1.val.f;
      |                              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There's clearly no need to assign to result.val.f twice here.
Delete the duplicate assignment.

lex.c: In function ‘lgetc’:
lex.c:465:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
  465 |                 c = '\n';
      |                 ~~^~~~~~
lex.c:466:9: note: here
  466 |         case '\n':
      |         ^~~~

This fallthrough looks intentional, so declare that.

toomf.c: In function ‘main’:
toomf.c:36:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
   36 | int main(int argc, char **argv)
      |          ~~~~^~~~
toomf.c:36:27: warning: unused parameter ‘argv’ [-Wunused-parameter]
   36 | int main(int argc, char **argv)
      |                    ~~~~~~~^~~~

Change the parameter list to void.

---
--- a/a56.y
+++ b/a56.y
@@ -1900,7 +1900,7 @@ struct n binary_op(struct n a1, int op,
 jmp_buf unary_env;
 
 void
-sigfpu(int signum)
+sigfpu(int signum __attribute__((unused)))
 {
 	longjmp(unary_env, 1);
 }
@@ -1918,12 +1918,13 @@ char *unary_name(int op)
    	case 'l':	return "ln";
 	case 'L':	return "log";
 	case 'a':	return "abs";
+	default:	return "???";
 	}
 }
 
 struct n unary_op(int op, struct n a1)
 {
-	struct n result;
+	volatile struct n result;
 	void (*orig)(int);
 	double farg;
 
@@ -1956,7 +1957,7 @@ struct n unary_op(int op, struct n a1)
 		case 'a':
 			result.type = a1.type;
 			if(a1.type == INT) result.val.i = a1.val.i < 0 ? -a1.val.i : a1.val.i;
-			else result.val.f = result.val.f = a1.val.f < 0 ? -a1.val.f : a1.val.f;
+			else result.val.f = a1.val.f < 0 ? -a1.val.f : a1.val.f;
 			break;
 		case 's':
 			result.type = FLT;
--- a/lex.c
+++ b/lex.c
@@ -463,6 +463,7 @@ int lgetc(FILE *fp)
 		break;
 	case '\0':
 		c = '\n';
+		__attribute__((fallthrough));
 	case '\n':
 		clp = NULL;
 		break;
--- a/toomf.c
+++ b/toomf.c
@@ -37,7 +37,7 @@ static char *Copyright = "Copyright (C)
 
 #define MAX 256
 
-int main(int argc, char **argv)
+int main(void)
 {
 	char buf[MAX];
 	int curaddr = 0;