From bfd9606d23a703bc77371e5fce70e56eea9ce3b4 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Feb 2024 16:43:26 +0100 Subject: [PATCH 1/4] More stringent #include API checks --- src/libavrdude-avrintel.h | 3 +++ src/libavrdude.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/libavrdude-avrintel.h b/src/libavrdude-avrintel.h index 9e7197b0f..830f19605 100644 --- a/src/libavrdude-avrintel.h +++ b/src/libavrdude-avrintel.h @@ -1,6 +1,9 @@ /* * Do not edit: automatically generated by mkavrintel.pl * + * Do NOT directly "#include " into your code. + * DO "#include " instead. + * * libavrdude-avrintel.h * * Microchip AVR8L, AVR8, XMEGA and AVR8X family description of interrupts, configurations and more diff --git a/src/libavrdude.h b/src/libavrdude.h index 648fceba3..36187d2ed 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -25,6 +25,11 @@ #include #include #include + +#ifdef LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS +#error LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS is defined. Do not do that. +#endif + #define LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS #include "libavrdude-avrintel.h" #undef LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS From efafa0ced050841e447d70c3340be916aeda76cf Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Feb 2024 17:14:25 +0100 Subject: [PATCH 2/4] Install libavrdude internal header libavrdude-avrintel.h --- src/CMakeLists.txt | 2 +- src/Makefile.am | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c02d4d541..9c1b9149f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -278,7 +278,7 @@ add_library(libavrdude set_target_properties(libavrdude PROPERTIES PREFIX "" - PUBLIC_HEADER "libavrdude.h" + PUBLIC_HEADER "libavrdude.h;libavrdude-avrintel.h" VERSION 1.0.0 SOVERSION 1 ) diff --git a/src/Makefile.am b/src/Makefile.am index 8863291a9..eaf70732a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -222,6 +222,7 @@ libavrdude_la_SOURCES = $(libavrdude_a_SOURCES) libavrdude_la_LDFLAGS = -version-info 1:0 include_HEADERS = libavrdude.h +include_HEADERS += libavrdude-avrintel.h avrdude_SOURCES = \ main.c \ From df7c495fb7471c48144055d737748da0931c8848 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Feb 2024 16:44:53 +0100 Subject: [PATCH 3/4] Use proper C99 parameterless function declaration --- src/libavrdude.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libavrdude.h b/src/libavrdude.h index 36187d2ed..413be677f 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1108,11 +1108,11 @@ int avr_read(const PROGRAMMER * pgm, const AVRPART *p, const char *memstr, const int avr_write_page(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr); -unsigned long avr_ustimestamp(); +unsigned long avr_ustimestamp(void); -unsigned long avr_mstimestamp(); +unsigned long avr_mstimestamp(void); -double avr_timestamp(); +double avr_timestamp(void); int avr_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char data); @@ -1481,7 +1481,7 @@ const char *str_plural(int x); const char *str_inname(const char *fn); const char *str_outname(const char *fn); const char *str_interval(int a, int b); -bool is_bigendian(); +bool is_bigendian(void); void change_endian(void *p, int size); int memall(const void *p, char c, size_t n); unsigned long long int str_ull(const char *str, char **endptr, int base); @@ -1511,7 +1511,7 @@ int terminal_mode(const PROGRAMMER *pgm, const AVRPART *p); int terminal_mode_noninteractive(const PROGRAMMER *pgm, const AVRPART *p); int terminal_line(const PROGRAMMER *pgm, const AVRPART *p, const char *line); char *terminal_get_input(const char *prompt); -void terminal_setup_update_progress(); +void terminal_setup_update_progress(void); #ifdef __cplusplus } From ec698b4e1aa70bcb9bddb0618a668051f93e6314 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 14 Feb 2024 16:46:02 +0100 Subject: [PATCH 4/4] Include headers defining the used types As libavrdude-avrintel.h uses not only uint32_t and related types from stdint.h, but also size_t from stddef.h, we also need to #include the latter into libavrdude.h before libavrdude.h includes libavrdude-avrintel.h --- src/libavrdude.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libavrdude.h b/src/libavrdude.h index 413be677f..1675b7668 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #ifdef LIBAVRDUDE_INCLUDE_INTERNAL_HEADERS