Skip to content

Commit

Permalink
Add %s NULL check to logging statements (Azure#2594)
Browse files Browse the repository at this point in the history
* Add null ptr to "NULL" string

* avoid double maco expansion

* added comments
  // advoid MU_P_OR_NULL double call

* handle NULL CompareProperties
  • Loading branch information
ericwolz authored Mar 13, 2024
1 parent f8e111b commit dd31b51
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 44 deletions.
2 changes: 1 addition & 1 deletion iothub_client/src/iothub_client_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ IOTHUB_CLIENT_RESULT IoTHubClientCore_UploadToBlobAsync(IOTHUB_CLIENT_CORE_HANDL
{
LogError("invalid parameters IOTHUB_CLIENT_CORE_HANDLE iotHubClientHandle = %p , const char* destinationFileName = %s, const unsigned char* source= %p, size_t size = %lu, IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK iotHubClientFileUploadCallback = %p, void* context = %p",
iotHubClientHandle,
destinationFileName,
MU_P_OR_NULL(destinationFileName),
source,
(unsigned long)size,
iotHubClientFileUploadCallback,
Expand Down
6 changes: 3 additions & 3 deletions iothub_client/src/iothub_client_core_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ static bool IoTHubClientCore_LL_MessageCallbackFromInput(IOTHUB_MESSAGE_HANDLE m

if (item_handle == NULL)
{
LogError("Could not find callback (explicit or default) for input queue %s", inputName);
LogError("Could not find callback (explicit or default) for input queue %s", MU_P_OR_NULL(inputName));
result = false;
}
else
Expand Down Expand Up @@ -2714,7 +2714,7 @@ IOTHUB_CLIENT_RESULT IoTHubClientCore_LL_UploadToBlob(IOTHUB_CLIENT_CORE_LL_HAND
)
{
LogError("invalid parameters iotHubClientHandle=%p, const char* destinationFileName=%s, const unsigned char* source=%p, size_t size=%lu",
iotHubClientHandle, destinationFileName, source, (unsigned long)size);
iotHubClientHandle, MU_P_OR_NULL(destinationFileName), source, (unsigned long)size);
result = IOTHUB_CLIENT_INVALID_ARG;
}
else
Expand Down Expand Up @@ -3165,7 +3165,7 @@ static IOTHUB_CLIENT_RESULT remove_event_unsubscribe_if_needed(IOTHUB_CLIENT_COR
LIST_ITEM_HANDLE item_handle = singlylinkedlist_find(handleData->event_callbacks, is_event_equal_for_match, (const void*)inputName);
if (item_handle == NULL)
{
LogError("Input name %s was not present", inputName);
LogError("Input name %s was not present", MU_P_OR_NULL(inputName));
result = IOTHUB_CLIENT_ERROR;
}
else
Expand Down
Loading

0 comments on commit dd31b51

Please sign in to comment.