From e2554c4ce2987a9c7f9dfdbce5a5dde5542c0b65 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 3 Dec 2011 14:57:26 +0100 Subject: build: mark functions with "const" or "pure" attribute, per gcc warnings 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. --- include/parted/constraint.h | 2 +- include/parted/crc32.h | 2 +- include/parted/device.h | 4 ++-- include/parted/disk.h | 37 ++++++++++++++++++++++++------------- include/parted/exception.h | 9 ++++++--- include/parted/filesys.h | 6 ++++-- include/parted/geom.h | 11 ++++++----- include/parted/natmath.h | 20 ++++++++++++-------- include/parted/parted.h | 2 +- include/parted/unit.h | 5 +++-- 10 files changed, 60 insertions(+), 38 deletions(-) (limited to 'include') diff --git a/include/parted/constraint.h b/include/parted/constraint.h index 4098835..a25689a 100644 --- a/include/parted/constraint.h +++ b/include/parted/constraint.h @@ -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); diff --git a/include/parted/crc32.h b/include/parted/crc32.h index 9d55723..0bdd879 100644 --- a/include/parted/crc32.h +++ b/include/parted/crc32.h @@ -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 */ diff --git a/include/parted/device.h b/include/parted/device.h index d76854a..5d7562a 100644 --- a/include/parted/device.h +++ b/include/parted/device.h @@ -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); diff --git a/include/parted/disk.h b/include/parted/disk.h index dd461fb..1113213 100644 --- a/include/parted/disk.h +++ b/include/parted/disk.h @@ -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); diff --git a/include/parted/exception.h b/include/parted/exception.h index bfa6eb1..b1fb3ee 100644 --- a/include/parted/exception.h +++ b/include/parted/exception.h @@ -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); diff --git a/include/parted/filesys.h b/include/parted/filesys.h index 44258f5..3e20f6a 100644 --- a/include/parted/filesys.h +++ b/include/parted/filesys.h @@ -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 ( diff --git a/include/parted/geom.h b/include/parted/geom.h index 0aea2b5..ee947ef 100644 --- a/include/parted/geom.h +++ b/include/parted/geom.h @@ -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 */ diff --git a/include/parted/natmath.h b/include/parted/natmath.h index 02c5ee8..a88ff06 100644 --- a/include/parted/natmath.h +++ b/include/parted/natmath.h @@ -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; diff --git a/include/parted/parted.h b/include/parted/parted.h index f0e8847..7826330 100644 --- a/include/parted/parted.h +++ b/include/parted/parted.h @@ -37,7 +37,7 @@ extern "C" { #include #include -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); diff --git a/include/parted/unit.h b/include/parted/unit.h index ceb53ac..d3296c3 100644 --- a/include/parted/unit.h +++ b/include/parted/unit.h @@ -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 (); -- cgit v1.2.1