Tasklist
FS#10080 - Use strlcpy for string copies and get completely rid of strncpy
| Task Type |
Patches |
| Category |
Operating System/Drivers |
| Status |
Closed |
| Assigned To |
No-one |
| Player Type |
All players |
| Severity |
Low |
| Priority |
Normal |
| Reported Version |
Daily build (which?) |
| Due in Version |
Undecided |
| Due Date |
Undecided |
| Percent Complete |
|
| Private |
No
|
|
Details
This patch removes strncpy from rockbox and introduces the strlcpy function instead. Most uses of strncpy have been changed to use strlcpy and a few to use memcpy.
the differences between strlcpy and strncpy is that strlcpy guarantees null termination of the copied string while strncpy does not and that strlcpy does not zero pad the rest of the buffer.
This means that copying short strings into large buffers should be a lot faster and that there is no need to guard for the case that the string is truncated and strncpy would not have null terminated it.
This patch touches a lot of files and while i have gone over the changes several times and tested on both gigabeast and c200 and sims there are some things i can't or didn't test so i would appreciate review and testing :)
strlcpy_v6.diff
(80.1 KiB)
apps/codecs.c | 1
apps/playlist.c | 21 ++--
apps/codecs.h | 5 -
apps/cuesheet.c | 13 +-
apps/recorder/radio.c | 5 -
apps/recorder/albumart.c | 5 -
apps/recorder/recording.c | 2
apps/recorder/pcm_record.c | 8 -
apps/tree.c | 2
apps/metadata/mp3.c | 5 -
apps/metadata/metadata_common.c | 5 -
apps/settings.c | 34 +++----
apps/plugins/mp3_encoder.c | 5 -
apps/plugins/keybox.c | 16 +--
apps/plugins/random_folder_advance_config.c | 10 +-
apps/plugins/dict.c | 3
apps/plugins/zxbox/snapshot.c | 6 -
apps/plugins/zxbox/spconf.c | 3
apps/plugins/zxbox/sptape.c | 3
apps/plugins/zxbox/tapefile.c | 6 -
apps/plugins/sudoku/sudoku.c | 8 -
apps/plugins/chessbox/chessbox_pgn.c | 2
apps/plugins/mpegplayer/mpeg_settings.c | 2
apps/plugins/splitedit.c | 4
apps/plugins/pictureflow.c | 2
apps/plugins/goban/sgf_output.c | 2
apps/plugins/shortcuts/shortcuts_common.c | 8 -
apps/plugins/doom/r_data.c | 2
apps/plugins/doom/d_deh.c | 26 ++---
apps/plugins/doom/m_menu.c | 2
apps/plugins/doom/rockmacros.h | 2
apps/plugins/doom/w_wad.c | 8 -
apps/plugins/lib/wrappers.h | 1
apps/plugins/lib/highscore.c | 2
apps/plugins/lib/configfile.c | 2
apps/plugins/rockboy/rockmacros.h | 2
apps/plugins/rockboy/menu.c | 6 -
apps/plugins/sokoban.c | 11 +-
apps/plugins/test_codec.c | 3
apps/plugins/invadrox.c | 2
apps/plugins/rockpaint.c | 2
apps/plugins/text_editor.c | 2
apps/plugins/properties.c | 30 +++---
apps/onplay.c | 14 +--
apps/gui/buttonbar.c | 9 --
apps/gui/gwps-common.c | 11 +-
apps/gui/option_select.c | 6 -
apps/gui/statusbar.c | 7 -
apps/gui/wps_parser.c | 9 --
apps/menu.c | 2
apps/menus/main_menu.c | 2
apps/metadata.c | 2
apps/mpeg.c | 6 -
apps/talk.c | 4
apps/settings_list.c | 2
apps/tagcache.c | 2
apps/playback.c | 2
apps/replaygain.c | 3
apps/plugin.c | 2
apps/plugin.h | 2
apps/bookmark.c | 7 -
apps/buffering.c | 4
apps/root_menu.c | 4
apps/iap.c | 13 +-
apps/debug_menu.c | 3
apps/misc.c | 4
apps/playlist_catalog.c | 6 -
apps/tagtree.c | 17 +--
firmware/general.c | 4
firmware/logf.c | 2
firmware/include/string.h | 3
firmware/SOURCES | 2
firmware/common/strlcpy.c | 51 +++++++++++
firmware/common/dircache.c | 28 +++---
firmware/common/strncpy.c | 125 ----------------------------
firmware/common/dir_uncached.c | 11 --
firmware/common/file.c | 3
firmware/drivers/lcd-charcell.c | 2
firmware/drivers/lcd-1bit-vert.c | 2
firmware/drivers/lcd-2bit-vert.c | 2
firmware/drivers/fat.c | 4
firmware/drivers/lcd-2bit-vi.c | 2
firmware/drivers/lcd-16bit.c | 2
83 files changed, 277 insertions(+), 398 deletions(-)
|
Closed by
Nils Wallménius (nls)
Tuesday, 14 July 2009, 16:04 GMT+2
Reason for closing: Accepted
Additional comments about closing: comitted
Loading...
Any testing is of course very welcome.