summaryrefslogtreecommitdiff
path: root/src/lib/eet
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-11-24 14:27:13 -0800
committerCedric BAIL <cedric@osg.samsung.com>2015-11-24 14:27:13 -0800
commit6a7257f5a7c8cbcfc35772dd0f385888b9196203 (patch)
tree79e540b55f918f83c91b9bc78ae30285055e2888 /src/lib/eet
parent699a57c7e46e13476b88aa37a0342722919c56d6 (diff)
eet: improve error message during eet_close.
Diffstat (limited to 'src/lib/eet')
-rw-r--r--src/lib/eet/eet_lib.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c
index 11d07069b6..4d0dfbae5d 100644
--- a/src/lib/eet/eet_lib.c
+++ b/src/lib/eet/eet_lib.c
@@ -340,17 +340,25 @@ eet_flush2(Eet_File *ef)
340 /* opening for write - delete old copy of file right away */ 340 /* opening for write - delete old copy of file right away */
341 unlink(ef->path); 341 unlink(ef->path);
342 fd = open(ef->path, O_CREAT | O_TRUNC | O_RDWR | O_BINARY, S_IRUSR | S_IWUSR); 342 fd = open(ef->path, O_CREAT | O_TRUNC | O_RDWR | O_BINARY, S_IRUSR | S_IWUSR);
343 if (fd < 0) 343 if (fd < 0)
344 return EET_ERROR_NOT_WRITABLE; 344 {
345 ERR("Can't write file '%s'.", ef->path);
346 return EET_ERROR_NOT_WRITABLE;
347 }
345 348
346 fp = fdopen(fd, "wb"); 349 fp = fdopen(fd, "wb");
347 if (!fp) 350 if (!fp)
348 return EET_ERROR_NOT_WRITABLE; 351 {
352 ERR("Can't write file '%s'.", ef->path);
353 return EET_ERROR_NOT_WRITABLE;
354 }
349 355
350 if (fcntl(fd, F_SETFD, FD_CLOEXEC)) ERR("can't set CLOEXEC on write fd"); 356 if (fcntl(fd, F_SETFD, FD_CLOEXEC)) ERR("can't set CLOEXEC on write fd");
351 } 357 }
352 else 358 else
353 return EET_ERROR_NOT_WRITABLE; 359 {
360 return EET_ERROR_NOT_WRITABLE;
361 }
354 362
355 /* calculate string base offset and data base offset */ 363 /* calculate string base offset and data base offset */
356 num = (1 << ef->header->directory->size); 364 num = (1 << ef->header->directory->size);
@@ -436,11 +444,11 @@ eet_flush2(Eet_File *ef)
436 for (j = 0; j < ef->ed->count; ++j) 444 for (j = 0; j < ef->ed->count; ++j)
437 { 445 {
438 int sbuf[EET_FILE2_DICTIONARY_ENTRY_COUNT]; 446 int sbuf[EET_FILE2_DICTIONARY_ENTRY_COUNT];
439 int prev = 0; 447 int prev = 0;
440 448
441 // We still use the prev as an hint for knowing if it is the head of the hash 449 // We still use the prev as an hint for knowing if it is the head of the hash
442 if (ef->ed->hash[ef->ed->all_hash[j]] == j) 450 if (ef->ed->hash[ef->ed->all_hash[j]] == j)
443 prev = -1; 451 prev = -1;
444 452
445 sbuf[0] = (int)htonl((unsigned int)ef->ed->all_hash[j]); 453 sbuf[0] = (int)htonl((unsigned int)ef->ed->all_hash[j]);
446 sbuf[1] = (int)htonl((unsigned int)offset); 454 sbuf[1] = (int)htonl((unsigned int)offset);
@@ -521,6 +529,7 @@ eet_flush2(Eet_File *ef)
521write_error: 529write_error:
522 if (ferror(fp)) 530 if (ferror(fp))
523 { 531 {
532 ERR("Error during write on '%s'.", ef->path);
524 switch (errno) 533 switch (errno)
525 { 534 {
526 case EFBIG: error = EET_ERROR_WRITE_ERROR_FILE_TOO_BIG; break; 535 case EFBIG: error = EET_ERROR_WRITE_ERROR_FILE_TOO_BIG; break;
@@ -1256,11 +1265,14 @@ static Eet_Error
1256eet_internal_close(Eet_File *ef, 1265eet_internal_close(Eet_File *ef,
1257 Eina_Bool locked) 1266 Eina_Bool locked)
1258{ 1267{
1259 Eet_Error err; 1268 Eet_Error err = EET_ERROR_NONE;
1260 1269
1261 /* check to see its' an eet file pointer */ 1270 /* check to see its' an eet file pointer */
1262 if (eet_check_pointer(ef)) 1271 if (eet_check_pointer(ef))
1263 return EET_ERROR_BAD_OBJECT; 1272 {
1273 ERR("Bad file descriptor '%p'\n", ef);
1274 return EET_ERROR_BAD_OBJECT;
1275 }
1264 1276
1265 if (!locked) 1277 if (!locked)
1266 LOCK_CACHE; 1278 LOCK_CACHE;