From c8bf1f26dada2b3c88b1efcd6d0becb41ddff316 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Sun, 11 Apr 2021 22:00:12 -0400 Subject: [PATCH] Examples: C Interactive: Initialize product description to empty string This is a guard in case the icsneo_describeDevice call were to fail for some reason, and is just good practice regardless. --- examples/c/interactive/src/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/c/interactive/src/main.c b/examples/c/interactive/src/main.c index c8b7859..f3dad6a 100644 --- a/examples/c/interactive/src/main.c +++ b/examples/c/interactive/src/main.c @@ -31,7 +31,7 @@ void printAllDevices() { printf("No devices found! Please scan for new devices.\n"); } for(int i = 0; i < numDevices; i++) { - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION]; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; // Updates productDescription and descriptionLength for each device @@ -271,7 +271,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION]; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -332,7 +332,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION]; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -380,7 +380,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION]; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -439,7 +439,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION]; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -504,7 +504,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION]; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -559,7 +559,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION]; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -585,7 +585,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION]; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength);