diff --git a/subsys/net/lib/wifi_credentials/wifi_credentials.c b/subsys/net/lib/wifi_credentials/wifi_credentials.c index 2f155b3f166640..a91ea8dd5428a4 100644 --- a/subsys/net/lib/wifi_credentials/wifi_credentials.c +++ b/subsys/net/lib/wifi_credentials/wifi_credentials.c @@ -108,13 +108,12 @@ int wifi_credentials_get_by_ssid_personal_struct(const char *ssid, size_t ssid_l int ret; if (ssid == NULL || ssid_len > WIFI_SSID_MAX_LEN || ssid_len == 0) { - LOG_ERR("Cannot retrieve WiFi credentials, SSID has invalid format"); + LOG_ERR("Cannot %s WiFi credentials, %s", "retrieve", "SSID has invalid format"); return -EINVAL; } if (buf == NULL) { - LOG_ERR("Cannot retrieve WiFi credentials, " - "destination struct pointer cannot be NULL"); + LOG_ERR("Cannot %s WiFi credentials, %s", "retrieve", "destination is NULL"); return -EINVAL; } @@ -122,14 +121,14 @@ int wifi_credentials_get_by_ssid_personal_struct(const char *ssid, size_t ssid_l idx = lookup_idx(ssid, ssid_len); if (idx == -1) { - LOG_DBG("Cannot retrieve WiFi credentials, no entry found for the provided SSID"); + LOG_DBG("Cannot %s WiFi credentials, %s", "retrieve", "SSID not found"); ret = -ENOENT; goto exit; } ret = wifi_credentials_load_entry(idx, buf, sizeof(struct wifi_credentials_personal)); if (ret) { - LOG_ERR("Failed to load WiFi credentials at index %d, err: %d", idx, ret); + LOG_ERR("Failed to %s WiFi credentials at index %d, err: %d", "load", idx, ret); goto exit; } @@ -155,12 +154,12 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal int ret; if (creds == NULL) { - LOG_ERR("Cannot set WiFi credentials, provided struct pointer cannot be NULL"); + LOG_ERR("Cannot %s WiFi credentials, %s", "set", "credential not set"); return -EINVAL; } if (creds->header.ssid_len > WIFI_SSID_MAX_LEN || creds->header.ssid_len == 0) { - LOG_ERR("Cannot set WiFi credentials, SSID has invalid format"); + LOG_ERR("Cannot %s WiFi credentials, %s", "set", "SSID has invalid format"); return -EINVAL; } @@ -170,7 +169,7 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal if (idx == -1) { idx = lookup_unused_idx(); if (idx == -1) { - LOG_ERR("Cannot store WiFi credentials, no space left"); + LOG_ERR("Cannot %s WiFi credentials, %s", "store", "no space left"); ret = -ENOBUFS; goto exit; } @@ -178,7 +177,7 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal ret = wifi_credentials_store_entry(idx, creds, sizeof(struct wifi_credentials_personal)); if (ret) { - LOG_ERR("Failed to store WiFi credentials at index %d, err: %d", idx, ret); + LOG_ERR("Failed to %s WiFi credentials at index %d, err: %d", "store", idx, ret); goto exit; } @@ -200,20 +199,21 @@ int wifi_credentials_set_personal(const char *ssid, size_t ssid_len, enum wifi_s struct wifi_credentials_header *header; if (ssid == NULL || ssid_len > WIFI_SSID_MAX_LEN || ssid_len == 0) { - LOG_ERR("Cannot set WiFi credentials, SSID has invalid format"); + LOG_ERR("Cannot %s WiFi credentials, %s", "set", "SSID has invalid format"); return -EINVAL; } if (flags & WIFI_CREDENTIALS_FLAG_BSSID && (bssid_len != WIFI_MAC_ADDR_LEN || bssid == NULL)) { - LOG_ERR("Cannot set WiFi credentials, " - "provided flags indicated BSSID, but no BSSID provided"); + LOG_ERR("Cannot %s WiFi credentials, %s", "set", + "provided flags indicated BSSID but no BSSID provided"); return -EINVAL; } if ((type != WIFI_SECURITY_TYPE_NONE && (password_len == 0 || password == NULL)) || (password_len > WIFI_CREDENTIALS_MAX_PASSWORD_LEN)) { - LOG_ERR("Cannot set WiFi credentials, password not provided or invalid"); + LOG_ERR("Cannot %s WiFi credentials, %s", "set", + "password not provided or invalid"); return -EINVAL; } @@ -246,9 +246,8 @@ int wifi_credentials_set_personal(const char *ssid, size_t ssid_len, enum wifi_s break; } default: - LOG_ERR("Cannot set WiFi credentials, " - "provided security type %d is unsupported", - type); + LOG_ERR("Cannot %s WiFi credentials, provided security type %d is unsupported", + "set", type); return -ENOTSUP; } @@ -269,18 +268,18 @@ int wifi_credentials_get_by_ssid_personal(const char *ssid, size_t ssid_len, struct wifi_credentials_header *header; if (ssid == NULL || ssid_len > WIFI_SSID_MAX_LEN || ssid_len == 0) { - LOG_ERR("Cannot retrieve WiFi credentials, SSID has invalid format"); + LOG_ERR("Cannot %s WiFi credentials, %s", "retrieve", "SSID has invalid format"); return -EINVAL; } if (bssid_buf_len != WIFI_MAC_ADDR_LEN || bssid_buf == NULL) { - LOG_ERR("BSSID buffer needs to be provided"); + LOG_ERR("%s buffer needs to be provided", "BSSID"); return -EINVAL; } if (password_buf == NULL || password_buf_len > WIFI_CREDENTIALS_MAX_PASSWORD_LEN || password_buf_len == 0) { - LOG_ERR("WiFi password buffer needs to be provided"); + LOG_ERR("%s buffer needs to be provided", "WiFi password"); return -EINVAL; } @@ -318,7 +317,7 @@ int wifi_credentials_get_by_ssid_personal(const char *ssid, size_t ssid_len, break; } default: - LOG_ERR("Cannot get WiFi credentials, " + LOG_ERR("Cannot %s WiFi credentials, %s", "get", "the requested credentials have invalid WIFI_SECURITY_TYPE"); ret = -EPROTO; } @@ -331,7 +330,7 @@ int wifi_credentials_delete_by_ssid(const char *ssid, size_t ssid_len) int ret = 0; if (ssid == NULL || ssid_len > WIFI_SSID_MAX_LEN || ssid_len == 0) { - LOG_ERR("Cannot delete WiFi credentials, SSID has invalid format"); + LOG_ERR("Cannot %s WiFi credentials, %s", "delete", "SSID has invalid format"); return -EINVAL; } @@ -345,7 +344,7 @@ int wifi_credentials_delete_by_ssid(const char *ssid, size_t ssid_len) ret = wifi_credentials_delete_entry(idx); if (ret) { - LOG_ERR("Failed to delete WiFi credentials index %d, err: %d", idx, ret); + LOG_ERR("Failed to %s WiFi credentials index %d, err: %d", "delete", idx, ret); goto exit; } @@ -393,8 +392,8 @@ int wifi_credentials_delete_all(void) if (is_entry_used(i)) { ret = wifi_credentials_delete_entry(i); if (ret) { - LOG_ERR("Failed to delete WiFi credentials index %d, err: %d", i, - ret); + LOG_ERR("Failed to %s WiFi credentials index %d, err: %d", + "delete", i, ret); break; }