]> git.pld-linux.org Git - packages/poldek.git/commitdiff
- use intermediate variables instead of n_array_size() - fixes two problems:
authorsparky <sparky@pld-linux.org>
Thu, 4 Feb 2010 23:45:35 +0000 (23:45 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
  * comparision between signed (int) and unsigned (size_t) intergers
  * calling n_array_size() function for each loop iteration
- make sdiff negative when uninstalling - prevents second check for:
  ts->type != POLDEK_TS_UNINSTALL
- abs() if for ints, use labs() instead

Changed files:
    poldek-show_only_relative_used_space.patch -> 1.3

poldek-show_only_relative_used_space.patch

index 334acd4de69c98267cb7fe182ebfaac5691b58cc..44b9a27553604e5b715f4e24ed8272fa39f899b8 100644 (file)
@@ -22,7 +22,7 @@ index a0dd436..a670379 100644
  void poldek__ts_display_summary(struct poldek_ts *ts)
  {
      int ninst = 0, ndep = 0, nrm = 0, npkgs = 0, parseable = 0;
-+    long sinsts = 0, sdeps = 0, srems = 0, sdiff = 0;
++    long int sinsts = 0, sdeps = 0, srems = 0, sdiff = 0;
      tn_array *ipkgs, *idepkgs, *rmpkgs, *pkgs;
      char ms[1024], *to, *prefix;
 -    int n;
@@ -41,17 +41,17 @@ index a0dd436..a670379 100644
 -    
 -    if (ts->type == POLDEK_TS_UNINSTALL) {
 +    if (ipkgs)
-+      for (i=0; i < n_array_size(ipkgs); i++) {
++      for (i=0; i < ninst; i++) {
 +          struct pkg *pkg = n_array_nth(ipkgs, i);
 +          sinsts += pkg->size;
 +      }
 +    if (idepkgs)
-+      for (i=0; i < n_array_size(idepkgs); i++) {
++      for (i=0; i < ndep; i++) {
 +          struct pkg *pkg = n_array_nth(idepkgs, i);
 +          sdeps += pkg->size;
 +      }
 +    if (rmpkgs)
-+      for (i=0; i < n_array_size(rmpkgs); i++) {
++      for (i=0; i < nrm; i++) {
 +          struct pkg *pkg = n_array_nth(rmpkgs, i);
 +          srems += pkg->size;
 +      }
@@ -67,7 +67,7 @@ index a0dd436..a670379 100644
          prefix = "R";
          pkgs = rmpkgs;
          npkgs = nrm + ndep;
-+        sdiff = sdeps + srems;
++        sdiff = - srems - sdeps;
          nrm = 0;
      }
      n_assert(pkgs);
@@ -76,14 +76,14 @@ index a0dd436..a670379 100644
              packages_display_summary(1, "R", rmpkgs, parseable);
      }
 +
-+    if (sdiff) {
-+      char size[64];
-+        snprintf_size(size, sizeof(size), abs(sdiff), 1, 1);
++    if (sdiff != 0) {
++        char size[64];
++        snprintf_size(size, sizeof(size), labs(sdiff), 1, 1);
 +
-+        if (sdiff > 0 && ts->type != POLDEK_TS_UNINSTALL)
-+          msgn(1, _("This operation will take %s of disk space."), size);
-+      else
-+          msgn(1, _("This operation will free %s of disk space."), size);
++        if (sdiff > 0)
++           msgn(1, _("This operation will take %s of disk space."), size);
++        else
++           msgn(1, _("This operation will free %s of disk space."), size);
 +    }
  }
  
This page took 0.036593 seconds and 4 git commands to generate.