Review and overhaul AVRDUDE's messaging system (#1126)

* Change avrdude_message(MSG_XYZ, ...) to msg_xyz(...)
* Define and use pmsg_xyz(...) instead of msg_xyz("%s: ...", progname, ...)
* Review and change avrdude_message() levels
   - Introduce new levels warning, error and ext_error
   - Distribute info level to info, warning, error, ext_error
   - Assign levels (more) consistently
   - Unify grammar, punctuation and style of messages
* Use imsg_xyz() to print indented messages
* Show function name in errors and warnings on -v
* Reduce effective verbosity level by number of -q above one
This commit is contained in:
Stefan Rueger
2022-10-17 15:44:55 +01:00
committed by GitHub
parent 2503ae03ce
commit e172877724
54 changed files with 3024 additions and 4206 deletions

View File

@@ -63,7 +63,7 @@ static int linuxgpio_export(unsigned int gpio)
fd = open("/sys/class/gpio/export", O_WRONLY);
if (fd < 0) {
perror("Can't open /sys/class/gpio/export");
pmsg_ext_error("cannot open /sys/class/gpio/export: %s\n", strerror(errno));
return fd;
}
@@ -81,7 +81,7 @@ static int linuxgpio_unexport(unsigned int gpio)
fd = open("/sys/class/gpio/unexport", O_WRONLY);
if (fd < 0) {
perror("Can't open /sys/class/gpio/unexport");
pmsg_ext_error("cannot open /sys/class/gpio/unexport: %s\n", strerror(errno));
return fd;
}
@@ -109,8 +109,7 @@ static int linuxgpio_dir(unsigned int gpio, unsigned int dir)
fd = open(buf, O_WRONLY);
if (fd < 0) {
snprintf(buf, sizeof(buf), "Can't open gpio%u/direction", gpio);
perror(buf);
pmsg_ext_error("cannot open %s: %s\n", buf, strerror(errno));
return fd;
}
@@ -220,7 +219,7 @@ static int linuxgpio_highpulsepin(const PROGRAMMER *pgm, int pinfunc) {
static void linuxgpio_display(const PROGRAMMER *pgm, const char *p) {
avrdude_message(MSG_INFO, "%sPin assignment : /sys/class/gpio/gpio{n}\n",p);
msg_info("%sPin assignment : /sys/class/gpio/gpio{n}\n",p);
pgm_display_generic_mask(pgm, p, SHOW_AVR_PINS);
}
@@ -267,7 +266,7 @@ static int linuxgpio_open(PROGRAMMER *pgm, const char *port) {
i == PIN_AVR_MISO ) {
pin = pgm->pinno[i] & PIN_MASK;
if ((r=linuxgpio_export(pin)) < 0) {
avrdude_message(MSG_INFO, "Can't export GPIO %d, already exported/busy?: %s",
pmsg_ext_error("cannot export GPIO %d, already exported/busy?: %s",
pin, strerror(errno));
return r;
}
@@ -306,9 +305,9 @@ static int linuxgpio_open(PROGRAMMER *pgm, const char *port) {
}
if (retry_count)
avrdude_message(MSG_NOTICE2, "%s: needed %d retr%s for linuxgpio_dir_%s(%s)\n",
progname, retry_count, retry_count > 1? "ies": "y",
i == PIN_AVR_MISO? "in": "out", avr_pin_name(pin));
pmsg_notice2("needed %d retr%s for linuxgpio_dir_%s(%s)\n",
retry_count, retry_count > 1? "ies": "y",
i == PIN_AVR_MISO? "in": "out", avr_pin_name(pin));
if (r < 0) {
linuxgpio_unexport(pin);
@@ -379,8 +378,7 @@ const char linuxgpio_desc[] = "GPIO bitbanging using the Linux sysfs interface";
#else /* !HAVE_LINUXGPIO */
void linuxgpio_initpgm(PROGRAMMER *pgm) {
avrdude_message(MSG_INFO, "%s: Linux sysfs GPIO support not available in this configuration\n",
progname);
pmsg_error("Linux sysfs GPIO support not available in this configuration\n");
}
const char linuxgpio_desc[] = "GPIO bitbanging using the Linux sysfs interface (not available)";