Skip to content

Commit

Permalink
simpleusb-tune-menu.c: Update explode_string()
Browse files Browse the repository at this point in the history
  • Loading branch information
mkmer committed Jan 30, 2025
1 parent e957e50 commit e111d09
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions utils/simpleusb-tune-menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* Most of these commands take optional parameters to set values.
*
*/

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Expand All @@ -62,6 +62,7 @@
#include <signal.h>
#include <errno.h>
#include <sys/wait.h>
#include <asterisk/utils.h>

/*! \brief type of signal detection used for carrier (cos) or ctcss */
static const char * const signal_type[] = {"no", "usb", "usbinvert", "pp", "ppinvert"};
Expand Down Expand Up @@ -109,9 +110,9 @@ static void ourhandler(int sig)
*
* \retval Returns number of substrings found.
*/
static int explode_string(char *str, char *strp[], int limit, char delim, char quote)
static int explode_string(char *str, char *strp[], size_t limit, char delim, char quote)
{
int i, l, inquo;
int i, inquo;

inquo = 0;
i = 0;
Expand All @@ -121,7 +122,7 @@ static int explode_string(char *str, char *strp[], int limit, char delim, char q
strp[0] = 0;
return (0);
}
for (l = 0; *str && (l < limit); str++) {
for (; *str && (i < (limit - 1)); str++) {
if (quote) {
if (*str == quote) {
if (inquo) {
Expand All @@ -136,7 +137,6 @@ static int explode_string(char *str, char *strp[], int limit, char delim, char q
}
if ((*str == delim) && (!inquo)) {
*str = 0;
l++;
strp[i++] = str + 1;
}
}
Expand Down Expand Up @@ -416,7 +416,7 @@ static int astgetresp(char *cmd)
if (astgetline(COMMAND_PREFIX "tune menu-support 1", buf, sizeof(buf) - 1)) {
exit(255);
}
n = explode_string(buf, strs, 100, ',', 0);
n = explode_string(buf, strs, ARRAY_LEN(strs), ',', 0);
if (n < 1) {
fprintf(stderr, "Error parsing USB device information\n");
return;
Expand Down Expand Up @@ -474,7 +474,7 @@ static int astgetresp(char *cmd)
if (astgetline(COMMAND_PREFIX "tune menu-support 3", buf, sizeof(buf) - 1)) {
exit(255);
}
n = explode_string(buf, strs, 100, ',', 0);
n = explode_string(buf, strs, ARRAY_LEN(strs), ',', 0);
if ((n < 1) || (!*strs[0])) {
fprintf(stderr, "No additional USB devices found\n");
return;
Expand Down

0 comments on commit e111d09

Please sign in to comment.