jtag/drivers: replace perror() with LOG_ERROR()

The function perror() sends the output to stderr, but OpenOCD
cannot intercept such output to send it to the log.

Replace all occurrences of perror() with LOG_ERROR(), but keeping
the same output format of perror().

The replacement is done automatically through:
	sed -i 's/perror("\([^":]*\)[: ]*")/LOG_ERROR("\1: %s", strerror(errno))/' src/jtag/drivers/*.c

Change-Id: I4c140bdb09235d56cfd8bef75da9b56fbe7c2aec
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5728
Tested-by: jenkins
This commit is contained in:
Antonio Borneo 2020-06-28 23:19:23 +02:00
parent 3a5f84f818
commit e466f389a9
5 changed files with 14 additions and 14 deletions

View File

@ -231,14 +231,14 @@ static int at91rm9200_init(void)
dev_mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
if (dev_mem_fd < 0) {
perror("open");
LOG_ERROR("open: %s", strerror(errno));
return ERROR_JTAG_INIT_FAILED;
}
sys_controller = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, dev_mem_fd, AT91C_BASE_SYS);
if (sys_controller == MAP_FAILED) {
perror("mmap");
LOG_ERROR("mmap: %s", strerror(errno));
close(dev_mem_fd);
return ERROR_JTAG_INIT_FAILED;
}

View File

@ -473,7 +473,7 @@ static int bcm2835gpio_init(void)
dev_mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
}
if (dev_mem_fd < 0) {
perror("open");
LOG_ERROR("open: %s", strerror(errno));
return ERROR_JTAG_INIT_FAILED;
}
@ -481,7 +481,7 @@ static int bcm2835gpio_init(void)
MAP_SHARED, dev_mem_fd, BCM2835_GPIO_BASE);
if (pio_base == MAP_FAILED) {
perror("mmap");
LOG_ERROR("mmap: %s", strerror(errno));
close(dev_mem_fd);
return ERROR_JTAG_INIT_FAILED;
}
@ -491,7 +491,7 @@ static int bcm2835gpio_init(void)
MAP_SHARED, dev_mem_fd, BCM2835_PADS_GPIO_0_27);
if (pads_base == MAP_FAILED) {
perror("mmap");
LOG_ERROR("mmap: %s", strerror(errno));
close(dev_mem_fd);
return ERROR_JTAG_INIT_FAILED;
}

View File

@ -127,7 +127,7 @@ static int set_gonk_mode(void)
syscon = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, dev_mem_fd, 0x80930000);
if (syscon == MAP_FAILED) {
perror("mmap");
LOG_ERROR("mmap: %s", strerror(errno));
return ERROR_JTAG_INIT_FAILED;
}
@ -151,14 +151,14 @@ static int ep93xx_init(void)
dev_mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
if (dev_mem_fd < 0) {
perror("open");
LOG_ERROR("open: %s", strerror(errno));
return ERROR_JTAG_INIT_FAILED;
}
gpio_controller = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, dev_mem_fd, 0x80840000);
if (gpio_controller == MAP_FAILED) {
perror("mmap");
LOG_ERROR("mmap: %s", strerror(errno));
close(dev_mem_fd);
return ERROR_JTAG_INIT_FAILED;
}

View File

@ -491,7 +491,7 @@ static int imx_gpio_init(void)
dev_mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
if (dev_mem_fd < 0) {
perror("open");
LOG_ERROR("open: %s", strerror(errno));
return ERROR_JTAG_INIT_FAILED;
}
@ -502,7 +502,7 @@ static int imx_gpio_init(void)
MAP_SHARED, dev_mem_fd, imx_gpio_peri_base);
if (pio_base == MAP_FAILED) {
perror("mmap");
LOG_ERROR("mmap: %s", strerror(errno));
close(dev_mem_fd);
return ERROR_JTAG_INIT_FAILED;
}

View File

@ -127,7 +127,7 @@ static int setup_sysfs_gpio(int gpio, int is_output, int init_high)
LOG_WARNING("gpio %d is already exported", gpio);
} else {
LOG_ERROR("Couldn't export gpio %d", gpio);
perror("sysfsgpio: ");
LOG_ERROR("sysfsgpio: %s", strerror(errno));
return ERROR_FAIL;
}
}
@ -147,7 +147,7 @@ static int setup_sysfs_gpio(int gpio, int is_output, int init_high)
}
if (ret < 0) {
LOG_ERROR("Couldn't set direction for gpio %d", gpio);
perror("sysfsgpio: ");
LOG_ERROR("sysfsgpio: %s", strerror(errno));
unexport_sysfs_gpio(gpio);
return ERROR_FAIL;
}
@ -164,7 +164,7 @@ static int setup_sysfs_gpio(int gpio, int is_output, int init_high)
}
if (ret < 0) {
LOG_ERROR("Couldn't open value for gpio %d", gpio);
perror("sysfsgpio: ");
LOG_ERROR("sysfsgpio: %s", strerror(errno));
unexport_sysfs_gpio(gpio);
}
@ -208,7 +208,7 @@ static void sysfsgpio_swdio_drive(bool is_output)
ret = open_write_close(buf, is_output ? "high" : "in");
if (ret < 0) {
LOG_ERROR("Couldn't set direction for gpio %d", swdio_gpio);
perror("sysfsgpio: ");
LOG_ERROR("sysfsgpio: %s", strerror(errno));
}
last_stored = false;