Message ID | 20210526190405.1269962-1-alex.hung@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | [V2] lib: fwts_acpi_tables: constify read-only function arguments | expand |
On 5/27/21 3:04 AM, Alex Hung wrote: > Signed-off-by: Colin Ian King <colin.king@canonical.com> > Signed-off-by: Alex Hung <alex.hung@canonical.com> > --- > src/lib/include/fwts_acpi_tables.h | 36 ++++++++++++++++--------- > src/lib/src/fwts_acpi_tables.c | 42 +++++++++++++++--------------- > 2 files changed, 45 insertions(+), 33 deletions(-) > > diff --git a/src/lib/include/fwts_acpi_tables.h b/src/lib/include/fwts_acpi_tables.h > index 8ed65841..11670ae0 100644 > --- a/src/lib/include/fwts_acpi_tables.h > +++ b/src/lib/include/fwts_acpi_tables.h > @@ -63,23 +63,35 @@ static int name ## _init (fwts_framework *fw) \ > int fwts_acpi_load_tables(fwts_framework *fw); > int fwts_acpi_free_tables(void); > > -int fwts_acpi_find_table(fwts_framework *fw, const char *name, const uint32_t which, fwts_acpi_table_info **info); > -int fwts_acpi_find_table_by_addr(fwts_framework *fw, const uint64_t addr, fwts_acpi_table_info **info); > +int fwts_acpi_find_table(fwts_framework *fw, const char *name, const uint32_t which, > + fwts_acpi_table_info **info); > +int fwts_acpi_find_table_by_addr(fwts_framework *fw, const uint64_t addr, > + fwts_acpi_table_info **info); > int fwts_acpi_get_table(fwts_framework *fw, const uint32_t index, fwts_acpi_table_info **info); > bool fwts_acpi_obj_find(fwts_framework *fw, const char *obj_name); > > fwts_bool fwts_acpi_is_reduced_hardware(fwts_framework *fw); > > -void fwts_acpi_reserved_zero_(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, bool *passed); > -void fwts_acpi_reserved_zero_array(fwts_framework *fw, const char *table, const char *field, uint8_t* data, uint8_t length, bool *passed); > -void fwts_acpi_reserved_bits_(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, uint8_t min, uint8_t max, bool *passed); > -void fwts_acpi_reserved_type(fwts_framework *fw, const char *table, uint8_t value, uint8_t min, uint8_t reserved, bool *passed); > -bool fwts_acpi_table_length(fwts_framework *fw, const char *table, uint32_t length, uint32_t size); > -bool fwts_acpi_structure_length(fwts_framework *fw, const char *table, uint8_t type, uint32_t actual_length, uint32_t struct_length); > -bool fwts_acpi_structure_length_zero(fwts_framework *fw, const char *table, uint16_t length, uint32_t offset); > -bool fwts_acpi_structure_range(fwts_framework *fw, const char *table, uint32_t table_length, uint32_t offset); > -void fwts_acpi_fixed_value(fwts_framework *fw, fwts_log_level level, const char *table, const char *field, uint8_t actual, uint8_t must_be, bool *passed); > -void fwts_acpi_space_id(fwts_framework *fw, const char *table, const char *field, bool *passed, uint8_t actual, uint8_t num_type, ...); > +void fwts_acpi_reserved_zero_(fwts_framework *fw, const char *table, const char *field, > + const uint64_t value, const uint8_t size, bool *passed); > +void fwts_acpi_reserved_zero_array(fwts_framework *fw, const char *table, const char *field, > + const uint8_t* data, const uint8_t length, bool *passed); > +void fwts_acpi_reserved_bits_(fwts_framework *fw, const char *table, const char *field, > + const uint64_t value, const uint8_t size, const uint8_t min, const uint8_t max, bool *passed); > +void fwts_acpi_reserved_type(fwts_framework *fw, const char *table, const uint8_t value, > + const uint8_t min, const uint8_t reserved, bool *passed); > +bool fwts_acpi_table_length(fwts_framework *fw, const char *table, const uint32_t length, > + const uint32_t size); > +bool fwts_acpi_structure_length(fwts_framework *fw, const char *table, const uint8_t type, > + const uint32_t actual_length, const uint32_t struct_length); > +bool fwts_acpi_structure_length_zero(fwts_framework *fw, const char *table, > + const uint16_t length, const uint32_t offset); > +bool fwts_acpi_structure_range(fwts_framework *fw, const char *table, const uint32_t table_length, > + const uint32_t offset); > +void fwts_acpi_fixed_value(fwts_framework *fw, const fwts_log_level level, const char *table, > + const char *field, const uint8_t actual, const uint8_t must_be, bool *passed); > +void fwts_acpi_space_id(fwts_framework *fw, const char *table, const char *field, bool *passed, > + const uint8_t actual, const uint8_t num_type, ...); > > uint32_t fwts_get_acpi_version(fwts_framework *fw); > > diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c > index e69dc04e..58732201 100644 > --- a/src/lib/src/fwts_acpi_tables.c > +++ b/src/lib/src/fwts_acpi_tables.c > @@ -1432,8 +1432,8 @@ void fwts_acpi_reserved_zero_( > fwts_framework *fw, > const char *table, > const char *field, > - uint64_t value, > - uint8_t size, > + const uint64_t value, > + const uint8_t size, > bool *passed) > { > if (value != 0) { > @@ -1476,8 +1476,8 @@ void fwts_acpi_reserved_zero_array( > fwts_framework *fw, > const char *table, > const char *field, > - uint8_t* data, > - uint8_t length, > + const uint8_t* data, > + const uint8_t length, > bool *passed) > { > uint32_t value = 0; > @@ -1507,11 +1507,11 @@ void fwts_acpi_reserved_zero_array( > */ > void fwts_acpi_fixed_value( > fwts_framework *fw, > - fwts_log_level level, > + const fwts_log_level level, > const char *table, > const char *field, > - uint8_t actual, > - uint8_t must_be, > + const uint8_t actual, > + const uint8_t must_be, > bool *passed) > { > char label[20]; > @@ -1535,10 +1535,10 @@ void fwts_acpi_reserved_bits_( > fwts_framework *fw, > const char *table, > const char *field, > - uint64_t value, > - uint8_t size, > - uint8_t min, > - uint8_t max, > + const uint64_t value, > + const uint8_t size, > + const uint8_t min, > + const uint8_t max, > bool *passed) > { > uint64_t mask = 0; > @@ -1586,9 +1586,9 @@ void fwts_acpi_reserved_bits_( > void fwts_acpi_reserved_type( > fwts_framework *fw, > const char *table, > - uint8_t value, > - uint8_t min, > - uint8_t reserved, > + const uint8_t value, > + const uint8_t min, > + const uint8_t reserved, > bool *passed) > { > if (value < min || value >= reserved) { > @@ -1648,8 +1648,8 @@ void fwts_acpi_space_id( > const char *table, > const char *field, > bool *passed, > - uint8_t actual, > - uint8_t num_type, > + const uint8_t actual, > + const uint8_t num_type, > ...) > { > bool matched = false; > @@ -1705,8 +1705,8 @@ void fwts_acpi_space_id( > bool fwts_acpi_table_length( > fwts_framework *fw, > const char *table, > - uint32_t length, > - uint32_t size) > + const uint32_t length, > + const uint32_t size) > { > if (length < size) { > char label[30]; > @@ -1729,9 +1729,9 @@ bool fwts_acpi_table_length( > bool fwts_acpi_structure_length( > fwts_framework *fw, > const char *table, > - uint8_t type, > - uint32_t actual_length, > - uint32_t struct_length) > + const uint8_t type, > + const uint32_t actual_length, > + const uint32_t struct_length) > { > if (actual_length != struct_length) { > char label[30]; > Acked-by: Ivan Hu <ivan.hu@canonical.com>
On 26/05/2021 20:04, Alex Hung wrote: > Signed-off-by: Colin Ian King <colin.king@canonical.com> > Signed-off-by: Alex Hung <alex.hung@canonical.com> > --- > src/lib/include/fwts_acpi_tables.h | 36 ++++++++++++++++--------- > src/lib/src/fwts_acpi_tables.c | 42 +++++++++++++++--------------- > 2 files changed, 45 insertions(+), 33 deletions(-) > > diff --git a/src/lib/include/fwts_acpi_tables.h b/src/lib/include/fwts_acpi_tables.h > index 8ed65841..11670ae0 100644 > --- a/src/lib/include/fwts_acpi_tables.h > +++ b/src/lib/include/fwts_acpi_tables.h > @@ -63,23 +63,35 @@ static int name ## _init (fwts_framework *fw) \ > int fwts_acpi_load_tables(fwts_framework *fw); > int fwts_acpi_free_tables(void); > > -int fwts_acpi_find_table(fwts_framework *fw, const char *name, const uint32_t which, fwts_acpi_table_info **info); > -int fwts_acpi_find_table_by_addr(fwts_framework *fw, const uint64_t addr, fwts_acpi_table_info **info); > +int fwts_acpi_find_table(fwts_framework *fw, const char *name, const uint32_t which, > + fwts_acpi_table_info **info); > +int fwts_acpi_find_table_by_addr(fwts_framework *fw, const uint64_t addr, > + fwts_acpi_table_info **info); > int fwts_acpi_get_table(fwts_framework *fw, const uint32_t index, fwts_acpi_table_info **info); > bool fwts_acpi_obj_find(fwts_framework *fw, const char *obj_name); > > fwts_bool fwts_acpi_is_reduced_hardware(fwts_framework *fw); > > -void fwts_acpi_reserved_zero_(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, bool *passed); > -void fwts_acpi_reserved_zero_array(fwts_framework *fw, const char *table, const char *field, uint8_t* data, uint8_t length, bool *passed); > -void fwts_acpi_reserved_bits_(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, uint8_t min, uint8_t max, bool *passed); > -void fwts_acpi_reserved_type(fwts_framework *fw, const char *table, uint8_t value, uint8_t min, uint8_t reserved, bool *passed); > -bool fwts_acpi_table_length(fwts_framework *fw, const char *table, uint32_t length, uint32_t size); > -bool fwts_acpi_structure_length(fwts_framework *fw, const char *table, uint8_t type, uint32_t actual_length, uint32_t struct_length); > -bool fwts_acpi_structure_length_zero(fwts_framework *fw, const char *table, uint16_t length, uint32_t offset); > -bool fwts_acpi_structure_range(fwts_framework *fw, const char *table, uint32_t table_length, uint32_t offset); > -void fwts_acpi_fixed_value(fwts_framework *fw, fwts_log_level level, const char *table, const char *field, uint8_t actual, uint8_t must_be, bool *passed); > -void fwts_acpi_space_id(fwts_framework *fw, const char *table, const char *field, bool *passed, uint8_t actual, uint8_t num_type, ...); > +void fwts_acpi_reserved_zero_(fwts_framework *fw, const char *table, const char *field, > + const uint64_t value, const uint8_t size, bool *passed); > +void fwts_acpi_reserved_zero_array(fwts_framework *fw, const char *table, const char *field, > + const uint8_t* data, const uint8_t length, bool *passed); > +void fwts_acpi_reserved_bits_(fwts_framework *fw, const char *table, const char *field, > + const uint64_t value, const uint8_t size, const uint8_t min, const uint8_t max, bool *passed); > +void fwts_acpi_reserved_type(fwts_framework *fw, const char *table, const uint8_t value, > + const uint8_t min, const uint8_t reserved, bool *passed); > +bool fwts_acpi_table_length(fwts_framework *fw, const char *table, const uint32_t length, > + const uint32_t size); > +bool fwts_acpi_structure_length(fwts_framework *fw, const char *table, const uint8_t type, > + const uint32_t actual_length, const uint32_t struct_length); > +bool fwts_acpi_structure_length_zero(fwts_framework *fw, const char *table, > + const uint16_t length, const uint32_t offset); > +bool fwts_acpi_structure_range(fwts_framework *fw, const char *table, const uint32_t table_length, > + const uint32_t offset); > +void fwts_acpi_fixed_value(fwts_framework *fw, const fwts_log_level level, const char *table, > + const char *field, const uint8_t actual, const uint8_t must_be, bool *passed); > +void fwts_acpi_space_id(fwts_framework *fw, const char *table, const char *field, bool *passed, > + const uint8_t actual, const uint8_t num_type, ...); > > uint32_t fwts_get_acpi_version(fwts_framework *fw); > > diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c > index e69dc04e..58732201 100644 > --- a/src/lib/src/fwts_acpi_tables.c > +++ b/src/lib/src/fwts_acpi_tables.c > @@ -1432,8 +1432,8 @@ void fwts_acpi_reserved_zero_( > fwts_framework *fw, > const char *table, > const char *field, > - uint64_t value, > - uint8_t size, > + const uint64_t value, > + const uint8_t size, > bool *passed) > { > if (value != 0) { > @@ -1476,8 +1476,8 @@ void fwts_acpi_reserved_zero_array( > fwts_framework *fw, > const char *table, > const char *field, > - uint8_t* data, > - uint8_t length, > + const uint8_t* data, > + const uint8_t length, > bool *passed) > { > uint32_t value = 0; > @@ -1507,11 +1507,11 @@ void fwts_acpi_reserved_zero_array( > */ > void fwts_acpi_fixed_value( > fwts_framework *fw, > - fwts_log_level level, > + const fwts_log_level level, > const char *table, > const char *field, > - uint8_t actual, > - uint8_t must_be, > + const uint8_t actual, > + const uint8_t must_be, > bool *passed) > { > char label[20]; > @@ -1535,10 +1535,10 @@ void fwts_acpi_reserved_bits_( > fwts_framework *fw, > const char *table, > const char *field, > - uint64_t value, > - uint8_t size, > - uint8_t min, > - uint8_t max, > + const uint64_t value, > + const uint8_t size, > + const uint8_t min, > + const uint8_t max, > bool *passed) > { > uint64_t mask = 0; > @@ -1586,9 +1586,9 @@ void fwts_acpi_reserved_bits_( > void fwts_acpi_reserved_type( > fwts_framework *fw, > const char *table, > - uint8_t value, > - uint8_t min, > - uint8_t reserved, > + const uint8_t value, > + const uint8_t min, > + const uint8_t reserved, > bool *passed) > { > if (value < min || value >= reserved) { > @@ -1648,8 +1648,8 @@ void fwts_acpi_space_id( > const char *table, > const char *field, > bool *passed, > - uint8_t actual, > - uint8_t num_type, > + const uint8_t actual, > + const uint8_t num_type, > ...) > { > bool matched = false; > @@ -1705,8 +1705,8 @@ void fwts_acpi_space_id( > bool fwts_acpi_table_length( > fwts_framework *fw, > const char *table, > - uint32_t length, > - uint32_t size) > + const uint32_t length, > + const uint32_t size) > { > if (length < size) { > char label[30]; > @@ -1729,9 +1729,9 @@ bool fwts_acpi_table_length( > bool fwts_acpi_structure_length( > fwts_framework *fw, > const char *table, > - uint8_t type, > - uint32_t actual_length, > - uint32_t struct_length) > + const uint8_t type, > + const uint32_t actual_length, > + const uint32_t struct_length) > { > if (actual_length != struct_length) { > char label[30]; > Acked-by: Colin Ian King <colin.king@canonical.com>
diff --git a/src/lib/include/fwts_acpi_tables.h b/src/lib/include/fwts_acpi_tables.h index 8ed65841..11670ae0 100644 --- a/src/lib/include/fwts_acpi_tables.h +++ b/src/lib/include/fwts_acpi_tables.h @@ -63,23 +63,35 @@ static int name ## _init (fwts_framework *fw) \ int fwts_acpi_load_tables(fwts_framework *fw); int fwts_acpi_free_tables(void); -int fwts_acpi_find_table(fwts_framework *fw, const char *name, const uint32_t which, fwts_acpi_table_info **info); -int fwts_acpi_find_table_by_addr(fwts_framework *fw, const uint64_t addr, fwts_acpi_table_info **info); +int fwts_acpi_find_table(fwts_framework *fw, const char *name, const uint32_t which, + fwts_acpi_table_info **info); +int fwts_acpi_find_table_by_addr(fwts_framework *fw, const uint64_t addr, + fwts_acpi_table_info **info); int fwts_acpi_get_table(fwts_framework *fw, const uint32_t index, fwts_acpi_table_info **info); bool fwts_acpi_obj_find(fwts_framework *fw, const char *obj_name); fwts_bool fwts_acpi_is_reduced_hardware(fwts_framework *fw); -void fwts_acpi_reserved_zero_(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, bool *passed); -void fwts_acpi_reserved_zero_array(fwts_framework *fw, const char *table, const char *field, uint8_t* data, uint8_t length, bool *passed); -void fwts_acpi_reserved_bits_(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, uint8_t min, uint8_t max, bool *passed); -void fwts_acpi_reserved_type(fwts_framework *fw, const char *table, uint8_t value, uint8_t min, uint8_t reserved, bool *passed); -bool fwts_acpi_table_length(fwts_framework *fw, const char *table, uint32_t length, uint32_t size); -bool fwts_acpi_structure_length(fwts_framework *fw, const char *table, uint8_t type, uint32_t actual_length, uint32_t struct_length); -bool fwts_acpi_structure_length_zero(fwts_framework *fw, const char *table, uint16_t length, uint32_t offset); -bool fwts_acpi_structure_range(fwts_framework *fw, const char *table, uint32_t table_length, uint32_t offset); -void fwts_acpi_fixed_value(fwts_framework *fw, fwts_log_level level, const char *table, const char *field, uint8_t actual, uint8_t must_be, bool *passed); -void fwts_acpi_space_id(fwts_framework *fw, const char *table, const char *field, bool *passed, uint8_t actual, uint8_t num_type, ...); +void fwts_acpi_reserved_zero_(fwts_framework *fw, const char *table, const char *field, + const uint64_t value, const uint8_t size, bool *passed); +void fwts_acpi_reserved_zero_array(fwts_framework *fw, const char *table, const char *field, + const uint8_t* data, const uint8_t length, bool *passed); +void fwts_acpi_reserved_bits_(fwts_framework *fw, const char *table, const char *field, + const uint64_t value, const uint8_t size, const uint8_t min, const uint8_t max, bool *passed); +void fwts_acpi_reserved_type(fwts_framework *fw, const char *table, const uint8_t value, + const uint8_t min, const uint8_t reserved, bool *passed); +bool fwts_acpi_table_length(fwts_framework *fw, const char *table, const uint32_t length, + const uint32_t size); +bool fwts_acpi_structure_length(fwts_framework *fw, const char *table, const uint8_t type, + const uint32_t actual_length, const uint32_t struct_length); +bool fwts_acpi_structure_length_zero(fwts_framework *fw, const char *table, + const uint16_t length, const uint32_t offset); +bool fwts_acpi_structure_range(fwts_framework *fw, const char *table, const uint32_t table_length, + const uint32_t offset); +void fwts_acpi_fixed_value(fwts_framework *fw, const fwts_log_level level, const char *table, + const char *field, const uint8_t actual, const uint8_t must_be, bool *passed); +void fwts_acpi_space_id(fwts_framework *fw, const char *table, const char *field, bool *passed, + const uint8_t actual, const uint8_t num_type, ...); uint32_t fwts_get_acpi_version(fwts_framework *fw); diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c index e69dc04e..58732201 100644 --- a/src/lib/src/fwts_acpi_tables.c +++ b/src/lib/src/fwts_acpi_tables.c @@ -1432,8 +1432,8 @@ void fwts_acpi_reserved_zero_( fwts_framework *fw, const char *table, const char *field, - uint64_t value, - uint8_t size, + const uint64_t value, + const uint8_t size, bool *passed) { if (value != 0) { @@ -1476,8 +1476,8 @@ void fwts_acpi_reserved_zero_array( fwts_framework *fw, const char *table, const char *field, - uint8_t* data, - uint8_t length, + const uint8_t* data, + const uint8_t length, bool *passed) { uint32_t value = 0; @@ -1507,11 +1507,11 @@ void fwts_acpi_reserved_zero_array( */ void fwts_acpi_fixed_value( fwts_framework *fw, - fwts_log_level level, + const fwts_log_level level, const char *table, const char *field, - uint8_t actual, - uint8_t must_be, + const uint8_t actual, + const uint8_t must_be, bool *passed) { char label[20]; @@ -1535,10 +1535,10 @@ void fwts_acpi_reserved_bits_( fwts_framework *fw, const char *table, const char *field, - uint64_t value, - uint8_t size, - uint8_t min, - uint8_t max, + const uint64_t value, + const uint8_t size, + const uint8_t min, + const uint8_t max, bool *passed) { uint64_t mask = 0; @@ -1586,9 +1586,9 @@ void fwts_acpi_reserved_bits_( void fwts_acpi_reserved_type( fwts_framework *fw, const char *table, - uint8_t value, - uint8_t min, - uint8_t reserved, + const uint8_t value, + const uint8_t min, + const uint8_t reserved, bool *passed) { if (value < min || value >= reserved) { @@ -1648,8 +1648,8 @@ void fwts_acpi_space_id( const char *table, const char *field, bool *passed, - uint8_t actual, - uint8_t num_type, + const uint8_t actual, + const uint8_t num_type, ...) { bool matched = false; @@ -1705,8 +1705,8 @@ void fwts_acpi_space_id( bool fwts_acpi_table_length( fwts_framework *fw, const char *table, - uint32_t length, - uint32_t size) + const uint32_t length, + const uint32_t size) { if (length < size) { char label[30]; @@ -1729,9 +1729,9 @@ bool fwts_acpi_table_length( bool fwts_acpi_structure_length( fwts_framework *fw, const char *table, - uint8_t type, - uint32_t actual_length, - uint32_t struct_length) + const uint8_t type, + const uint32_t actual_length, + const uint32_t struct_length) { if (actual_length != struct_length) { char label[30];