[Settings] show_setting() functions return snprintf()-style length.

show_setting() and related functions now return an "actual length" in the
style of snprintf().  This is to allow consumers to allocate buffers large
enough to hold the formatted setting.
This commit is contained in:
Michael Brown
2008-03-18 00:48:23 +00:00
parent 08b19abf94
commit 5a08b434c7
4 changed files with 11 additions and 14 deletions

View File

@@ -28,7 +28,7 @@ static int show_exec ( int argc, char **argv ) {
dummy_context.options = ugly_nvo_hack->options;
if ( ( rc = show_named_setting ( &dummy_context, argv[1], buf,
sizeof ( buf ) ) ) != 0 ) {
sizeof ( buf ) ) ) < 0 ) {
printf ( "Could not find \"%s\": %s\n",
argv[1], strerror ( -rc ) );
return 1;

View File

@@ -118,7 +118,7 @@ static void load_setting ( struct setting_widget *widget ) {
/* Read current setting value */
if ( show_setting ( widget->context, widget->setting,
widget->value, sizeof ( widget->value ) ) != 0 ) {
widget->value, sizeof ( widget->value ) ) < 0 ) {
widget->value[0] = '\0';
}