parted/0020-libparted-Fix-warnings-from-GCC-8-Wsuggest-attribute.patch
DistroBaker b7125dc640 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/parted.git#633c371306f0da38c70879e948b612775032740a
2020-12-01 18:08:09 +00:00

249 lines
8.3 KiB
Diff

From 20c136159b37f11822b591941c077bb2be6ede05 Mon Sep 17 00:00:00 2001
From: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
Date: Wed, 14 Aug 2019 10:59:21 +0900
Subject: [PATCH 20/42] libparted: Fix warnings from GCC 8
-Wsuggest-attribute=pure
As GCC 8 suggests, add 'pure' attribute to 17 functions. After adding
pure attributes, GCC suggested three more functions to add pure
attributes. Add pure attribute to those functions also. In total, add
pure attributes to 20 functions.
I read code of the functions and confirmed the 20 functions are pure:
they have no effect except the return value, and their return value
depend only on the parameters and/or global variables.
Signed-off-by: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/fs/fat/bootsector.c | 2 +-
libparted/fs/r/fat/bootsector.c | 2 +-
libparted/fs/r/fat/calc.c | 4 ++--
libparted/fs/r/fat/context.c | 4 ++--
libparted/fs/r/fat/count.c | 4 ++--
libparted/fs/r/fat/table.c | 2 +-
libparted/fs/r/fat/traverse.c | 14 +++++++-------
libparted/fs/r/hfs/advfs.c | 4 ++--
libparted/fs/r/hfs/advfs_plus.c | 4 ++--
9 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/libparted/fs/fat/bootsector.c b/libparted/fs/fat/bootsector.c
index 0c3ae77..2a03696 100644
--- a/libparted/fs/fat/bootsector.c
+++ b/libparted/fs/fat/bootsector.c
@@ -86,7 +86,7 @@ fat_boot_sector_read (FatBootSector** bsp, const PedGeometry *geom)
/*
Don't trust the FAT12, FAT16 or FAT32 label string.
*/
-FatType
+FatType _GL_ATTRIBUTE_PURE
fat_boot_sector_probe_type (const FatBootSector* bs, const PedGeometry* geom)
{
PedSector logical_sector_size;
diff --git a/libparted/fs/r/fat/bootsector.c b/libparted/fs/r/fat/bootsector.c
index 9130900..34134cc 100644
--- a/libparted/fs/r/fat/bootsector.c
+++ b/libparted/fs/r/fat/bootsector.c
@@ -85,7 +85,7 @@ fat_boot_sector_read (FatBootSector** bsp, const PedGeometry *geom)
/*
Don't trust the FAT12, FAT16 or FAT32 label string.
*/
-FatType
+FatType _GL_ATTRIBUTE_PURE
fat_boot_sector_probe_type (const FatBootSector* bs, const PedGeometry* geom)
{
PedSector logical_sector_size;
diff --git a/libparted/fs/r/fat/calc.c b/libparted/fs/r/fat/calc.c
index e524007..60c6bac 100644
--- a/libparted/fs/r/fat/calc.c
+++ b/libparted/fs/r/fat/calc.c
@@ -314,7 +314,7 @@ fat_calc_resize_sizes (
friends, to allow room for this space. If too much of this space is left
over, everyone will complain, so we have to be greedy, and use it all up...
*/
-PedSector
+PedSector _GL_ATTRIBUTE_PURE
fat_calc_align_sectors (const PedFileSystem* new_fs,
const PedFileSystem* old_fs)
{
@@ -359,7 +359,7 @@ fat_calc_align_sectors (const PedFileSystem* new_fs,
return align;
}
-int
+int _GL_ATTRIBUTE_PURE
fat_is_sector_in_clusters (const PedFileSystem* fs, PedSector sector)
{
FatSpecific* fs_info = FAT_SPECIFIC (fs);
diff --git a/libparted/fs/r/fat/context.c b/libparted/fs/r/fat/context.c
index 5c27d09..170094c 100644
--- a/libparted/fs/r/fat/context.c
+++ b/libparted/fs/r/fat/context.c
@@ -124,7 +124,7 @@ fat_op_context_destroy (FatOpContext* ctx)
free (ctx);
}
-FatFragment
+FatFragment _GL_ATTRIBUTE_PURE
fat_op_context_map_static_fragment (const FatOpContext* ctx, FatFragment frag)
{
FatSpecific* new_fs_info = FAT_SPECIFIC (ctx->new_fs);
@@ -160,7 +160,7 @@ fat_op_context_map_static_cluster (const FatOpContext* ctx, FatCluster clst)
return 0;
}
-FatFragment
+FatFragment _GL_ATTRIBUTE_PURE
fat_op_context_map_fragment (const FatOpContext* ctx, FatFragment frag)
{
return ctx->remap [frag];
diff --git a/libparted/fs/r/fat/count.c b/libparted/fs/r/fat/count.c
index 250e80d..2b65e72 100644
--- a/libparted/fs/r/fat/count.c
+++ b/libparted/fs/r/fat/count.c
@@ -338,7 +338,7 @@ fat_collect_cluster_info (PedFileSystem* fs) {
return 1;
}
-FatClusterFlag
+FatClusterFlag _GL_ATTRIBUTE_PURE
fat_get_cluster_flag (PedFileSystem* fs, FatCluster cluster)
{
FatSpecific* fs_info = FAT_SPECIFIC (fs);
@@ -346,7 +346,7 @@ fat_get_cluster_flag (PedFileSystem* fs, FatCluster cluster)
return fs_info->cluster_info [cluster].flag;
}
-PedSector
+PedSector _GL_ATTRIBUTE_PURE
fat_get_cluster_usage (PedFileSystem* fs, FatCluster cluster)
{
FatSpecific* fs_info = FAT_SPECIFIC (fs);
diff --git a/libparted/fs/r/fat/table.c b/libparted/fs/r/fat/table.c
index fe8e040..98b0499 100644
--- a/libparted/fs/r/fat/table.c
+++ b/libparted/fs/r/fat/table.c
@@ -371,7 +371,7 @@ fat_table_is_bad (const FatTable* ft, FatCluster cluster)
/*
returns true if <cluster> represents an EOF marker
*/
-int
+int _GL_ATTRIBUTE_PURE
fat_table_is_eof (const FatTable* ft, FatCluster cluster)
{
return _test_code_eof (ft, cluster);
diff --git a/libparted/fs/r/fat/traverse.c b/libparted/fs/r/fat/traverse.c
index fc8a795..50b94bd 100644
--- a/libparted/fs/r/fat/traverse.c
+++ b/libparted/fs/r/fat/traverse.c
@@ -31,7 +31,7 @@
static char tmp_buffer [4096];
-int
+int _GL_ATTRIBUTE_PURE
fat_traverse_entries_per_buffer (FatTraverseInfo* trav_info)
{
return trav_info->buffer_size / sizeof (FatDirEntry);
@@ -226,7 +226,7 @@ fat_traverse_next_dir_entry (FatTraverseInfo *trav_info)
return trav_info->dir_entries + trav_info->current_entry;
}
-FatCluster
+FatCluster _GL_ATTRIBUTE_PURE
fat_dir_entry_get_first_cluster (FatDirEntry* dir_entry, PedFileSystem *fs)
{
FatSpecific* fs_info = FAT_SPECIFIC (fs);
@@ -269,7 +269,7 @@ fat_dir_entry_set_first_cluster (FatDirEntry* dir_entry, PedFileSystem* fs,
}
}
-uint32_t
+uint32_t _GL_ATTRIBUTE_PURE
fat_dir_entry_get_length (FatDirEntry* dir_entry)
{
return PED_LE32_TO_CPU (dir_entry->length);
@@ -284,7 +284,7 @@ fat_dir_entry_is_null_term (const FatDirEntry* dir_entry)
return memcmp (&null_entry, dir_entry, sizeof (null_entry)) == 0;
}
-int
+int _GL_ATTRIBUTE_PURE
fat_dir_entry_is_active (FatDirEntry* dir_entry)
{
if ((unsigned char) dir_entry->name[0] == DELETED_FLAG) return 0;
@@ -293,7 +293,7 @@ fat_dir_entry_is_active (FatDirEntry* dir_entry)
return 1;
}
-int
+int _GL_ATTRIBUTE_PURE
fat_dir_entry_is_file (FatDirEntry* dir_entry) {
if (dir_entry->attributes == VFAT_ATTR) return 0;
if (dir_entry->attributes & VOLUME_LABEL_ATTR) return 0;
@@ -302,7 +302,7 @@ fat_dir_entry_is_file (FatDirEntry* dir_entry) {
return 1;
}
-int
+int _GL_ATTRIBUTE_PURE
fat_dir_entry_is_system_file (FatDirEntry* dir_entry)
{
if (!fat_dir_entry_is_file (dir_entry)) return 0;
@@ -310,7 +310,7 @@ fat_dir_entry_is_system_file (FatDirEntry* dir_entry)
|| (dir_entry->attributes & HIDDEN_ATTR);
}
-int
+int _GL_ATTRIBUTE_PURE
fat_dir_entry_is_directory (FatDirEntry* dir_entry)
{
if (dir_entry->attributes == VFAT_ATTR) return 0;
diff --git a/libparted/fs/r/hfs/advfs.c b/libparted/fs/r/hfs/advfs.c
index d0afa30..0a39960 100644
--- a/libparted/fs/r/hfs/advfs.c
+++ b/libparted/fs/r/hfs/advfs.c
@@ -239,7 +239,7 @@ errbb: hfs_free_bad_blocks_list(priv_data->bad_blocks_xtent_list);
}
/* This function check if fblock is a bad block */
-int
+int _GL_ATTRIBUTE_PURE
hfs_is_bad_block (const PedFileSystem *fs, unsigned int fblock)
{
HfsPrivateFSData* priv_data = (HfsPrivateFSData*)
@@ -304,7 +304,7 @@ hfs_get_empty_end (const PedFileSystem *fs)
/* return the block which should be used to pack data to have at
least free fblock blocks at the end of the volume */
-unsigned int
+unsigned int _GL_ATTRIBUTE_PURE
hfs_find_start_pack (const PedFileSystem *fs, unsigned int fblock)
{
HfsPrivateFSData* priv_data = (HfsPrivateFSData*)
diff --git a/libparted/fs/r/hfs/advfs_plus.c b/libparted/fs/r/hfs/advfs_plus.c
index 5453c25..2b6fd87 100644
--- a/libparted/fs/r/hfs/advfs_plus.c
+++ b/libparted/fs/r/hfs/advfs_plus.c
@@ -247,7 +247,7 @@ errbbp: hfsplus_free_bad_blocks_list(priv_data->bad_blocks_xtent_list);
}
/* This function check if fblock is a bad block */
-int
+int _GL_ATTRIBUTE_PURE
hfsplus_is_bad_block (const PedFileSystem *fs, unsigned int fblock)
{
HfsPPrivateFSData* priv_data = (HfsPPrivateFSData*)
@@ -358,7 +358,7 @@ hfsplus_get_min_size (const PedFileSystem *fs)
/* return the block which should be used to pack data to have
at least free fblock blocks at the end of the volume */
-unsigned int
+unsigned int _GL_ATTRIBUTE_PURE
hfsplus_find_start_pack (const PedFileSystem *fs, unsigned int fblock)
{
HfsPPrivateFSData* priv_data = (HfsPPrivateFSData*)
--
2.26.2