23 Commits

Author SHA1 Message Date
Ian Campbell
585cb1d499 Fix two warnings about implicit fallthrough.
In the first case:

    pio.c: In function ‘main’:
    pio.c:355:4: warning: this statement may fall through [-Wimplicit-fallthrough=]
        usage(0);
        ^~~~~~~~
    pio.c:356:3: note: here
       case 'm':
       ^~~~

The fallthrough is not intended because `usage()` never returns (it calls
`exit` unconditionally). Annotate as `noreturn` so the compiler realises this.

In the second case:

    fexc.c: In function ‘main’:
    fexc.c:312:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
       filename[1] = argv[optind+1]; /* out */
       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
    fexc.c:313:2: note: here
      case 1:
      ^~~~

The fallthrough appears to be intended (the two argument case is a superset of
the one argument case). Annotate with a comment which tells the compiler this
is intended.

Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
2018-07-09 09:16:25 +01:00
Andre Przywara
1082b1683f pio: add missing return statement
main() should return 0 if execution was successful.

Signed-off-by: Andre Przywara <osp@andrep.de>
2018-07-09 09:16:24 +01:00
Andre Przywara
7e8be239f8 pio: fix typo in help message
Signed-off-by: Andre Przywara <osp@andrep.de>
2018-07-09 09:16:24 +01:00
Bernhard Nortmann
b496582b3d Have a workaround for missing mmap() in fexc.c and pio.c
By defining NO_MMAP it's now possible to avoid the usage of
mmap() and munmap(). This benefits platforms that don't support
these functions, e.g. Windows.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-26 21:37:29 +02:00
Bernhard Nortmann
569f189693 Have programs display version information in their usage help
This way we don't have to introduce new options for retrieving
version info. For those programs that do not output their usage
by default (e.g. because they would process stdin), you may pass
a "-?" option to get help - and thus version information.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-24 14:53:02 +02:00
Bernhard Nortmann
c3d04a4b35 Get rid of two "unused parameter" warnings
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-04 10:31:34 +02:00
Bernhard Nortmann
73c20eea7b Makefile: Have portable_endian.h properly expose all functions
For Linux, this requires additional #defines, see
https://gist.github.com/panzi/6856583#gistcomment-1656524

Placing those #defines into portable_endian.h would mean we
depend on the specific order of #includes (whatever pulls
in endian.h first, including other system includes). Avoid
this by using symbols provided "globally" via the Makefile.

Also nuke the _NETBSD_SOURCE definition in fel.c

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-03 08:02:09 +02:00
Bernhard Nortmann
d47c3a3649 Replace endian_compat.h with portable_endian.h
Our previous include file only supplied a very limited set of
wrapper redefinitions for platforms that define __APPLE__ (i.e.
Mac OS). In particular, some needed big endian conversions were
missing, causing "symbol(s) not found" errors when linking.

Instead of patching the existing file, let's do away with it
completely and replace it by something more sophisticated.
The portable_endian.h used is in the public domain, and was
taken from https://gist.github.com/panzi/6856583

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-04-20 09:45:26 +02:00
Bernhard Nortmann
568c7a0e81 fix compiler warnings due to deprecated _BSD_SOURCE
With glibc 2.20 (and newer), defining _BSD_SOURCE (only)
will now generate compiler warnings similar to:

/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE
and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]

See the glibc 2.20 release notes, https://lwn.net/Articles/611162/.

This patch adds the required _DEFAULT_SOURCE.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
2015-09-13 23:56:46 +03:00
Michal Suchanek
a03129b185 Fix bogus usage message in pio tool.
Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Signed-off-by: Henrik Nordstrom <henrik@henriknordstrom.net>
2014-01-29 18:39:20 +01:00
Angus Gratton
9e79a0d995 pio.c: Fix broken file I/O 2013-04-12 12:38:31 +10:00
Henrik Nordstrom
4168151063 pio: Add mmap support 2013-01-21 19:53:26 +01:00
Alejandro Mery
1f5056275a pio: add missing copyright note
and remove unused macro
2012-09-29 12:49:47 +02:00
Henrik Nordstrom
3316205f63 pio: Fix Pxx= and Pxx? commands 2012-09-04 22:32:54 +02:00
Henrik Nordstrom
8a2c09f575 pio: Add = and ? pin commands for easier GPIO operation 2012-09-04 22:13:33 +02:00
Alejandro Mery
bcde0fc721 move OSX compatible <endian.h> exception to a common "endian_compat.h" header 2012-08-07 00:18:34 +00:00
Henrik Nordstrom
3bbef5466e pio: Correct drv_level setting 2012-08-01 00:31:17 +02:00
Henrik Nordstrom
1690132c1c pio: Correct parsing of pin values 2012-08-01 00:29:07 +02:00
Henrik Nordstrom
e9f338bb6b pio manipulation options 2012-07-31 23:49:56 +02:00
Alejandro Mery
af8146eff7 pio: clean offset pattern in pio_get() and pio_set() 2012-07-31 18:48:55 +02:00
Alejandro Mery
22e82981c5 pio: add pio_set() helper 2012-07-31 18:06:44 +02:00
Alejandro Mery
f49d3a47c8 pio: fix pio_get()'s data extraction 2012-07-31 17:34:05 +02:00
Alejandro Mery
0d2d96c484 pio: add pio print < PIO to turn a PIO dump into human readable 2012-07-31 16:01:46 +02:00