poldek: poldek/pkgdir/pndir/save.c - killed FPE

mis mis at pld-linux.org
Sat Jun 23 19:44:50 CEST 2007


Author: mis                          Date: Sat Jun 23 17:44:50 2007 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- killed FPE

---- Files affected:
poldek/poldek/pkgdir/pndir:
   save.c (1.29 -> 1.30) 

---- Diffs:

================================================================
Index: poldek/poldek/pkgdir/pndir/save.c
diff -u poldek/poldek/pkgdir/pndir/save.c:1.29 poldek/poldek/pkgdir/pndir/save.c:1.30
--- poldek/poldek/pkgdir/pndir/save.c:1.29	Wed Oct 12 21:25:57 2005
+++ poldek/poldek/pkgdir/pndir/save.c	Sat Jun 23 19:44:45 2007
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2000 - 2005 Pawel A. Gajda <mis at k2.net.pl>
+  Copyright (C) 2000 - 2007 Pawel A. Gajda <mis at pld-linux.org>
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License, version 2 as
@@ -147,12 +147,16 @@
     tn_array *avlangs;
     tn_hash *langs_h = NULL;
     int i;
-    
+
     n_assert(pkgdir->avlangs_h);
+    n_assert(pkgdir->pkgs);
     
     if (n_hash_size(pkgdir->avlangs_h) == 0)
         return NULL;
 
+    if (n_array_size(pkgdir->pkgs) == 0) /* division by zero (FPE) */
+        return NULL;
+
     langs_h = n_hash_new(32, NULL);
     n_hash_ctl(langs_h, TN_HASH_NOCPKEY);
     n_buf_clean(nbuf);
@@ -644,8 +648,7 @@
     tn_array         *exclpath = NULL;
 
     idx = pkgdir->mod_data;
-    if (pkgdir->ts == 0) 
-        pkgdir->ts = time(0);
+    n_assert(pkgdir->ts > 0);   /* must be set by the caller */
 
     if (pathname == NULL) {
         if (pkgdir->flags & PKGDIR_DIFF)
@@ -653,7 +656,9 @@
         else
             pathname = pndir_localidxpath(pkgdir);
     }
-
+    
+    DBGF("Saving %s ts=%ld (%s)\n", pathname, pkgdir->ts, strtime_(pkgdir->ts));
+    
     n_assert(pathname);
     mk_paths(&paths, pathname, pkgdir);
     
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/pndir/save.c?r1=1.29&r2=1.30&f=u



More information about the pld-cvs-commit mailing list