Skip to content

Commit

Permalink
iiod: Use snprintf instead of iio_snprintf
Browse files Browse the repository at this point in the history
iio_snprintf is a libiio internal function, which we don't really need
in IIOD anyway.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Apr 22, 2021
1 parent 5f57e44 commit ed60003
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion iiod/dns-sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static void start_avahi_thd(struct thread_pool *pool, void *d)
if (ret || !strcmp(host, "none"))
goto again;

iio_snprintf(label, sizeof(label), "%s%s", IIOD_ON, host);
snprintf(label, sizeof(label), "%s%s", IIOD_ON, host);

if (!avahi.name)
avahi.name = avahi_strdup(label);
Expand Down
1 change: 0 additions & 1 deletion iiod/iiod.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ static const char *options_descriptions[] = {
"Specify the number of USB pipes (ep couples) to use",
};


static void usage(void)
{
unsigned int i;
Expand Down
8 changes: 4 additions & 4 deletions iiod/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static void print_value(struct parser_pdata *pdata, long value)
output(pdata, "\n");
} else {
char buf[128];
iio_snprintf(buf, sizeof(buf), "%li\n", value);
snprintf(buf, sizeof(buf), "%li\n", value);
output(pdata, buf);
}
}
Expand Down Expand Up @@ -424,7 +424,7 @@ static ssize_t send_data(struct DevEntry *dev, struct ThdEntry *thd, size_t len)
/* Send the current mask */
for (i = dev->nb_words; i > 0 && ptr < buf + sizeof(buf);
i--, ptr += 8) {
iio_snprintf(ptr, length, "%08x", mask[i - 1]);
snprintf(ptr, length, "%08x", mask[i - 1]);
length -= 8;
}

Expand Down Expand Up @@ -830,7 +830,7 @@ static uint32_t *get_mask(const char *mask, size_t *len)
ptr = words + nb;
while (*mask) {
char buf[9];
iio_snprintf(buf, sizeof(buf), "%.*s", 8, mask);
snprintf(buf, sizeof(buf), "%.*s", 8, mask);
sscanf(buf, "%08x", --ptr);
mask += 8;
IIO_DEBUG("Mask[%lu]: 0x%08x\n",
Expand Down Expand Up @@ -1255,7 +1255,7 @@ ssize_t get_trigger(struct parser_pdata *pdata, struct iio_device *dev)
ret = strlen(trigger->name);
print_value(pdata, ret);

iio_snprintf(buf, sizeof(buf), "%s\n", trigger->name);
snprintf(buf, sizeof(buf), "%s\n", trigger->name);
ret = write_all(pdata, buf, ret + 1);
} else {
print_value(pdata, ret);
Expand Down
6 changes: 3 additions & 3 deletions iiod/usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ static int usb_open_pipe(struct usbd_pdata *pdata, unsigned int pipe_id)
* before opening the endpoints again. */
thread_pool_stop_and_wait(pdata->pool[pipe_id]);

iio_snprintf(buf, sizeof(buf), "%s/ep%u", pdata->ffs, pipe_id * 2 + 1);
snprintf(buf, sizeof(buf), "%s/ep%u", pdata->ffs, pipe_id * 2 + 1);
cpdata->ep_out = open(buf, O_WRONLY);
if (cpdata->ep_out < 0) {
err = -errno;
goto err_free_cpdata;
}

iio_snprintf(buf, sizeof(buf), "%s/ep%u", pdata->ffs, pipe_id * 2 + 2);
snprintf(buf, sizeof(buf), "%s/ep%u", pdata->ffs, pipe_id * 2 + 2);
cpdata->ep_in = open(buf, O_RDONLY);
if (cpdata->ep_in < 0) {
err = -errno;
Expand Down Expand Up @@ -357,7 +357,7 @@ int start_usb_daemon(struct iio_context *ctx, const char *ffs,
goto err_free_pdata_pool;
}

iio_snprintf(buf, sizeof(buf), "%s/ep0", ffs);
snprintf(buf, sizeof(buf), "%s/ep0", ffs);

pdata->ep0_fd = open(buf, O_RDWR);
if (pdata->ep0_fd < 0) {
Expand Down

0 comments on commit ed60003

Please sign in to comment.