Skip to content

Commit

Permalink
Fixed inconsistent use of short vs. unsigned short in some APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperrealm committed Nov 22, 2022
1 parent ba33788 commit 9350629
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions doc/libconfig.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,8 @@ option. They are obsoleted by the @code{config_set_option()} and

@end deftypefun

@deftypefun short config_get_default_format (@w{config_t * @var{config}})
@deftypefunx void config_set_default_format (@w{config_t * @var{config}}, @w{short @var{format}})
@deftypefun {unsigned short} config_get_default_format (@w{config_t * @var{config}})
@deftypefunx void config_set_default_format (@w{config_t * @var{config}}, @w{unsigned short @var{format}})

These functions, which are implemented as macros, get and set the
default external format for settings in the configuration
Expand Down Expand Up @@ -1134,8 +1134,8 @@ be freed by the caller.

@end deftypefun

@deftypefun short config_setting_get_format (@w{config_setting_t * @var{setting}})
@deftypefunx int config_setting_set_format (@w{config_setting_t * @var{setting}}, @w{short @var{format}})
@deftypefun {unsigned short} config_setting_get_format (@w{config_setting_t * @var{setting}})
@deftypefunx int config_setting_set_format (@w{config_setting_t * @var{setting}}, @w{unsigned short @var{format}})

These functions get and set the external format for the setting @var{setting}.

Expand Down
4 changes: 2 additions & 2 deletions lib/libconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ int config_setting_set_string(config_setting_t *setting, const char *value)

/* ------------------------------------------------------------------------- */

int config_setting_set_format(config_setting_t *setting, short format)
int config_setting_set_format(config_setting_t *setting, unsigned short format)
{
if(((setting->type != CONFIG_TYPE_INT)
&& (setting->type != CONFIG_TYPE_INT64))
Expand All @@ -1212,7 +1212,7 @@ int config_setting_set_format(config_setting_t *setting, short format)

/* ------------------------------------------------------------------------- */

short config_setting_get_format(const config_setting_t *setting)
unsigned short config_setting_get_format(const config_setting_t *setting)
{
return(setting->format != 0 ? setting->format
: setting->config->default_format);
Expand Down
14 changes: 7 additions & 7 deletions lib/libconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ typedef union config_value_t
typedef struct config_setting_t
{
char *name;
short type;
short format;
unsigned short type;
unsigned short format;
config_value_t value;
struct config_setting_t *parent;
struct config_t *config;
Expand Down Expand Up @@ -134,7 +134,7 @@ extern LIBCONFIG_API int config_read(config_t *config, FILE *stream);
extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream);

extern LIBCONFIG_API void config_set_default_format(config_t *config,
short format);
unsigned short format);

extern LIBCONFIG_API void config_set_options(config_t *config, int options);
extern LIBCONFIG_API int config_get_options(const config_t *config);
Expand Down Expand Up @@ -212,8 +212,8 @@ extern LIBCONFIG_API int config_setting_set_string(config_setting_t *setting,
const char *value);

extern LIBCONFIG_API int config_setting_set_format(config_setting_t *setting,
short format);
extern LIBCONFIG_API short config_setting_get_format(
unsigned short format);
extern LIBCONFIG_API unsigned short config_setting_get_format(
const config_setting_t *setting);

extern LIBCONFIG_API int config_setting_get_int_elem(
Expand Down Expand Up @@ -327,10 +327,10 @@ extern LIBCONFIG_API int config_lookup_string(const config_t *config,
((C)->root)

#define /* void */ config_set_default_format(/* config_t * */ C, \
/* short */ F) \
/* unsigned short */ F) \
(C)->default_format = (F)

#define /* short */ config_get_default_format(/* config_t * */ C) \
#define /* unsigned short */ config_get_default_format(/* config_t * */ C) \
((C)->default_format)

#define /* unsigned short */ config_setting_source_line( \
Expand Down

0 comments on commit 9350629

Please sign in to comment.