[parted-devel] [PATCH 07/24] libparted: Fix warnings from GCC 8 -Wsuggest-attribute=const
Brian C. Lane
bcl at redhat.com
Sat Nov 14 00:11:50 GMT 2020
From: Shin'ichiro Kawasaki <kawasaki at juno.dti.ne.jp>
As GCC 8 suggests, add 'const' attribute to six functions. After adding
const attributes, GCC suggested two more functions to add const
attributes. Add const attributes to those functions also. In total, add
const attributes to 8 functions.
I read code of the functions and confirmed they are const: they examine
only their arguments and have no effect other than return value.
Signed-off-by: Shin'ichiro Kawasaki <kawasaki at juno.dti.ne.jp>
Signed-off-by: Brian C. Lane <bcl at redhat.com>
---
libparted/fs/r/fat/calc.c | 14 +++++++-------
libparted/fs/r/fat/table.c | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/libparted/fs/r/fat/calc.c b/libparted/fs/r/fat/calc.c
index 177564d..1c8331c 100644
--- a/libparted/fs/r/fat/calc.c
+++ b/libparted/fs/r/fat/calc.c
@@ -23,7 +23,7 @@
#ifndef DISCOVER_ONLY
/* returns the minimum size of clusters for a given file system type */
-PedSector
+PedSector _GL_ATTRIBUTE_CONST
fat_min_cluster_size (FatType fat_type) {
switch (fat_type) {
case FAT_TYPE_FAT12: return 1;
@@ -33,7 +33,7 @@ fat_min_cluster_size (FatType fat_type) {
return 0;
}
-static PedSector
+static PedSector _GL_ATTRIBUTE_CONST
_smallest_power2_over (PedSector ceiling)
{
PedSector result = 1;
@@ -45,7 +45,7 @@ _smallest_power2_over (PedSector ceiling)
}
/* returns the minimum size of clusters for a given file system type */
-PedSector
+PedSector _GL_ATTRIBUTE_CONST
fat_recommend_min_cluster_size (FatType fat_type, PedSector size) {
switch (fat_type) {
case FAT_TYPE_FAT12: return 1;
@@ -59,7 +59,7 @@ fat_recommend_min_cluster_size (FatType fat_type, PedSector size) {
}
/* returns the maxmimum size of clusters for a given file system type */
-PedSector
+PedSector _GL_ATTRIBUTE_CONST
fat_max_cluster_size (FatType fat_type) {
switch (fat_type) {
case FAT_TYPE_FAT12: return 1; /* dunno... who cares? */
@@ -70,7 +70,7 @@ fat_max_cluster_size (FatType fat_type) {
}
/* returns the minimum number of clusters for a given file system type */
-FatCluster
+FatCluster _GL_ATTRIBUTE_CONST
fat_min_cluster_count (FatType fat_type) {
switch (fat_type) {
case FAT_TYPE_FAT12:
@@ -83,7 +83,7 @@ fat_min_cluster_count (FatType fat_type) {
}
/* returns the maximum number of clusters for a given file system type */
-FatCluster
+FatCluster _GL_ATTRIBUTE_CONST
fat_max_cluster_count (FatType fat_type) {
switch (fat_type) {
case FAT_TYPE_FAT12: return 0xff0;
@@ -94,7 +94,7 @@ fat_max_cluster_count (FatType fat_type) {
}
/* what is this supposed to be? What drugs are M$ on? (Can I have some? :-) */
-PedSector
+PedSector _GL_ATTRIBUTE_CONST
fat_min_reserved_sector_count (FatType fat_type)
{
return (fat_type == FAT_TYPE_FAT32) ? 32 : 1;
diff --git a/libparted/fs/r/fat/table.c b/libparted/fs/r/fat/table.c
index b743404..5700c96 100644
--- a/libparted/fs/r/fat/table.c
+++ b/libparted/fs/r/fat/table.c
@@ -467,7 +467,7 @@ fat_table_set_avail (FatTable* ft, FatCluster cluster)
#endif /* !DISCOVER_ONLY */
-int
+int _GL_ATTRIBUTE_CONST
fat_table_entry_size (FatType fat_type)
{
switch (fat_type) {
--
2.26.2
More information about the parted-devel
mailing list