GCC 8 fails to compile libparted/unit.c with an error: CC unit.lo unit.c:155:1: error: function might be candidate for attribute 'const' [-Werror=suggest-attribute=const] ped_unit_get_name (PedUnit unit) ^~~~~~~~~~~~~~~~~ CC disk.lo cc1: all warnings being treated as errors
Const attribute is required for the function ped_unit_get_name() because its return value is not affected by program status. To avoid the build failure, change attribute of the function from pure to const. Signed-off-by: Shin'ichiro Kawasaki <[email protected]> --- include/parted/unit.in.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/parted/unit.in.h b/include/parted/unit.in.h index 315660d..ad8d901 100644 --- a/include/parted/unit.in.h +++ b/include/parted/unit.in.h @@ -66,7 +66,7 @@ typedef enum { extern long long ped_unit_get_size (const PedDevice* dev, PedUnit unit); 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); -- 2.22.0
