Package: partclone / 0.3.13+dfsg-5

fix-external-variables.patch Patch series | 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
Those changes are fixing bugs which are currently detected by gcc-10.

However the fixes should be made upstream by rethinking the status
of the touched variables. Do they need to be *that* external?

--- partclone-0.3.13+dfsg.orig/src/partclone.c
+++ partclone-0.3.13+dfsg/src/partclone.c
@@ -1662,11 +1662,22 @@ int close_target(int dfw) {
 	return ret;
 }
 
+/**
+ * must this variable really need to be so global?
+ * GK, 2020-04-17 : removed the "extern unsigned long long rescue_write_size"
+ * statements from the following function bodies, and declared this variable
+ * as external in the header file partclone.h
+ **/
+unsigned long long rescue_write_size;
+
 int write_block_file(char* target, char *buf, unsigned long long count, unsigned long long offset, cmd_opt* opt){
 	long long int i;
 	int debug = opt->debug;
 	unsigned long long size = count;
+	/**
+	 * wrong statement here; see GK's comment above
 	extern unsigned long long rescue_write_size;
+	**/
 	int flags = O_WRONLY | O_LARGEFILE | O_CREAT ;
         int torrent_fd = 0;
 	char *block_filename = malloc(PATH_MAX + 1);
@@ -1706,7 +1717,10 @@ int io_all(int *fd, char *buf, unsigned
 	long long int i;
 	int debug = opt->debug;
 	unsigned long long size = count;
+	/**
+	 * wrong statement here; see GK's comment above
 	extern unsigned long long rescue_write_size;
+	**/
 
 	// for sync I/O buffer, when use stdin or pipe.
 	while (count > 0) {
--- partclone-0.3.13+dfsg.orig/src/partclone.h
+++ partclone-0.3.13+dfsg/src/partclone.h
@@ -80,8 +80,18 @@ const char* get_exec_name();
 #undef crc32
 #endif
 
+/**
+ * GK, 2020-04-17 : wrong declaration : no source file is using the
+ * variable EXECNAME, but GCC will define this variable automatically
+ * so this must be commented out:
 char *EXECNAME;
-unsigned long long rescue_write_size;
+**/
+
+/**
+ * GK, 2020-04-17 : here is the declaration of the variable 
+ * rescue_write_size as something external.
+ **/
+extern unsigned long long rescue_write_size;
 
 /**
  * option
--- partclone-0.3.13+dfsg.orig/src/progress.h
+++ partclone-0.3.13+dfsg/src/progress.h
@@ -37,6 +37,13 @@ struct progress_bar {
 };
 typedef struct progress_bar progress_bar;
 
+/**
+ * GK 2020-04-17 : this variable is used in global space in C source files
+ * main.c and xfsclone.c; so it must be declared as extern.
+ * the global variable is actually defined in main.c, line 45.
+ **/
+extern progress_bar prog;
+
 struct prog_stat_t{
     char Eformated[12];
     char Rformated[12];
--- partclone-0.3.13+dfsg.orig/src/xfsclone.c
+++ partclone-0.3.13+dfsg/src/xfsclone.c
@@ -24,7 +24,11 @@
 #undef crc32
 int	source_fd = -1;
 int     first_residue;
+/**
+ * GK, 2020-04-17 : wrong statement, the same global varaible is defined
+ * in main.c, line 45, so it is commented out here :
 progress_bar        prog;
+**/
 unsigned long long checked;
 unsigned long long total_block;
 int bitmap_done = 0;