diff options
| author | David M. Syzdek <david@syzdek.net> | 2023-01-08 09:36:15 -0900 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2023-01-08 09:36:15 -0900 |
| commit | f5af35d4a6a37acd86f9c31b6bbd0baefe7b8d1c (patch) | |
| tree | 84cb533b6946a65ebe131fbe16b9612370973e00 | |
| parent | b7b2af42abb222b6262fe361fcee4c12a7bda876 (diff) | |
| download | otputils-f5af35d4a6a37acd86f9c31b6bbd0baefe7b8d1c.tar.gz otputils-f5af35d4a6a37acd86f9c31b6bbd0baefe7b8d1c.tar.bz2 otputils-f5af35d4a6a37acd86f9c31b6bbd0baefe7b8d1c.tar.xz otputils-f5af35d4a6a37acd86f9c31b6bbd0baefe7b8d1c.zip | |
libotputil: refactoring OTPUTIL_OPT_DESC handling in otputil_set_param()
| -rw-r--r-- | lib/libotputil/libotputil.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libotputil/libotputil.c b/lib/libotputil/libotputil.c index 40e3d0a..0cabd54 100644 --- a/lib/libotputil/libotputil.c +++ b/lib/libotputil/libotputil.c | |||
| @@ -493,6 +493,7 @@ otputil_set_param( | |||
| 493 | const char * str; | 493 | const char * str; |
| 494 | int i; | 494 | int i; |
| 495 | uint64_t uint; | 495 | uint64_t uint; |
| 496 | void * ptr; | ||
| 496 | 497 | ||
| 497 | defaults = ((tud)) ? &otputil_defaults : &otputil_const_defaults; | 498 | defaults = ((tud)) ? &otputil_defaults : &otputil_const_defaults; |
| 498 | tud = ((tud)) ? tud : &otputil_defaults; | 499 | tud = ((tud)) ? tud : &otputil_defaults; |
| @@ -504,13 +505,13 @@ otputil_set_param( | |||
| 504 | ///////////////////// | 505 | ///////////////////// |
| 505 | 506 | ||
| 506 | case OTPUTIL_OPT_DESC: | 507 | case OTPUTIL_OPT_DESC: |
| 508 | ptr = NULL; | ||
| 509 | if ((invalue = ((invalue)) ? invalue : defaults->otp_desc) != NULL) | ||
| 510 | if ((ptr = bindle_strdup(((const char *)invalue))) == NULL) | ||
| 511 | return(OTPUTIL_ENOMEM); | ||
| 507 | if ((tud->otp_desc)) | 512 | if ((tud->otp_desc)) |
| 508 | free(tud->otp_desc); | 513 | free(tud->otp_desc); |
| 509 | tud->otp_desc = NULL; | 514 | tud->otp_desc = ptr; |
| 510 | if ((invalue = ((invalue)) ? invalue : defaults->otp_desc) == NULL) | ||
| 511 | return(OTPUTIL_SUCCESS); | ||
| 512 | if ((tud->otp_desc = bindle_strdup(((const char *)invalue))) == NULL) | ||
| 513 | return(OTPUTIL_ENOMEM); | ||
| 514 | return(OTPUTIL_SUCCESS); | 515 | return(OTPUTIL_SUCCESS); |
| 515 | 516 | ||
| 516 | case OTPUTIL_OPT_DIGITS: | 517 | case OTPUTIL_OPT_DIGITS: |
