bug#16134: [PATCH 1/2] libparted:tests: Move get_sector_size() to common.c

John Paul Adrian Glaubitz <[email protected]>
Newsgroups gmane.comp.gnu.parted.bugs
Message-ID <20161204161246.30936-2-glaubitz__36202.8930605904$1480867996$gmane$org@physik.fu-berlin.de>
Moving get_sector_size() from disk.c to common.c allows
us to use it in _implemented_disk_label() to test for
512-byte sectors. This change is required to be able to
enable this test for atari partition tables for which
support is added in a follow-up patch.

Signed-off-by: John Paul Adrian Glaubitz <[email protected]>
---
 libparted/tests/common.c | 14 ++++++++++++++
 libparted/tests/common.h |  5 +++++
 libparted/tests/disk.c   | 15 ---------------
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/libparted/tests/common.c b/libparted/tests/common.c
index a0be997..9115686 100644
--- a/libparted/tests/common.c
+++ b/libparted/tests/common.c
@@ -7,9 +7,23 @@
 #include <check.h>
 
 #include "common.h"
+#include "xstrtol.h"
 
 #define STREQ(a, b) (strcmp (a, b) == 0)
 
+size_t get_sector_size (void)
+{
+  char *p = getenv ("PARTED_SECTOR_SIZE");
+  size_t ss = 512;
+  unsigned long val;
+  if (p
+      && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK
+      && val % 512 == 0)
+    ss = val;
+
+  return ss;
+}
+
 PedExceptionOption
 _test_exception_handler (PedException* e)
 {
diff --git a/libparted/tests/common.h b/libparted/tests/common.h
index 1b1c801..5d7485e 100644
--- a/libparted/tests/common.h
+++ b/libparted/tests/common.h
@@ -1,5 +1,10 @@
 #include <parted/parted.h>
 
+/* Determine sector size from environment
+ *
+ */
+size_t get_sector_size (void);
+
 /* Create an empty disk image
  *
  * filename: file (with full path) where to write the disk image
diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
index 48561b9..62d20c1 100644
--- a/libparted/tests/disk.c
+++ b/libparted/tests/disk.c
@@ -7,24 +7,9 @@
 
 #include "common.h"
 #include "progname.h"
-#include "xstrtol.h"
 
 static char* temporary_disk;
 
-static
-size_t get_sector_size (void)
-{
-  char *p = getenv ("PARTED_SECTOR_SIZE");
-  size_t ss = 512;
-  unsigned long val;
-  if (p
-      && xstrtoul (p, NULL, 10, &val, NULL) == LONGINT_OK
-      && val % 512 == 0)
-    ss = val;
-
-  return ss;
-}
-
 static void
 create_disk (void)
 {
-- 
2.10.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.