@@ -678,6 +678,8 @@ config_set_opt(ConfigOption options[], void *var, OptionSource source)
678
678
/*
679
679
* Return value of the function in the string representation. Result is
680
680
* allocated string.
681
+ * We can set GET_VAL_IN_DEFAULT_UNITS flag in opt->flags
682
+ * before call option_get_value() to get option value in default units
681
683
*/
682
684
char *
683
685
option_get_value (ConfigOption * opt )
@@ -692,20 +694,33 @@ option_get_value(ConfigOption *opt)
692
694
*/
693
695
if (opt -> flags & OPTION_UNIT )
694
696
{
695
- if (opt -> type == 'i' )
696
- convert_from_base_unit (* ((int32 * ) opt -> var ),
697
- opt -> flags & OPTION_UNIT , & value , & unit );
698
- else if (opt -> type == 'I' )
699
- convert_from_base_unit (* ((int64 * ) opt -> var ),
700
- opt -> flags & OPTION_UNIT , & value , & unit );
701
- else if (opt -> type == 'u' )
702
- convert_from_base_unit_u (* ((uint32 * ) opt -> var ),
703
- opt -> flags & OPTION_UNIT , & value_u , & unit );
704
- else if (opt -> type == 'U' )
705
- convert_from_base_unit_u (* ((uint64 * ) opt -> var ),
706
- opt -> flags & OPTION_UNIT , & value_u , & unit );
697
+ if (opt -> flags & GET_VAL_IN_DEFAULT_UNITS ){
698
+ if (opt -> type == 'i' )
699
+ value = * ((int32 * ) opt -> var );
700
+ else if (opt -> type == 'I' )
701
+ value = * ((int64 * ) opt -> var );
702
+ else if (opt -> type == 'u' )
703
+ value_u = * ((uint32 * ) opt -> var );
704
+ else if (opt -> type == 'U' )
705
+ value_u = * ((uint64 * ) opt -> var );
706
+ unit = "" ;
707
+ }
708
+ else
709
+ {
710
+ if (opt -> type == 'i' )
711
+ convert_from_base_unit (* ((int32 * ) opt -> var ),
712
+ opt -> flags & OPTION_UNIT , & value , & unit );
713
+ else if (opt -> type == 'I' )
714
+ convert_from_base_unit (* ((int64 * ) opt -> var ),
715
+ opt -> flags & OPTION_UNIT , & value , & unit );
716
+ else if (opt -> type == 'u' )
717
+ convert_from_base_unit_u (* ((uint32 * ) opt -> var ),
718
+ opt -> flags & OPTION_UNIT , & value_u , & unit );
719
+ else if (opt -> type == 'U' )
720
+ convert_from_base_unit_u (* ((uint64 * ) opt -> var ),
721
+ opt -> flags & OPTION_UNIT , & value_u , & unit );
722
+ }
707
723
}
708
-
709
724
/* Get string representation itself */
710
725
switch (opt -> type )
711
726
{
0 commit comments