aboutsummaryrefslogtreecommitdiff
path: root/misc-utils
AgeCommit message (Collapse)Author
2017-11-03Enable further warning flags, address new warningsDavid Oberhollenzer
mtd_debug: Remove a duplicate if case. MTD_CAP_NANDFLASH has only one flag set (MTD_WRITEABLE). Directly below, we had a check for MTD_WRITEABLE in the else branch which can't possible ever have triggered. Checking for MTD_WRITEABLE in addition to the CAP constants was probably not intended anyway, given the check for the individual flags if all else fails. integck: We already established that "r" is less than the number of elements in the list, so the loop condition doesn't need to check if w is NULL in addition. At least this way, the compiler "gets" that w cannot be NULL below and doesn't issue warnings. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-02Mark or fix switch cases that fall throughDavid Oberhollenzer
Now that C++17 introduced a special fallthrough keyword for explicitly tagging switch cases that are supposed to fall through, newer gcc versions also implement a feature request from 2002 to warn about maybe unwanted fall-throughs in switch cases in other languages (like C). For C code, we can either add a gcc specific attribute at the end of the switch case, or use a special comment that gcc checks for, indicating that the fall-through behaviour is indeed intended. This patch adds a "/* fall-through */" comment at the end of various case blocks to silence gcc warnings and in some cases a break, where fall-through was probably not intended. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-02Add no-return attribute to usage() style functionsDavid Oberhollenzer
A common pattern in command line processing is having a usage() function that prints out how to use the command line options and then terminates. The function is typically used inside a switch block for command line options like `-h' or unknown options. In a lot of places, the break keyword is omitted, because the function exits anyway. However, this triggers gcc warnings about implicit fall-through. Rather than adding a phony "/* fall-through */" this patch flags the usage() style function with a gcc attribute, indicating that they do not return and removes further superfluous break statements. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-10-05misc-utils: initialize "ip" in docfdisk to NULLDavid Oberhollenzer
Technically it is initializied in the for loop right before being used. From the conditional above, we know that the for loop is executed at least once and the variable is always initialized, but gcc doesn't appear to perform the same reasoning. This patch adds an initialization of the variable for the sake of making the compiler happy. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-28Eliminate warnings about missing prototypesDavid Oberhollenzer
This patch eliminates warnings generated by the -Wmissing-prototypes option. With this flag set, we are now forced to have prototypes for all global, exported functions, that have to be made visible to the definitions and we are forced to mark all local functions as static. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-28Move libfec declarations to public header in global include directoryDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-14ftl_format: Use return directly to leave main functionDaniel Wagner
We can use return with the exit code instead of the sliglty odd exit, return pattern. Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-14flashcp: Drop exit code definesDaniel Wagner
The EXIT_{FAILURE|SUCCESS} are already defined in stdlib.h. Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-14Use defines for exit code valuesDaniel Wagner
Make the usage of exit consist. That is use the pre defined exit values. Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-21mtd-utils: Support jffs2 flash-erase for large OOB (>32b)Manikandan Ramachandran
"flash_erase" fails on nand flash with JFFS2 that has OOB size greater than 32 bytes. "flash_erase" uses "MEMGETOOSEL" to determine OOB size. This ioctl call is obsolete and returns error if OOB size is more than 32 bytes. This patch fixes this issue by using "mtd_write" to update clean-marker instead of mtd_oob_write. This fix is based on the discussion: http://lists.infradead.org/pipermail/linux-mtd/2011-September/037958.html. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-20mtd-utils: serve_image: Use PRIdoff_t as format specifier.Torsten Fleischer
To be independent on the size of off_t the format specifier determined of common.h should be used instead of PRIu64. Signed-off-by: Torsten Fleischer <torfl6749@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-14mtd-utils: Correct casting for final status report in flashcpJonathan Fether
Add correct casting for filestat.st_size in flashcp.c. While the interim status updates had correct casting from commit 08b243, the final update was not. Signed-off-by: Jonathan Fether <jonf@mds.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-06common: Fix 'unchecked return code' warningsBoris Brezillon
Several tools are simply not checking return code of functions marked with 'warn_unused_result'. Provide wrappers for the read/write functions to avoid patching old code and providing proper error handling. Fix the remaining ones (calls to fgets() and system()). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-11-17Unify version string printingDavid Oberhollenzer
When a program does sophisticated enough command line processing (i.e. getopt), make sure it responds to -V and --version. When a program prints a version string, make sure it uses the common_print_version macro to print out its name, that it is part of mtd-utils and the mtd-utils version from the build system in a fashion similar to common program packages like the GNU coreutils. When a program responds to -V/--version or -h/--help, make sure it reports success exit status. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-11-17Change build system to autotoolsRichard Weinberger
This patch is largely based on Richards original RFC. The major differences to the RFC patch are: - Add missing sumtools & mtdpart targets - Fix name of mkfs.jffs2 target - Add missing subdir-objects option for non-recursive make - Move all automake options to configure.ac - Add manpages to install target - Make XATTR & LZO support configurable - Install binaries to sbin directory like in the old build system - Install flash_erase wrapper script - Add files missing from distribution target Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-08-25mtd-utils: mtd_debug: check amount of data read.Michal Suchanek
The kernel refuses to read more data from a MTD device than the device size. However, mtd_debug does not check the amount of data read as returned by read(2) and assumes the requested amount is always read when there is no error. Reading 8M data from a 4M flash chip results in 8M file containing the flash data at the start. Signed-off-by: Michal Suchanek <hramrach@gmail.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-04-18fix build warnings w/newer glibc & _BSD_SOURCEMike Frysinger
The _BSD_SOURCE define has been deprecated for a while now. Instead, code should be defining _DEFAULT_SOURCE. By defining both, it'll work with both new & old versions warning-free. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-12flashcp: Use %llu to print filestat.st_sizeFabien Proriol
filestat.st_size type is off_t. For some paltforms, off_t can be 32 or 64bit but there is no C99 format specifier for off_t. The best way to print it with printf is to cast it to long long and print with %llu Signed-off-by: Fabien Proriol <fabien.proriol@jdsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11mtd-utils: Restructure the mtd-utils source.Dongsheng Yang
* There is no code modification in this commit, only moving * the files to proper place. The user tools looks a little messy as we place almost the all tools in the root directory of mtd-utils. To make it more clear, I propose to introduce the following structure for our source code. mtd-utils/ |-- lib |-- include |-- misc-utils |-- jffsX-utils |-- nand-utils |-- nor-utils |-- ubi-utils |-- ubifs-utils `-- tests Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>