#include "config.h"
#endif
+#include <helper/system.h>
#include <libusb.h>
#include <helper/log.h>
+#include <helper/replacements.h>
#include "cmsis_dap.h"
* - config asked explicitly for an interface number
* - the device has only one interface
* The later two cases should be honored only if we know
- * we are on the rigt device */
+ * we are on the right device */
bool intf_identified_reliably = cmsis_dap_in_interface_str
|| (device_identified_reliably &&
(cmsis_dap_usb_interface != -1
LOG_WARNING("could not claim interface: %s", libusb_strerror(err));
dap->bdata = malloc(sizeof(struct cmsis_dap_backend_data));
- if (dap->bdata == NULL) {
+ if (!dap->bdata) {
LOG_ERROR("unable to allocate memory");
libusb_release_interface(dev_handle, interface_num);
libusb_close(dev_handle);
dap->bdata->interface = interface_num;
dap->packet_buffer = malloc(dap->packet_buffer_size);
- if (dap->packet_buffer == NULL) {
+ if (!dap->packet_buffer) {
LOG_ERROR("unable to allocate memory");
cmsis_dap_usb_close(dap);
return ERROR_FAIL;
static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
{
uint8_t *buf = malloc(pkt_sz);
- if (buf == NULL) {
+ if (!buf) {
LOG_ERROR("unable to allocate CMSIS-DAP packet buffer");
return ERROR_FAIL;
}
COMMAND_HANDLER(cmsis_dap_handle_usb_interface_command)
{
if (CMD_ARGC == 1)
- cmsis_dap_usb_interface = strtoul(CMD_ARGV[0], NULL, 10);
+ COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], cmsis_dap_usb_interface);
else
LOG_ERROR("expected exactly one argument to cmsis_dap_usb_interface <interface_number>");