summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org>2018-05-24 05:28:51 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-05-24 05:29:47 (GMT)
commitf82d0b213fd2cdce80dc891906fba8d589115664 (patch) (unidiff)
tree9aa091d9fbe7fea183391fc9e22fc0f2f54ae28f /src
parent0665bcf0c9cdf756f9d5edc6a638c56602c42065 (diff)
downloadgdbm-f82d0b213fd2cdce80dc891906fba8d589115664.tar.gz
gdbm-f82d0b213fd2cdce80dc891906fba8d589115664.tar.bz2
Fix the use of return code from _gdbm_full_(read|write) functions
Diffstat (limited to 'src') (more/less context) (show whitespace changes)
-rw-r--r--src/falloc.c4
-rw-r--r--src/findkey.c2
-rw-r--r--src/gdbmstore.c4
-rw-r--r--src/gdbmtool.c17
-rw-r--r--src/update.c2
5 files changed, 10 insertions, 19 deletions
diff --git a/src/falloc.c b/src/falloc.c
index 33a238a..e87a5b7 100644
--- a/src/falloc.c
+++ b/src/falloc.c
@@ -199,13 +199,13 @@ pop_avail_block (GDBM_FILE dbf)
199 } 199 }
200 200
201 rc = GDBM_DEBUG_OVERRIDE ("pop_avail_block:read-failure", 201 rc = GDBM_DEBUG_OVERRIDE ("pop_avail_block:read-failure",
202 _gdbm_full_read (dbf, new_blk, new_el.av_size)); 202 _gdbm_full_read (dbf, new_blk, new_el.av_size));
203 if (rc) 203 if (rc)
204 { 204 {
205 _gdbm_fatal (dbf, gdbm_strerror (rc)); 205 _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
206 return -1; 206 return -1;
207 } 207 }
208 208
209 if (!gdbm_avail_block_valid_p (new_blk)) 209 if (!gdbm_avail_block_valid_p (new_blk))
210 { 210 {
211 gdbm_set_errno (dbf, GDBM_BAD_AVAIL, TRUE); 211 gdbm_set_errno (dbf, GDBM_BAD_AVAIL, TRUE);
@@ -327,13 +327,13 @@ push_avail_block (GDBM_FILE dbf)
327 _gdbm_full_write (dbf, temp, av_size)); 327 _gdbm_full_write (dbf, temp, av_size));
328 if (rc) 328 if (rc)
329 { 329 {
330 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR, 330 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
331 "%s: error writing avail data: %s", 331 "%s: error writing avail data: %s",
332 dbf->name, gdbm_db_strerror (dbf)); 332 dbf->name, gdbm_db_strerror (dbf));
333 _gdbm_fatal (dbf, gdbm_strerror (rc)); 333 _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
334 return -1; 334 return -1;
335 } 335 }
336 336
337 free (temp); 337 free (temp);
338 338
339 return 0; 339 return 0;
diff --git a/src/findkey.c b/src/findkey.c
index 211d9a9..7638b04 100644
--- a/src/findkey.c
+++ b/src/findkey.c
@@ -80,13 +80,13 @@ _gdbm_read_entry (GDBM_FILE dbf, int elem_loc)
80 if (rc) 80 if (rc)
81 { 81 {
82 GDBM_DEBUG (GDBM_DEBUG_ERR|GDBM_DEBUG_LOOKUP|GDBM_DEBUG_READ, 82 GDBM_DEBUG (GDBM_DEBUG_ERR|GDBM_DEBUG_LOOKUP|GDBM_DEBUG_READ,
83 "%s: error reading entry: %s", 83 "%s: error reading entry: %s",
84 dbf->name, gdbm_db_strerror (dbf)); 84 dbf->name, gdbm_db_strerror (dbf));
85 dbf->need_recovery = TRUE; 85 dbf->need_recovery = TRUE;
86 _gdbm_fatal (dbf, gdbm_strerror (rc)); 86 _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
87 return NULL; 87 return NULL;
88 } 88 }
89 89
90 return data_ca->dptr; 90 return data_ca->dptr;
91} 91}
92 92
diff --git a/src/gdbmstore.c b/src/gdbmstore.c
index 0bcd7d7..7b2ed04 100644
--- a/src/gdbmstore.c
+++ b/src/gdbmstore.c
@@ -164,25 +164,25 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
164 _gdbm_full_write (dbf, key.dptr, key.dsize)); 164 _gdbm_full_write (dbf, key.dptr, key.dsize));
165 if (rc) 165 if (rc)
166 { 166 {
167 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR, 167 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
168 "%s: error writing key: %s", 168 "%s: error writing key: %s",
169 dbf->name, gdbm_db_strerror (dbf)); 169 dbf->name, gdbm_db_strerror (dbf));
170 _gdbm_fatal (dbf, gdbm_strerror (rc)); 170 _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
171 return -1; 171 return -1;
172 } 172 }
173 173
174 rc = GDBM_DEBUG_OVERRIDE ("gdbm_store:write-2-failure", 174 rc = GDBM_DEBUG_OVERRIDE ("gdbm_store:write-2-failure",
175 _gdbm_full_write (dbf, 175 _gdbm_full_write (dbf,
176 content.dptr, content.dsize)); 176 content.dptr, content.dsize));
177 if (rc) 177 if (rc)
178 { 178 {
179 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR, 179 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
180 "%s: error writing content: %s", 180 "%s: error writing content: %s",
181 dbf->name, gdbm_db_strerror (dbf)); 181 dbf->name, gdbm_db_strerror (dbf));
182 _gdbm_fatal (dbf, gdbm_strerror (rc)); 182 _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
183 return -1; 183 return -1;
184 } 184 }
185 185
186 /* Current bucket has changed. */ 186 /* Current bucket has changed. */
187 dbf->cache_entry->ca_changed = TRUE; 187 dbf->cache_entry->ca_changed = TRUE;
188 dbf->bucket_changed = TRUE; 188 dbf->bucket_changed = TRUE;
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index 18d0e10..33bdf93 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -192,13 +192,12 @@ size_t
192_gdbm_avail_list_size (GDBM_FILE dbf, size_t min_size) 192_gdbm_avail_list_size (GDBM_FILE dbf, size_t min_size)
193{ 193{
194 int temp; 194 int temp;
195 int size; 195 int size;
196 avail_block *av_stk; 196 avail_block *av_stk;
197 size_t lines; 197 size_t lines;
198 int rc;
199 198
200 lines = 4 + dbf->header->avail.count; 199 lines = 4 + dbf->header->avail.count;
201 if (lines > min_size) 200 if (lines > min_size)
202 return lines; 201 return lines;
203 /* Initialize the variables for a pass throught the avail stack. */ 202 /* Initialize the variables for a pass throught the avail stack. */
204 temp = dbf->header->avail.next_block; 203 temp = dbf->header->avail.next_block;
@@ -212,19 +211,15 @@ _gdbm_avail_list_size (GDBM_FILE dbf, size_t min_size)
212 if (__lseek (dbf, temp, SEEK_SET) != temp) 211 if (__lseek (dbf, temp, SEEK_SET) != temp)
213 { 212 {
214 terror ("lseek: %s", strerror (errno)); 213 terror ("lseek: %s", strerror (errno));
215 break; 214 break;
216 } 215 }
217 216
218 if ((rc = _gdbm_full_read (dbf, av_stk, size))) 217 if (_gdbm_full_read (dbf, av_stk, size))
219 { 218 {
220 if (rc == GDBM_FILE_EOF) 219 terror ("read: %s", gdbm_db_strerror (dbf));
221 terror ("read: %s", gdbm_strerror (rc));
222 else
223 terror ("read: %s (%s)",
224 gdbm_strerror (rc), strerror (errno));
225 break; 220 break;
226 } 221 }
227 222
228 if (gdbm_avail_block_valid_p (av_stk)) 223 if (gdbm_avail_block_valid_p (av_stk))
229 { 224 {
230 lines += av_stk->count; 225 lines += av_stk->count;
@@ -253,13 +248,12 @@ av_table_display (avail_elem *av_table, int count, FILE *fp)
253void 248void
254_gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf) 249_gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
255{ 250{
256 int temp; 251 int temp;
257 int size; 252 int size;
258 avail_block *av_stk; 253 avail_block *av_stk;
259 int rc;
260 254
261 /* Print the the header avail block. */ 255 /* Print the the header avail block. */
262 fprintf (fp, _("\nheader block\nsize = %d\ncount = %d\n"), 256 fprintf (fp, _("\nheader block\nsize = %d\ncount = %d\n"),
263 dbf->header->avail.size, dbf->header->avail.count); 257 dbf->header->avail.size, dbf->header->avail.count);
264 av_table_display (dbf->header->avail.av_table, dbf->header->avail.count, fp); 258 av_table_display (dbf->header->avail.av_table, dbf->header->avail.count, fp);
265 259
@@ -275,18 +269,15 @@ _gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
275 if (__lseek (dbf, temp, SEEK_SET) != temp) 269 if (__lseek (dbf, temp, SEEK_SET) != temp)
276 { 270 {
277 terror ("lseek: %s", strerror (errno)); 271 terror ("lseek: %s", strerror (errno));
278 break; 272 break;
279 } 273 }
280 274
281 if ((rc = _gdbm_full_read (dbf, av_stk, size))) 275 if (_gdbm_full_read (dbf, av_stk, size))
282 { 276 {
283 if (rc == GDBM_FILE_EOF) 277 terror ("read: %s", gdbm_db_strerror (dbf));
284 terror ("read: %s", gdbm_strerror (rc));
285 else
286 terror ("read: %s (%s)", gdbm_strerror (rc), strerror (errno));
287 break; 278 break;
288 } 279 }
289 280
290 /* Print the block! */ 281 /* Print the block! */
291 fprintf (fp, _("\nblock = %d\nsize = %d\ncount = %d\n"), temp, 282 fprintf (fp, _("\nblock = %d\nsize = %d\ncount = %d\n"), temp,
292 av_stk->size, av_stk->count); 283 av_stk->size, av_stk->count);
diff --git a/src/update.c b/src/update.c
index 905ba69..63c6c95 100644
--- a/src/update.c
+++ b/src/update.c
@@ -109,13 +109,13 @@ _gdbm_end_update (GDBM_FILE dbf)
109 _gdbm_full_write (dbf, dbf->dir, dbf->header->dir_size)); 109 _gdbm_full_write (dbf, dbf->dir, dbf->header->dir_size));
110 if (rc) 110 if (rc)
111 { 111 {
112 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR, 112 GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
113 "%s: error writing directory: %s", 113 "%s: error writing directory: %s",
114 dbf->name, gdbm_db_strerror (dbf)); 114 dbf->name, gdbm_db_strerror (dbf));
115 _gdbm_fatal (dbf, gdbm_strerror (rc)); 115 _gdbm_fatal (dbf, gdbm_db_strerror (dbf));
116 return -1; 116 return -1;
117 } 117 }
118 118
119 dbf->directory_changed = FALSE; 119 dbf->directory_changed = FALSE;
120 if (!dbf->header_changed && dbf->fast_write == FALSE) 120 if (!dbf->header_changed && dbf->fast_write == FALSE)
121 __fsync (dbf); 121 __fsync (dbf);

Return to:

Send suggestions and report system problems to the System administrator.