Franky,

Here are some really embarrassing bugs that have been in libkarma
for a while.  I should quit writing code. :)

Joe, try these patches out; they may help things.

# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1168557422 18000
# Node ID 0a2e507959e8ed0bb282e18f34631f145dafcd89
# Parent  684d21e7e6ff2085a6664085e1411cae74bbf64f
Fix boneheaded ret variable confusion

diff -r 684d21e7e6ff -r 0a2e507959e8 src/properties.c
--- a/src/properties.c  Sat Dec 23 17:04:16 2006 -0500
+++ b/src/properties.c  Thu Jan 11 18:17:02 2007 -0500
@@ -696,7 +696,7 @@ int lk_properties_write_smalldb(char *us
 int lk_properties_write_smalldb(char *usbMountPoint, karma_db_t *db)
 {
     uint32_t i, len, arrsz, nfiles = props.count-1;
-    uint32_t ret = 1;
+    uint32_t ret = 0;
     uint32_t *offset = NULL;
     table_t *table = NULL;
     char *tmp = NULL;
@@ -738,9 +738,11 @@ int lk_properties_write_smalldb(char *us
         goto err;
 
     if (db->num_attribs == 0)
+    {
         ret = smalldb_init(db);
-    if (ret)
-        goto err;
+        if (ret)
+            goto err;
+    }
 
     db->ctime = (int) time(NULL);
     fwrite(&db->version, sizeof(uint32_t), 1, fp);
@@ -793,9 +795,11 @@ int lk_properties_write_smalldb(char *us
 
     fwrite(&db->ctime, sizeof(uint32_t), 1, fp);
     fclose(fp);
-
-    ret = 0;
+    goto out;
+
 err:
+    ret = 1;
+out:
     if (arr) free(arr);
     if (offset) free(offset);
     if (table) free(table);

# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1168559805 18000
# Node ID 9c805535e504cf8a379cdc028941499b011a7100
# Parent  0a2e507959e8ed0bb282e18f34631f145dafcd89
Blank out dmap and playlist counts

diff -r 0a2e507959e8 -r 9c805535e504 src/karmaUsb.c
--- a/src/karmaUsb.c    Thu Jan 11 18:17:02 2007 -0500
+++ b/src/karmaUsb.c    Thu Jan 11 18:56:45 2007 -0500
@@ -741,8 +741,6 @@ static int32_t read_properties_smalldb(c
     }
     *ptr = '\0';
     *properties = tmp;
-    db->dmap_size = 0;
-    db->num_playlists = 0;
 
   out:
     ret = 0;
@@ -755,6 +753,8 @@ static int32_t read_properties_smalldb(c
         free(prop_strs);
     if (db)
     {
+        db->dmap_size = 0;
+        db->num_playlists = 0;
         if (db->dmap)
             free(db->dmap);
         if (db->playlists)
-- 
Bob Copeland %% www.bobcopeland.com 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel

Reply via email to