AVR C Runtime Library - Bugs: bug #28058, parameter checking in...
You are not allowed to post comments on this tracker with your current authentication level.
bug #28058: parameter checking in pgm_read_xxx()
Submitter: | Jan Waclawek <wek> | ||
Submitted: | Fri 20 Nov 2009 10:32:06 AM UTC | ||
Category: | Feature Request | Severity: | 3 - Normal |
Priority: | 9 - Immediate | Item Group: | Header files |
Status: | In Progress | Percent Complete: | 30% |
Assigned to: | None | Open/Closed: | Open |
Release: | Any | Fixed Release: | None |
Wed 23 Feb 2011 06:20:57 PM UTC, comment #3: |
Eric Weddington <arcanum>![]() |
Sat 22 May 2010 01:01:21 PM UTC, comment #2: Although not completely to the topic, as it again is related to <avr/pgmspace> , I would propose also the following addition:
and rename the existing strlen_P() function to __strlen_P(s) (including the appropriate change in library function).
This allows the compiler to avoid call of the library function when length of string is known at compile time.
The same change could be made to the far counterpart (strlen_PF()), in the unlikely event that Carlos Lamas' library gets included into the official avr-libc.
This item has been discussed on avrfreaks.net.
Jan Waclawek |
Jan Waclawek <wek> |
Wed 28 Apr 2010 03:20:50 PM UTC, comment #1: I would also propose adding the following function to <avr/pgmspace.h>, to allow for proper reading of PROGMEM char-s
[Please note that in my initial submission, the markup feature eat up the double-underscores around _attribute_ and _always_inline_ to single underscores...]
Jan Waclawek |
Jan Waclawek <wek> |
Fri 20 Nov 2009 10:32:06 AM UTC, original submission:
The pgm_read_xxx() functions in <avr/pgmspace.h> are currently implemented as macros, casting the parameter to (uint16_t).
While the parameter is supposed to be a pointer, this enables to use any garbage (read: non-pointer expression used by error) quietly.
Opposed to this are the similar accessing functions in eeprom.h.
It is therefore suggested, that these macros to be replaced by the following constructions:
// #define pgm_read_byte(address_short) pgm_read_byte_near(address_short)
// #define pgm_read_word(address_short) pgm_read_word_near(address_short)
// #define pgm_read_dword(address_short) pgm_read_dword_near(address_short)
I am not expert enough to judge whether the functions may be tagged also with the _pure_ attribute.
A discussion on the topic is on http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=85490 .
Jan Waclawek |
Jan Waclawek <wek> |
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
Renamed strlen_P to __strlen_P, added new inline function strlen_P to avr/pgmspace.h header file, as per comment #2. Committed. Comments #0, #1 still need to be addressed.