From 105a411c749700ebe8a0b90260d210e70979cdc2 Mon Sep 17 00:00:00 2001 From: George Baltz N3GB Date: Thu, 11 Jul 2024 10:20:53 -0400 Subject: [PATCH] Use pointers for amp->state references --- amplifiers/elecraft/kpa.c | 10 +++++----- amplifiers/expert/expert.c | 10 +++++----- amplifiers/gemini/gemini.c | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/amplifiers/elecraft/kpa.c b/amplifiers/elecraft/kpa.c index 842f77c57..e1acfba88 100644 --- a/amplifiers/elecraft/kpa.c +++ b/amplifiers/elecraft/kpa.c @@ -66,10 +66,10 @@ int kpa_init(AMP *amp) return -RIG_EINVAL; } - amp->state.priv = (struct kpa_priv_data *) + AMPSTATE(amp)->priv = (struct kpa_priv_data *) calloc(1, sizeof(struct kpa_priv_data)); - if (!amp->state.priv) + if (!AMPSTATE(amp)->priv) { return -RIG_ENOMEM; } @@ -83,9 +83,9 @@ int kpa_close(AMP *amp) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (amp->state.priv) { free(amp->state.priv); } + if (AMPSTATE(amp)->priv) { free(AMPSTATE(amp)->priv); } - amp->state.priv = NULL; + AMPSTATE(amp)->priv = NULL; return RIG_OK; } @@ -271,7 +271,7 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val) int pwrinput; float float_value = 0; int int_value = 0, int_value2 = 0; - struct kpa_priv_data *priv = amp->state.priv; + struct kpa_priv_data *priv = AMPSTATE(amp)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); diff --git a/amplifiers/expert/expert.c b/amplifiers/expert/expert.c index 14419e3e1..48f88c871 100644 --- a/amplifiers/expert/expert.c +++ b/amplifiers/expert/expert.c @@ -68,10 +68,10 @@ int expert_init(AMP *amp) return -RIG_EINVAL; } - amp->state.priv = (struct expert_priv_data *) + AMPSTATE(amp)->priv = (struct expert_priv_data *) calloc(1, sizeof(struct expert_priv_data)); - if (!amp->state.priv) + if (!AMPSTATE(amp)->priv) { return -RIG_ENOMEM; } @@ -102,9 +102,9 @@ int expert_close(AMP *amp) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); expert_transaction(amp, &cmd, 1, response, 4); - if (amp->state.priv) { free(amp->state.priv); } + if (AMPSTATE(amp)->priv) { free(AMPSTATE(amp)->priv); } - amp->state.priv = NULL; + AMPSTATE(amp)->priv = NULL; return RIG_OK; } @@ -305,7 +305,7 @@ int expert_get_level(AMP *amp, setting_t level, value_t *val) int pwrinput; float float_value = 0; int int_value = 0, int_value2 = 0; - struct expert_priv_data *priv = amp->state.priv; + struct expert_priv_data *priv = AMPSTATE(amp)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); diff --git a/amplifiers/gemini/gemini.c b/amplifiers/gemini/gemini.c index ad8c3e856..41129fec1 100644 --- a/amplifiers/gemini/gemini.c +++ b/amplifiers/gemini/gemini.c @@ -45,10 +45,10 @@ int gemini_init(AMP *amp) return -RIG_EINVAL; } - amp->state.priv = (struct gemini_priv_data *) + AMPSTATE(amp)->priv = (struct gemini_priv_data *) calloc(1, sizeof(struct gemini_priv_data)); - if (!amp->state.priv) + if (!AMPSTATE(amp)->priv) { return -RIG_ENOMEM; } @@ -62,9 +62,9 @@ int gemini_close(AMP *amp) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (amp->state.priv) { free(amp->state.priv); } + if (AMPSTATE(amp)->priv) { free(AMPSTATE(amp)->priv); } - amp->state.priv = NULL; + AMPSTATE(amp)->priv = NULL; return RIG_OK; } @@ -137,7 +137,7 @@ int gemini_status_parse(AMP *amp) int retval, n = 0; char *p; char responsebuf[GEMINIBUFSZ]; - struct gemini_priv_data *priv = amp->state.priv; + struct gemini_priv_data *priv = AMPSTATE(amp)->priv; retval = gemini_transaction(amp, "S\n", responsebuf, sizeof(responsebuf)); @@ -189,7 +189,7 @@ int gemini_get_freq(AMP *amp, freq_t *freq) if (!amp) { return -RIG_EINVAL; } - priv = amp->state.priv; + priv = AMPSTATE(amp)->priv; retval = gemini_status_parse(amp); @@ -228,7 +228,7 @@ int gemini_set_freq(AMP *amp, freq_t freq) int gemini_get_level(AMP *amp, setting_t level, value_t *val) { int retval; - struct gemini_priv_data *priv = amp->state.priv; + struct gemini_priv_data *priv = AMPSTATE(amp)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);