Merge lp:~stewart/percona-xtrabackup/1.6-cppcheck into lp:percona-xtrabackup/1.6

Proposed by Stewart Smith
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 272
Proposed branch: lp:~stewart/percona-xtrabackup/1.6-cppcheck
Merge into: lp:percona-xtrabackup/1.6
Diff against target: 184 lines (+60/-31)
1 file modified
xtrabackup.c (+60/-31)
To merge this branch: bzr merge lp:~stewart/percona-xtrabackup/1.6-cppcheck
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+66409@code.launchpad.net

Description of the change

fixes up fd leaks in a couple of places (reported by cppcheck)

http://jenkins.percona.com/view/Percona%20Xtrabackup/job/percona-xtrabackup-1.6-param/35/

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'xtrabackup.c'
2--- xtrabackup.c 2011-06-28 09:20:46 +0000
3+++ xtrabackup.c 2011-06-30 03:36:46 +0000
4@@ -2297,6 +2297,7 @@
5 xtrabackup_read_metadata(char *filename)
6 {
7 FILE *fp;
8+ my_bool r = FALSE;
9
10 fp = fopen(filename,"r");
11 if(!fp) {
12@@ -2305,41 +2306,53 @@
13 }
14
15 if (fscanf(fp, "backup_type = %29s\n", metadata_type)
16- != 1)
17- return(TRUE);
18+ != 1) {
19+ r = TRUE;
20+ goto end;
21+ }
22 #ifndef INNODB_VERSION_SHORT
23 if (fscanf(fp, "from_lsn = %lu:%lu\n", &metadata_from_lsn.high, &metadata_from_lsn.low)
24- != 2)
25- return(TRUE);
26+ != 2) {
27+ r = TRUE;
28+ goto end;
29+ }
30 if (fscanf(fp, "to_lsn = %lu:%lu\n", &metadata_to_lsn.high, &metadata_to_lsn.low)
31- != 2)
32- return(TRUE);
33+ != 2) {
34+ r = TRUE;
35+ goto end;
36+ }
37 if (fscanf(fp, "last_lsn = %lu:%lu\n", &metadata_last_lsn.high, &metadata_last_lsn.low)
38 != 2) {
39 metadata_last_lsn.high = metadata_last_lsn.low = 0;
40 }
41 #else
42 if (fscanf(fp, "from_lsn = %llu\n", &metadata_from_lsn)
43- != 1)
44- return(TRUE);
45+ != 1) {
46+ r = TRUE;
47+ goto end;
48+ }
49 if (fscanf(fp, "to_lsn = %llu\n", &metadata_to_lsn)
50- != 1)
51- return(TRUE);
52+ != 1) {
53+ r = TRUE;
54+ goto end;
55+ }
56 if (fscanf(fp, "last_lsn = %llu\n", &metadata_last_lsn)
57 != 1) {
58 metadata_last_lsn = 0;
59 }
60 #endif
61
62+end:
63 fclose(fp);
64
65- return(FALSE);
66+ return(r);
67 }
68
69 static my_bool
70 xtrabackup_write_metadata(char *filename)
71 {
72 FILE *fp;
73+ my_bool r = FALSE;
74
75 fp = fopen(filename,"w");
76 if(!fp) {
77@@ -2348,33 +2361,47 @@
78 }
79
80 if (fprintf(fp, "backup_type = %s\n", metadata_type)
81- < 0)
82- return(TRUE);
83+ < 0) {
84+ r = TRUE;
85+ goto end;
86+ }
87 #ifndef INNODB_VERSION_SHORT
88 if (fprintf(fp, "from_lsn = %lu:%lu\n", metadata_from_lsn.high, metadata_from_lsn.low)
89- < 0)
90- return(TRUE);
91+ < 0) {
92+ r = TRUE;
93+ goto end;
94+ }
95 if (fprintf(fp, "to_lsn = %lu:%lu\n", metadata_to_lsn.high, metadata_to_lsn.low)
96- < 0)
97- return(TRUE);
98+ < 0) {
99+ r = TRUE;
100+ goto end;
101+ }
102 if (fprintf(fp, "last_lsn = %lu:%lu\n", metadata_last_lsn.high, metadata_last_lsn.low)
103- < 0)
104- return(TRUE);
105+ < 0) {
106+ r = TRUE;
107+ goto end;
108+ }
109 #else
110 if (fprintf(fp, "from_lsn = %llu\n", metadata_from_lsn)
111- < 0)
112- return(TRUE);
113+ < 0) {
114+ r = TRUE;
115+ goto end;
116+ }
117 if (fprintf(fp, "to_lsn = %llu\n", metadata_to_lsn)
118- < 0)
119- return(TRUE);
120+ < 0) {
121+ r = TRUE;
122+ goto end;
123+ }
124 if (fprintf(fp, "last_lsn = %llu\n", metadata_last_lsn)
125- < 0)
126- return(TRUE);
127+ < 0) {
128+ r = TRUE;
129+ goto end;
130+ }
131 #endif
132-
133+ end:
134 fclose(fp);
135
136- return(FALSE);
137+ return(r);
138 }
139
140 /***********************************************************************
141@@ -2384,6 +2411,7 @@
142 xb_read_delta_metadata(const char *filepath, xb_delta_info_t *info)
143 {
144 FILE *fp;
145+ my_bool r= TRUE;
146
147 memset(info, 0, sizeof(xb_delta_info_t));
148
149@@ -2394,11 +2422,11 @@
150 }
151
152 if (fscanf(fp, "page_size = %lu\n", &info->page_size) != 1)
153- return(FALSE);
154+ r= FALSE;
155
156 fclose(fp);
157
158- return(TRUE);
159+ return(r);
160 }
161
162 /***********************************************************************
163@@ -2408,6 +2436,7 @@
164 xb_write_delta_metadata(const char *filepath, const xb_delta_info_t *info)
165 {
166 FILE *fp;
167+ my_bool r= TRUE;
168
169 fp = fopen(filepath, "w");
170 if (!fp) {
171@@ -2416,11 +2445,11 @@
172 }
173
174 if (fprintf(fp, "page_size = %lu\n", info->page_size) < 0)
175- return(FALSE);
176+ r= FALSE;
177
178 fclose(fp);
179
180- return(TRUE);
181+ return(r);
182 }
183
184 /* ================= backup ================= */

Subscribers

People subscribed via source and target branches