summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-07-19 11:56:59 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-07-20 11:39:22 +0000
commit22043a68d0fe0652dd7e0b1041f6f448e867390b (patch)
tree6cad9b1e8b50b98fe6ed561f4c3670612b087b1e
parent4303ba22a8cacea808eaf8f487303d1360ac4150 (diff)
Correct warning that was raised at compilation
Correct warning that was raised at compilation concerning 3 subjects : - Too short strings for 'snprintf'. - Forget cast returns of 'json_object_array_length' function. - Checking return of 'asprintf' function. Change-Id: I0fc702750841a0f8da921c3c3b1453c5afee0fd8 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--alsa-binding/Alsa-RegEvt.c2
-rw-r--r--alsa-binding/Alsa-SetGet.c8
-rw-r--r--alsa-binding/Alsa-Ucm.c2
-rw-r--r--alsa-hook/PolicyAlsaHook.c12
4 files changed, 15 insertions, 9 deletions
diff --git a/alsa-binding/Alsa-RegEvt.c b/alsa-binding/Alsa-RegEvt.c
index c3c0b51..a4f552f 100644
--- a/alsa-binding/Alsa-RegEvt.c
+++ b/alsa-binding/Alsa-RegEvt.c
@@ -262,7 +262,7 @@ OnErrorExit:
// Subscribe to every Alsa CtlEvent send by a given board
STATIC json_object *alsaProbeCardId(afb_req request) {
- char devid [10];
+ char devid [32];
const char *ctlName, *shortname, *longname, *mixername, *drivername;
int done, mode, card, err, index, idx;
json_object *responseJ, *tmpJ;
diff --git a/alsa-binding/Alsa-SetGet.c b/alsa-binding/Alsa-SetGet.c
index a755b02..00e7bec 100644
--- a/alsa-binding/Alsa-SetGet.c
+++ b/alsa-binding/Alsa-SetGet.c
@@ -74,7 +74,7 @@ PUBLIC void NumidsListParse(ActionSetGetT action, queryValuesT *queryValues, ctl
case json_type_array:
// NUMID is an array 1st slot should be numid, optionally values may come after
- length = json_object_array_length(ctlRequest[idx].jToken);
+ length = (int) json_object_array_length(ctlRequest[idx].jToken);
// numid must be in 1st slot of numid json array
ctlRequest[idx].numId = json_object_get_int(json_object_array_get_idx(ctlRequest[idx].jToken, 0));
@@ -114,7 +114,7 @@ PUBLIC void NumidsListParse(ActionSetGetT action, queryValuesT *queryValues, ctl
}
STATIC json_object *DB2StringJsonOject(long dB) {
- char label [20];
+ char label [32];
if (dB < 0) {
snprintf(label, sizeof (label), "-%li.%02lidB", -dB / 100, -dB % 100);
} else {
@@ -524,7 +524,7 @@ PUBLIC int alsaSetSingleCtl(snd_ctl_t *ctlDev, snd_ctl_elem_id_t *elemId, ctlReq
enum json_type jtype = json_object_get_type(ctlRequest->valuesJ);
switch (jtype) {
case json_type_array:
- length = json_object_array_length(ctlRequest->valuesJ);
+ length = (int) json_object_array_length(ctlRequest->valuesJ);
valueIsArray = 1;
break;
case json_type_int:
@@ -729,7 +729,7 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req request) {
switch (jtype) {
case json_type_array:
queryValues.numidsJ = numidsJ;
- queryValues.count = json_object_array_length(numidsJ);
+ queryValues.count = (int) json_object_array_length(numidsJ);
break;
case json_type_int:
diff --git a/alsa-binding/Alsa-Ucm.c b/alsa-binding/Alsa-Ucm.c
index d608e61..0c65f2c 100644
--- a/alsa-binding/Alsa-Ucm.c
+++ b/alsa-binding/Alsa-Ucm.c
@@ -278,7 +278,7 @@ PUBLIC void alsaUseCaseGet(struct afb_req request) {
json_object *tmpJ;
case json_type_array:
- labelCount = json_object_array_length(jLabels);
+ labelCount = (int) json_object_array_length(jLabels);
break;
case json_type_string:
diff --git a/alsa-hook/PolicyAlsaHook.c b/alsa-hook/PolicyAlsaHook.c
index e93edae..62b1a2f 100644
--- a/alsa-hook/PolicyAlsaHook.c
+++ b/alsa-hook/PolicyAlsaHook.c
@@ -275,7 +275,10 @@ static int CallWithTimeout(afbClientT *afbClient, afbRequestT *afbRequest, int c
int err;
// create a unique tag for request
- (void)asprintf(&afbRequest->callIdTag, "%d:%s", count, afbRequest->apiverb);
+ if(asprintf(&afbRequest->callIdTag, "%d:%s", count, afbRequest->apiverb) < 0) {
+ printf("Couldn't allocate request call unique id tag string\n");
+ goto OnErrorExit;
+ }
// create a timer with ~250us accuracy
sd_event_now(afbClient->sdLoop, CLOCK_MONOTONIC, &usec);
@@ -673,10 +676,13 @@ int PLUGIN_ENTRY_POINT (snd_pcm_t *pcm, snd_config_t *conf) {
afbClient->pcm = pcm;
afbClient->name= strdup(snd_pcm_name(pcm));
afbClient->verbose = 0;
- (void) asprintf(&afbClient->uid, "hook:%s:%d", afbClient->name, getpid());
+ if(asprintf(&afbClient->uid, "hook:%s:%d", afbClient->name, getpid()) < 0) {
+ SNDERR("Couldn't allocate client uid string");
+ goto OnErrorExit;
+ }
// Get PCM arguments from asoundrc
- printf("HookEntry handle=0x%x pcm=%s\n", afbClient, afbClient->name);
+ printf("HookEntry handle=0x%p pcm=%s\n", afbClient, afbClient->name);
snd_config_for_each(it, next, conf) {
snd_config_t *node = snd_config_iterator_entry(it);
const char *id;