Hi Lucas, Lucas De Marchi wrote: > this happens to work for -1, but bear in mind memset "fills > the first n bytes of the memory area". Considering > sizeof(int) == 4, it will set each byte to -1, which happens > to be -1 considering all 4 bytes too. But imo this is just > being lucky. > > In my first version I had the same as you and Denis asked me > to use a for loop.
I'll use for loop instead of using memset. >> + if (cbd == NULL) { >> + CALLBACK_WITH_FAILURE(cb, NULL, data); + >> return; + } >> >> - if (cbd == NULL) { >> - CALLBACK_WITH_FAILURE(cb, NULL, data); + >> switch (sd->vendor) { + case OFONO_VENDOR_IFX: >> + if (g_at_chat_send(sd->chat, "AT+XPINCNT", + >> xpincnt_prefix, + xpincnt_cb, >> cbd, g_free) > 0) return; >> - } >> >> + break; >> + case OFONO_VENDOR_HUAWEI: >> if (g_at_chat_send(sd->chat, "AT^CPIN?", >> huawei_cpin_prefix, >> huawei_cpin_cb, cbd, g_free) > 0) return; >> >> - g_free(cbd); >> - >> - CALLBACK_WITH_FAILURE(cb, NULL, data); >> break; >> - >> default: >> - for(i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++) >> - retries[i] = -1; >> - >> - CALLBACK_WITH_SUCCESS(cb, retries, data); + >> break; } >> + >> + g_free(cbd); >> + >> + CALLBACK_WITH_FAILURE(cb, NULL, data); > > If vendor is not huawei nor ifx, why are we bothering to > allocate cbd and free it afterwards without using? > Most of the vendors provide own commands for reading the sim pin retry count. Currently, we are handling 2vendors. If the number grows, then we will end up in having allocation code for each case. If its not going to be the case, then I can move the code inside each case. > This also changes the semantics to return a failure if it's > not implemented. I'm not against since this version seems to > be clearer. > However you might want to change src/sim.c:sim_pin_retries_query_cb() > so it doesn't call ofono_error() in this case. > If its not implemented, then we should term it as error. I don't see any change needed in the current src/sim.c:sim_pin_retries_query_cb() code. Regards, jeevaka _______________________________________________ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono