]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: make qsort_r() optional
authorKarel Zak <kzak@redhat.com>
Fri, 4 Apr 2014 14:02:35 +0000 (16:02 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 23 Apr 2014 09:55:08 +0000 (11:55 +0200)
The function is no critical for fdisk functionality. The SUN label
verification will check for less issues. All the verification code is
optional ('v' fdisk command).

Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
libfdisk/src/sun.c

index 35a1f260eb9c425fb44144727c435b37aba9dfbe..5052605c16c62a1273bfb339ff64dd99bfaf26aa 100644 (file)
@@ -303,6 +303,7 @@ AC_CHECK_FUNCS([ \
        personality \
        posix_fadvise \
        prctl \
+       qsort_r \
        rpmatch \
        scandirat \
        setresgid \
index e73c701fb7315acd9a7fa2be6f1fe62a4497d5fa..9f1d7152448cb764bd909ed523436c1fe383bcc1 100644 (file)
@@ -361,6 +361,7 @@ static void fetch_sun(struct fdisk_context *cxt,
        }
 }
 
+#ifdef HAVE_QSORT_R
 static int verify_sun_cmp(int *a, int *b, void *data)
 {
     unsigned int *verify_sun_starts = (unsigned int *) data;
@@ -373,20 +374,20 @@ static int verify_sun_cmp(int *a, int *b, void *data)
            return 1;
     return -1;
 }
+#endif
 
 static int sun_verify_disklabel(struct fdisk_context *cxt)
 {
     uint32_t starts[SUN_MAXPARTITIONS], lens[SUN_MAXPARTITIONS], start, stop;
     uint32_t i,j,k,starto,endo;
+#ifdef HAVE_QSORT_R
     int array[SUN_MAXPARTITIONS];
     unsigned int *verify_sun_starts;
-
+#endif
     assert(cxt);
     assert(cxt->label);
     assert(fdisk_is_disklabel(cxt, SUN));
 
-    verify_sun_starts = starts;
-
     fetch_sun(cxt, starts, lens, &start, &stop);
 
     for (k = 0; k < 7; k++) {
@@ -421,12 +422,15 @@ static int sun_verify_disklabel(struct fdisk_context *cxt)
        }
     }
 
+#ifdef HAVE_QSORT_R
     for (i = 0; i < SUN_MAXPARTITIONS; i++) {
         if (lens[i])
             array[i] = i;
         else
             array[i] = -1;
     }
+    verify_sun_starts = starts;
+
     qsort_r(array,ARRAY_SIZE(array),sizeof(array[0]),
          (int (*)(const void *,const void *,void *)) verify_sun_cmp,
          verify_sun_starts);
@@ -446,6 +450,7 @@ static int sun_verify_disklabel(struct fdisk_context *cxt)
     start = (starts[array[i]] + lens[array[i]]);
     if (start < stop)
         fdisk_warnx(cxt, _("Unused gap - sectors %d-%d."), start, stop);
+#endif
     return 0;
 }