OSDN Git Service

build: mark functions with "const" or "pure" attribute, per gcc warnings
authorJim Meyering <meyering@redhat.com>
Sat, 3 Dec 2011 13:57:26 +0000 (14:57 +0100)
committerJim Meyering <meyering@redhat.com>
Sat, 3 Dec 2011 14:43:33 +0000 (15:43 +0100)
Use _GL_ATTRIBUTE_PURE or _GL_ATTRIBUTE_CONST.  Mark static functions at
point of definition; extern ones at point of declaration.
* include/parted/crc32.h:
* include/parted/device.h: Likewise.
* include/parted/disk.h: Likewise.
* include/parted/exception.h: Likewise.
* include/parted/filesys.h: Likewise.
* include/parted/geom.h: Likewise.
* include/parted/natmath.h: Likewise.
* include/parted/parted.h: Likewise.
* include/parted/unit.h: Likewise.
* libparted/arch/linux.c: Likewise.
* libparted/disk.c: Likewise.
* libparted/exception.c: Likewise.
* libparted/fs/amiga/amiga.h: Likewise.
* libparted/labels/aix.c: Likewise.
* libparted/labels/bsd.c: Likewise.
* libparted/labels/dos.c: Likewise.
* libparted/labels/dvh.c: Likewise.
* libparted/labels/efi_crc32.c: Likewise.
* libparted/labels/gpt.c: Likewise.
* libparted/labels/mac.c: Likewise.
* libparted/labels/pc98.c: Likewise.
* libparted/labels/rdb.c: Likewise.
* libparted/labels/sun.c: Likewise.
* libparted/unit.c: Likewise.
* parted/ui.c: Likewise.
* parted/strlist.c: Likewise.
* parted/strlist.h: Likewise.
* libparted/tests/common.h (_implemented_disk_label): Mark as pure.
* libparted/cs/natmath.c (extended_euclid): Mark as pure.

31 files changed:
include/parted/constraint.h
include/parted/crc32.h
include/parted/device.h
include/parted/disk.h
include/parted/exception.h
include/parted/filesys.h
include/parted/geom.h
include/parted/natmath.h
include/parted/parted.h
include/parted/unit.h
libparted/arch/linux.c
libparted/cs/natmath.c
libparted/disk.c
libparted/exception.c
libparted/fs/amiga/amiga.h
libparted/labels/aix.c
libparted/labels/bsd.c
libparted/labels/dos.c
libparted/labels/dvh.c
libparted/labels/efi_crc32.c
libparted/labels/gpt.c
libparted/labels/mac.c
libparted/labels/pc98.c
libparted/labels/rdb.c
libparted/labels/sun.c
libparted/tests/common.h
libparted/unit.c
parted/strlist.c
parted/strlist.h
parted/ui.c
parted/ui.h

index 4098835..a25689a 100644 (file)
@@ -85,7 +85,7 @@ ped_constraint_solve_nearest (
 
 extern int
 ped_constraint_is_solution (const PedConstraint* constraint,
-                           const PedGeometry* geom);
+                           const PedGeometry* geom) _GL_ATTRIBUTE_PURE;
 
 extern PedConstraint*
 ped_constraint_any (const PedDevice* dev);
index 9d55723..0bdd879 100644 (file)
@@ -29,6 +29,6 @@
  */
 
 extern uint32_t __efi_crc32 (const void *buf, unsigned long len,
-                            uint32_t seed);
+                            uint32_t seed) _GL_ATTRIBUTE_PURE;
 
 #endif /* _CRC32_H */
index d76854a..5d7562a 100644 (file)
@@ -1,6 +1,6 @@
 /*
     libparted - a library for manipulating disk partitions
-    Copyright (C) 1998 - 2001, 2005, 2007-2008 Free Software Foundation, Inc.
+    Copyright (C) 1998-2001, 2005, 2007-2008, 2011 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -127,7 +127,7 @@ extern void ped_device_probe_all ();
 extern void ped_device_free_all ();
 
 extern PedDevice* ped_device_get (const char* name);
-extern PedDevice* ped_device_get_next (const PedDevice* dev);
+extern PedDevice* ped_device_get_next (const PedDevice* dev) _GL_ATTRIBUTE_PURE;
 extern int ped_device_is_busy (PedDevice* dev);
 extern int ped_device_open (PedDevice* dev);
 extern int ped_device_close (PedDevice* dev);
index dd461fb..1113213 100644 (file)
@@ -269,10 +269,13 @@ struct _PedDiskArchOps {
 extern void ped_disk_type_register (PedDiskType* type);
 extern void ped_disk_type_unregister (PedDiskType* type);
 
-extern PedDiskType* ped_disk_type_get_next (PedDiskType const *type);
-extern PedDiskType* ped_disk_type_get (const char* name);
+extern PedDiskType* ped_disk_type_get_next (PedDiskType const *type)
+  _GL_ATTRIBUTE_PURE;
+extern PedDiskType* ped_disk_type_get (const char* name)
+  _GL_ATTRIBUTE_PURE;
 extern int ped_disk_type_check_feature (const PedDiskType* disk_type,
-                                        PedDiskTypeFeature feature);
+                                        PedDiskTypeFeature feature)
+  _GL_ATTRIBUTE_PURE;
 
 extern PedDiskType* ped_disk_probe (PedDevice* dev);
 extern int ped_disk_clobber (PedDevice* dev);
@@ -287,8 +290,10 @@ extern int ped_disk_commit_to_os (PedDisk* disk);
 extern int ped_disk_check (const PedDisk* disk);
 extern void ped_disk_print (const PedDisk* disk);
 
-extern int ped_disk_get_primary_partition_count (const PedDisk* disk);
-extern int ped_disk_get_last_partition_num (const PedDisk* disk);
+extern int ped_disk_get_primary_partition_count (const PedDisk* disk)
+  _GL_ATTRIBUTE_PURE;
+extern int ped_disk_get_last_partition_num (const PedDisk* disk)
+  _GL_ATTRIBUTE_PURE;
 extern int ped_disk_get_max_primary_partition_count (const PedDisk* disk);
 extern bool ped_disk_get_max_supported_partition_count(const PedDisk* disk,
                                                        int* supported);
@@ -300,7 +305,7 @@ extern int ped_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag);
 
 extern const char *ped_disk_flag_get_name(PedDiskFlag flag);
 extern PedDiskFlag ped_disk_flag_get_by_name(const char *name);
-extern PedDiskFlag ped_disk_flag_next(PedDiskFlag flag);
+extern PedDiskFlag ped_disk_flag_next(PedDiskFlag flag) _GL_ATTRIBUTE_CONST;
 
 /** @} */
 
@@ -316,7 +321,7 @@ extern PedPartition* ped_partition_new (const PedDisk* disk,
                                         PedSector start,
                                         PedSector end);
 extern void ped_partition_destroy (PedPartition* part);
-extern int ped_partition_is_active (const PedPartition* part);
+extern int ped_partition_is_active (const PedPartition* part) _GL_ATTRIBUTE_PURE;
 extern int ped_partition_set_flag (PedPartition* part, PedPartitionFlag flag,
                                    int state);
 extern int ped_partition_get_flag (const PedPartition* part,
@@ -330,10 +335,12 @@ extern const char* ped_partition_get_name (const PedPartition* part);
 extern int ped_partition_is_busy (const PedPartition* part);
 extern char* ped_partition_get_path (const PedPartition* part);
 
-extern const char* ped_partition_type_get_name (PedPartitionType part_type);
+extern const char* ped_partition_type_get_name (PedPartitionType part_type)
+  _GL_ATTRIBUTE_CONST;
 extern const char* ped_partition_flag_get_name (PedPartitionFlag flag);
 extern PedPartitionFlag ped_partition_flag_get_by_name (const char* name);
-extern PedPartitionFlag ped_partition_flag_next (PedPartitionFlag flag);
+extern PedPartitionFlag ped_partition_flag_next (PedPartitionFlag flag)
+  _GL_ATTRIBUTE_CONST;
 
 /** @} */
 
@@ -357,11 +364,15 @@ extern PedGeometry* ped_disk_get_max_partition_geometry (PedDisk* disk,
 extern int ped_disk_minimize_extended_partition (PedDisk* disk);
 
 extern PedPartition* ped_disk_next_partition (const PedDisk* disk,
-                                              const PedPartition* part);
-extern PedPartition* ped_disk_get_partition (const PedDisk* disk, int num);
+                                              const PedPartition* part)
+  _GL_ATTRIBUTE_PURE;
+extern PedPartition* ped_disk_get_partition (const PedDisk* disk, int num)
+  _GL_ATTRIBUTE_PURE;
 extern PedPartition* ped_disk_get_partition_by_sector (const PedDisk* disk,
-                                                       PedSector sect);
-extern PedPartition* ped_disk_extended_partition (const PedDisk* disk);
+                                                       PedSector sect)
+  _GL_ATTRIBUTE_PURE;
+extern PedPartition* ped_disk_extended_partition (const PedDisk* disk)
+  _GL_ATTRIBUTE_PURE;
 
 extern PedSector ped_disk_max_partition_length (const PedDisk *disk);
 extern PedSector ped_disk_max_partition_start_sector (const PedDisk *disk);
index bfa6eb1..b1fb3ee 100644 (file)
@@ -83,11 +83,14 @@ typedef PedExceptionOption (PedExceptionHandler) (PedException* ex);
 
 extern int ped_exception;      /* set to true if there's an exception */
 
-extern char* ped_exception_get_type_string (PedExceptionType ex_type);
-extern char* ped_exception_get_option_string (PedExceptionOption ex_opt);
+extern char* ped_exception_get_type_string (PedExceptionType ex_type)
+     _GL_ATTRIBUTE_CONST;
+extern char* ped_exception_get_option_string (PedExceptionOption ex_opt)
+     _GL_ATTRIBUTE_PURE;
 
 extern void ped_exception_set_handler (PedExceptionHandler* handler);
-extern PedExceptionHandler *ped_exception_get_handler(void);
+extern PedExceptionHandler *ped_exception_get_handler(void)
+     _GL_ATTRIBUTE_PURE;
 
 extern PedExceptionOption ped_exception_default_handler (PedException* ex);
 
index 44258f5..3e20f6a 100644 (file)
@@ -86,10 +86,12 @@ extern void ped_file_system_alias_unregister (PedFileSystemType* type,
 
 extern PedFileSystemType* ped_file_system_type_get (const char* name);
 extern PedFileSystemType*
-ped_file_system_type_get_next (const PedFileSystemType* fs_type);
+ped_file_system_type_get_next (const PedFileSystemType* fs_type)
+  _GL_ATTRIBUTE_PURE;
 
 extern PedFileSystemAlias*
-ped_file_system_alias_get_next (const PedFileSystemAlias* fs_alias);
+ped_file_system_alias_get_next (const PedFileSystemAlias* fs_alias)
+  _GL_ATTRIBUTE_PURE;
 
 extern PedFileSystemType* ped_file_system_probe (PedGeometry* geom);
 extern PedGeometry* ped_file_system_probe_specific (
index 0aea2b5..ee947ef 100644 (file)
@@ -55,12 +55,13 @@ extern int ped_geometry_set (PedGeometry* geom, PedSector start,
 extern int ped_geometry_set_start (PedGeometry* geom, PedSector start);
 extern int ped_geometry_set_end (PedGeometry* geom, PedSector end);
 extern int ped_geometry_test_overlap (const PedGeometry* a,
-                                     const PedGeometry* b);
+                                     const PedGeometry* b) _GL_ATTRIBUTE_PURE;
 extern int ped_geometry_test_inside (const PedGeometry* a,
-                                    const PedGeometry* b);
-extern int ped_geometry_test_equal (const PedGeometry* a, const PedGeometry* b);
+                                    const PedGeometry* b) _GL_ATTRIBUTE_PURE;
+extern int ped_geometry_test_equal (const PedGeometry* a, const PedGeometry* b)
+  _GL_ATTRIBUTE_PURE;
 extern int ped_geometry_test_sector_inside (const PedGeometry* geom,
-                                           PedSector sect);
+                                           PedSector sect) _GL_ATTRIBUTE_PURE;
 
 extern int ped_geometry_read (const PedGeometry* geom, void* buffer,
                              PedSector offset, PedSector count);
@@ -78,7 +79,7 @@ extern int ped_geometry_sync_fast (PedGeometry* geom);
 /* returns -1 if "sector" is not within dest's space. */
 extern PedSector ped_geometry_map (const PedGeometry* dst,
                                   const PedGeometry* src,
-                                  PedSector sector);
+                                  PedSector sector) _GL_ATTRIBUTE_PURE;
 
 #endif /* PED_GEOM_H_INCLUDED */
 
index 02c5ee8..a88ff06 100644 (file)
@@ -58,10 +58,14 @@ struct _PedAlignment {
        PedSector       grain_size;
 };
 
-extern PedSector ped_round_up_to (PedSector sector, PedSector grain_size);
-extern PedSector ped_round_down_to (PedSector sector, PedSector grain_size);
-extern PedSector ped_round_to_nearest (PedSector sector, PedSector grain_size);
-extern PedSector ped_greatest_common_divisor (PedSector a, PedSector b);
+extern PedSector ped_round_up_to (PedSector sector, PedSector grain_size)
+  _GL_ATTRIBUTE_CONST;
+extern PedSector ped_round_down_to (PedSector sector, PedSector grain_size)
+  _GL_ATTRIBUTE_CONST;
+extern PedSector ped_round_to_nearest (PedSector sector, PedSector grain_size)
+  _GL_ATTRIBUTE_CONST;
+extern PedSector ped_greatest_common_divisor (PedSector a, PedSector b)
+  _GL_ATTRIBUTE_PURE;
 
 extern int ped_alignment_init (PedAlignment* align, PedSector offset,
                               PedSector grain_size);
@@ -73,17 +77,17 @@ extern PedAlignment* ped_alignment_intersect (const PedAlignment* a,
 
 extern PedSector
 ped_alignment_align_up (const PedAlignment* align, const PedGeometry* geom,
-                       PedSector sector);
+                       PedSector sector) _GL_ATTRIBUTE_PURE;
 extern PedSector
 ped_alignment_align_down (const PedAlignment* align, const PedGeometry* geom,
-                         PedSector sector);
+                         PedSector sector) _GL_ATTRIBUTE_PURE;
 extern PedSector
 ped_alignment_align_nearest (const PedAlignment* align, const PedGeometry* geom,
-                            PedSector sector);
+                            PedSector sector) _GL_ATTRIBUTE_PURE;
 
 extern int
 ped_alignment_is_aligned (const PedAlignment* align, const PedGeometry* geom,
-                         PedSector sector);
+                         PedSector sector) _GL_ATTRIBUTE_PURE;
 
 extern const PedAlignment* ped_alignment_any;
 extern const PedAlignment* ped_alignment_none;
index f0e8847..7826330 100644 (file)
@@ -37,7 +37,7 @@ extern "C" {
 #include <stdlib.h>
 #include <string.h>
 
-extern const char* ped_get_version ();
+extern const char* ped_get_version () _GL_ATTRIBUTE_CONST;
 
 extern void* ped_malloc (size_t size);
 extern void* ped_calloc (size_t size);
index ceb53ac..d3296c3 100644 (file)
@@ -65,8 +65,9 @@ typedef enum {
 #define PED_UNIT_LAST PED_UNIT_TEBIBYTE
 
 extern long long ped_unit_get_size (const PedDevice* dev, PedUnit unit);
-extern const char* ped_unit_get_name (PedUnit unit);
-extern PedUnit ped_unit_get_by_name (const char* unit_name);
+extern const char *ped_unit_get_name (PedUnit unit)
+  _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_CONST;
+extern PedUnit ped_unit_get_by_name (const char* unit_name) _GL_ATTRIBUTE_PURE;
 
 extern void ped_unit_set_default (PedUnit unit);
 extern PedUnit ped_unit_get_default ();
index 1da3343..69878e3 100644 (file)
@@ -2040,7 +2040,7 @@ _compare_digit_state (char ch, int need_digit)
  * Motivation: accept devices looking like /dev/rd/c0d0, but
  * not looking like /dev/hda1 and /dev/rd/c0d0p1
  */
-static int
+static int _GL_ATTRIBUTE_PURE
 _match_rd_device (const char* name)
 {
         const char* pos;
@@ -2115,7 +2115,7 @@ struct _entry {
        size_t len;
 };
 
-static int
+static int _GL_ATTRIBUTE_PURE
 _skip_entry (const char *name)
 {
        struct _entry *i;
@@ -2314,7 +2314,7 @@ _partition_is_mounted (const PedPartition *part)
        return !!status;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 _has_partitions (const PedDisk* disk)
 {
         PED_ASSERT(disk != NULL);
index 0294436..fe15a2e 100644 (file)
@@ -196,7 +196,7 @@ ped_alignment_duplicate (const PedAlignment* align)
  *     gcd = greatest common divisor of a and b
  *     gcd = x*a + y*b
  */
-static EuclidTriple
+static EuclidTriple _GL_ATTRIBUTE_PURE
 extended_euclid (int a, int b)
 {
        EuclidTriple    result;
@@ -340,7 +340,7 @@ ped_alignment_intersect (const PedAlignment* a, const PedAlignment* b)
 /* This function returns the sector closest to "sector" that lies inside
  * geom and satisfies the alignment constraint.
  */
-static PedSector
+static PedSector _GL_ATTRIBUTE_PURE
 _closest_inside_geometry (const PedAlignment* align, const PedGeometry* geom,
                          PedSector sector)
 {
index 807b53a..e059a02 100644 (file)
@@ -286,7 +286,7 @@ error:
 
 /* Given a partition table type NAME, e.g., "gpt", return its PedDiskType
    handle.  If no known type has a name matching NAME, return NULL.  */
-static PedDiskType const *
+static PedDiskType const * _GL_ATTRIBUTE_PURE
 find_disk_type (char const *name)
 {
   PedDiskType const *t;
@@ -1554,7 +1554,7 @@ ped_disk_next_partition (const PedDisk* disk, const PedPartition* part)
 /** @} */
 
 #ifdef DEBUG
-static int
+static int _GL_ATTRIBUTE_PURE
 _disk_check_sanity (PedDisk* disk)
 {
        PedPartition*   walk;
@@ -1807,7 +1807,7 @@ _partition_get_overlap_constraint (PedPartition* part, PedGeometry* geom)
  * Note: overlap with an extended partition is also allowed, provided that
  * \p geom lies completely inside the extended partition.
  */
-static int
+static int _GL_ATTRIBUTE_PURE
 _disk_check_part_overlaps (PedDisk* disk, PedPartition* part)
 {
        PedPartition*   walk;
index 910d25c..70086b6 100644 (file)
@@ -52,6 +52,7 @@
 
 #include <parted/parted.h>
 #include <parted/debug.h>
+#include <parted/exception.h>
 
 #define N_(String) String
 #if ENABLE_NLS
@@ -103,7 +104,7 @@ ped_exception_get_type_string (PedExceptionType ex_type)
 
 /* FIXME: move this out to the prospective math.c */
 /* FIXME: this can probably be done more efficiently */
-static int
+static int _GL_ATTRIBUTE_PURE
 ped_log2 (int n)
 {
        int x;
index 3756020..39e4926 100644 (file)
@@ -66,4 +66,4 @@ struct AmigaIds {
 
 struct AmigaIds * _amiga_add_id (uint32_t id, struct AmigaIds *ids);
 void _amiga_free_ids (struct AmigaIds *ids);
-int _amiga_id_in_list (uint32_t id, struct AmigaIds *ids);
+int _amiga_id_in_list (uint32_t id, struct AmigaIds *ids) _GL_ATTRIBUTE_PURE;
index 18d0f54..0dc25ce 100644 (file)
@@ -167,7 +167,7 @@ aix_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
         return 0;
 }
 
-static int
+static int _GL_ATTRIBUTE_CONST
 aix_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 {
         return 0;
@@ -195,7 +195,7 @@ aix_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
        return true;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 aix_partition_align (PedPartition* part, const PedConstraint* constraint)
 {
         PED_ASSERT (part != NULL);
@@ -203,13 +203,13 @@ aix_partition_align (PedPartition* part, const PedConstraint* constraint)
         return 1;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 aix_partition_enumerate (PedPartition* part)
 {
        return 1;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 aix_alloc_metadata (PedDisk* disk)
 {
        return 1;
index 2278a86..961c72a 100644 (file)
@@ -494,7 +494,7 @@ bsd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
        return 0;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 bsd_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 {
        BSDPartitionData*               bsd_data;
index 3d2dbd7..b69a71f 100644 (file)
@@ -403,7 +403,7 @@ chs_get_sector (const RawCHS* chs)
        return (chs->sector & 0x3f) - 1;
 }
 
-static PedSector
+static PedSector _GL_ATTRIBUTE_PURE
 chs_to_sector (const PedDevice* dev, const PedCHSGeometry *bios_geom,
               const RawCHS* chs)
 {
@@ -452,7 +452,7 @@ sector_to_chs (const PedDevice* dev, const PedCHSGeometry* bios_geom,
        chs->sector = real_s + 1 + (real_c >> 8 << 6);
 }
 
-static PedSector
+static PedSector _GL_ATTRIBUTE_PURE
 legacy_start (const PedDisk* disk, const PedCHSGeometry* bios_geom,
              const DosRawPartition* raw_part)
 {
@@ -462,7 +462,7 @@ legacy_start (const PedDisk* disk, const PedCHSGeometry* bios_geom,
        return chs_to_sector (disk->dev, bios_geom, &raw_part->chs_start);
 }
 
-static PedSector
+static PedSector _GL_ATTRIBUTE_PURE
 legacy_end (const PedDisk* disk, const PedCHSGeometry* bios_geom,
            const DosRawPartition* raw_part)
 {
@@ -472,7 +472,7 @@ legacy_end (const PedDisk* disk, const PedCHSGeometry* bios_geom,
        return chs_to_sector (disk->dev, bios_geom, &raw_part->chs_end);
 }
 
-static PedSector
+static PedSector _GL_ATTRIBUTE_PURE
 linear_start (const PedDisk* disk, const DosRawPartition* raw_part,
              PedSector offset)
 {
@@ -482,7 +482,7 @@ linear_start (const PedDisk* disk, const DosRawPartition* raw_part,
        return offset + PED_LE32_TO_CPU (raw_part->start);
 }
 
-static PedSector
+static PedSector _GL_ATTRIBUTE_PURE
 linear_end (const PedDisk* disk, const DosRawPartition* raw_part,
            PedSector offset)
 {
@@ -494,7 +494,7 @@ linear_end (const PedDisk* disk, const DosRawPartition* raw_part,
 }
 
 #ifndef DISCOVER_ONLY
-static int
+static int _GL_ATTRIBUTE_PURE
 partition_check_bios_geometry (PedPartition* part, PedCHSGeometry* bios_geom)
 {
        PedSector               leg_start, leg_end;
@@ -520,7 +520,7 @@ partition_check_bios_geometry (PedPartition* part, PedCHSGeometry* bios_geom)
        return 1;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 disk_check_bios_geometry (const PedDisk* disk, PedCHSGeometry* bios_geom)
 {
        PedPartition* part = NULL;
@@ -835,7 +835,7 @@ disk_probe_bios_geometry (const PedDisk* disk, PedCHSGeometry* bios_geom)
 }
 #endif /* !DISCOVER_ONLY */
 
-static int
+static int _GL_ATTRIBUTE_PURE
 raw_part_is_extended (const DosRawPartition* raw_part)
 {
        PED_ASSERT (raw_part != NULL);
@@ -853,7 +853,7 @@ raw_part_is_extended (const DosRawPartition* raw_part)
        return 0;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 raw_part_is_hidden (const DosRawPartition* raw_part)
 {
        PED_ASSERT (raw_part != NULL);
@@ -875,7 +875,7 @@ raw_part_is_hidden (const DosRawPartition* raw_part)
        return 0;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 raw_part_is_lba (const DosRawPartition* raw_part)
 {
        PED_ASSERT (raw_part != NULL);
@@ -1560,7 +1560,7 @@ msdos_partition_set_flag (PedPartition* part,
        }
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 {
        DosPartitionData*       dos_data;
@@ -2401,7 +2401,7 @@ next_primary (const PedDisk* disk)
        return 0;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 next_logical (const PedDisk* disk)
 {
        int     i;
index 8f4a208..dc114bf 100644 (file)
@@ -156,7 +156,7 @@ dvh_free (PedDisk* disk)
 }
 
 /* two's complement 32-bit checksum */
-static uint32_t
+static uint32_t _GL_ATTRIBUTE_PURE
 _checksum (const uint32_t* base, size_t size)
 {
        uint32_t        sum = 0;
@@ -656,7 +656,7 @@ dvh_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
        return 1;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 dvh_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 {
        DVHDiskData* dvh_disk_data = part->disk->disk_specific;
index bf1249f..c25409f 100644 (file)
@@ -108,7 +108,7 @@ static const uint32_t crc32_tab[] = {
 
 /* Return a 32-bit CRC of the contents of the buffer. */
 
-uint32_t
+uint32_t _GL_ATTRIBUTE_PURE
 __efi_crc32(const void *buf, unsigned long len, uint32_t seed)
 {
   unsigned long i;
index 454a177..9d464c6 100644 (file)
@@ -436,7 +436,7 @@ guid_cmp (efi_guid_t left, efi_guid_t right)
 }
 
 /* checks if 'mbr' is a protective MBR partition table */
-static inline int
+static inline int _GL_ATTRIBUTE_PURE
 _pmbr_is_valid (const LegacyMBR_t *mbr)
 {
   int i;
@@ -1628,7 +1628,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
   return 1;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
 {
   GPTPartitionData *gpt_part_data;
index bd756c2..2ec6b8e 100644 (file)
@@ -406,7 +406,7 @@ _rawpart_is_driver (const MacRawPartition* raw_part)
        return 1;
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 _rawpart_has_driver (const MacRawPartition* raw_part, MacDiskData* mac_disk_data)
 {
        MacDeviceDriver *driverlist;
@@ -1014,7 +1014,7 @@ _generate_empty_part (PedDisk* disk, int num, MacRawPartition* part_map)
 }
 
 /* returns the first empty entry in the partition map */
-static int
+static int _GL_ATTRIBUTE_PURE
 _get_first_empty_part_entry (PedDisk* disk, MacRawPartition* part_map)
 {
        MacDiskData*    mac_disk_data = disk->disk_specific;
@@ -1292,7 +1292,7 @@ mac_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
        }
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 mac_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 {
        MacPartitionData*       mac_data;
@@ -1369,7 +1369,7 @@ mac_partition_set_name (PedPartition* part, const char* name)
                mac_data->volume_name [i] = 0;
 }
 
-static const char*
+static const char* _GL_ATTRIBUTE_PURE
 mac_partition_get_name (const PedPartition* part)
 {
        MacPartitionData*       mac_data;
index d60843d..df0e17a 100644 (file)
@@ -193,7 +193,7 @@ pc98_free (PedDisk* disk)
        _ped_disk_free (disk);
 }
 
-static PedSector
+static PedSector _GL_ATTRIBUTE_PURE
 chs_to_sector (const PedDevice* dev, int c, int h, int s)
 {
        PED_ASSERT (dev != NULL);
@@ -217,7 +217,7 @@ sector_to_chs (const PedDevice* dev, PedSector sector, int* c, int* h, int* s)
        *s = (sector) % cyl_size % dev->hw_geom.sectors;
 }
 
-static PedSector
+static PedSector _GL_ATTRIBUTE_PURE
 legacy_start (const PedDisk* disk, const PC98RawPartition* raw_part)
 {
        PED_ASSERT (disk != NULL);
@@ -227,7 +227,7 @@ legacy_start (const PedDisk* disk, const PC98RawPartition* raw_part)
                              raw_part->head, raw_part->sector);
 }
 
-static PedSector
+static PedSector _GL_ATTRIBUTE_PURE
 legacy_end (const PedDisk* disk, const PC98RawPartition* raw_part)
 {
        PED_ASSERT (disk != NULL);
@@ -590,7 +590,7 @@ pc98_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
        }
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 pc98_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 {
        PC98PartitionData*      pc98_data;
@@ -641,7 +641,7 @@ pc98_partition_set_name (PedPartition* part, const char* name)
                pc98_data->name [i] = 0;
 }
 
-static const char*
+static const char* _GL_ATTRIBUTE_PURE
 pc98_partition_get_name (const PedPartition* part)
 {
        PC98PartitionData*      pc98_data;
index 5db3787..5ceb00e 100644 (file)
@@ -113,7 +113,7 @@ _amiga_free_ids (struct AmigaIds *ids) {
                free (current);
        }
 }
-static int
+static int _GL_ATTRIBUTE_PURE
 _amiga_id_in_list (uint32_t id, struct AmigaIds *ids) {
        struct AmigaIds *current;
 
@@ -608,14 +608,14 @@ _amiga_find_free_blocks(const PedDisk *disk, uint32_t *table,
        }
        return 1;
 }
-static uint32_t
+static uint32_t _GL_ATTRIBUTE_PURE
 _amiga_next_free_block(uint32_t *table, uint32_t start, uint32_t type) {
        int i;
 
        for (i = start; table[i] != type && table[i] != IDNAME_FREE; i++);
        return i;
 }
-static PedPartition *
+static PedPartition * _GL_ATTRIBUTE_PURE
 _amiga_next_real_partition(const PedDisk *disk, PedPartition *part) {
        PedPartition *next;
 
@@ -945,7 +945,7 @@ amiga_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
        }
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 amiga_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 {
        struct PartitionBlock *partition;
index 6148273..20e61a0 100644 (file)
@@ -650,7 +650,7 @@ sun_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
 }
 
 
-static int
+static int _GL_ATTRIBUTE_PURE
 sun_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
 {
        SunPartitionData*       sun_data;
index 8798ecb..1b1c801 100644 (file)
@@ -18,7 +18,7 @@ PedDisk* _create_disk_label (PedDevice* dev, PedDiskType* type);
  *
  * label: disk label name
  */
-int _implemented_disk_label (const char* label);
+int _implemented_disk_label (const char* label) _GL_ATTRIBUTE_PURE;
 
 /* Test specific exception handler
  *
index 232f81b..8b1b517 100644 (file)
@@ -52,6 +52,7 @@
 #include <config.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
+#include <parted/unit.h>
 
 #include <ctype.h>
 #include <stdio.h>
@@ -101,7 +102,7 @@ ped_unit_set_default (PedUnit unit)
 /**
  * \brief Get the current default unit.
  */
-PedUnit
+PedUnit _GL_ATTRIBUTE_PURE
 ped_unit_get_default ()
 {
        return default_unit;
@@ -334,7 +335,7 @@ strip_string (char* str)
 
 /* Find non-number suffix.  Eg: find_suffix("32Mb") returns a pointer to
  * "Mb". */
-static char*
+static char* _GL_ATTRIBUTE_PURE
 find_suffix (const char* str)
 {
        while (str[0] != 0 && (isdigit (str[0]) || strchr(",.-", str[0])))
@@ -353,7 +354,7 @@ remove_punct (char* str)
        }
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 is_chs (const char* str)
 {
        int punct_count = 0;
index 46ef307..1ab9920 100644 (file)
@@ -43,7 +43,7 @@
 
 #define MIN(a,b)       ( (a<b)?  a : b )
 
-int
+static int _GL_ATTRIBUTE_PURE
 wchar_strlen (const wchar_t* str)
 {
 #ifdef ENABLE_NLS
@@ -53,7 +53,7 @@ wchar_strlen (const wchar_t* str)
 #endif
 }
 
-wchar_t*
+static wchar_t * _GL_ATTRIBUTE_PURE
 wchar_strchr (const wchar_t* str, char ch)
 {
 #ifdef ENABLE_NLS
index 7fe9bf3..b90eee0 100644 (file)
@@ -60,6 +60,6 @@ extern int str_list_match_any (const StrList* list, const char* str);
 extern int str_list_match_node (const StrList* list, const char* str);
 extern StrList* str_list_match (const StrList* list, const char* str);
 
-extern int str_list_length (const StrList* list);
+extern int str_list_length (const StrList* list) _GL_ATTRIBUTE_PURE;
 
 #endif /* STRLIST_H_INCLUDED */
index 1def754..f0d663e 100644 (file)
@@ -592,7 +592,7 @@ _readline (const char* prompt, const StrList* possibilities)
         return line;
 }
 
-static PedExceptionOption
+static PedExceptionOption _GL_ATTRIBUTE_PURE
 option_get_next (PedExceptionOption options, PedExceptionOption current)
 {
         PedExceptionOption    i;
@@ -704,7 +704,7 @@ command_line_get_word_count ()
         return str_list_length (command_line);
 }
 
-static int
+static int _GL_ATTRIBUTE_PURE
 _str_is_spaces (const char* str)
 {
         while (isspace (*str))
index 14ba380..15da2ee 100644 (file)
@@ -43,7 +43,7 @@ extern void command_line_push_word (const char* word);
 extern char* command_line_pop_word ();
 extern char* command_line_peek_word ();
 extern void command_line_flush ();
-extern int command_line_get_word_count ();
+extern int command_line_get_word_count () _GL_ATTRIBUTE_PURE;
 extern void command_line_prompt_words (const char* prompt, const char* def,
                                       const StrList* possibilities,
                                       int multi_word);