Commit Graph

31 Commits

Author SHA1 Message Date
riastradh
d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
dholland
f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
dholland
a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
christos
9a5d3f2817 replace bitmask_snprintf(9) with snprintb(3) 2008-12-16 22:35:21 +00:00
cegger
376411d2dd device_t / softc split. From Hans Rosenfeld. 2008-04-16 09:39:01 +00:00
cegger
7b52308352 Use %zu format specifier for size_t. Fixes build error on shark. 2008-04-15 22:50:33 +00:00
cegger
2ae1aec4f9 Make this build without options LPT_VERBOSE and LPT_DEBUG. From Hans Rosenfeld. 2008-04-15 19:06:16 +00:00
cegger
b849cd90e5 device_t / softc split. From Hans Rosenfeld 2008-04-15 15:02:28 +00:00
cegger
1b044f414a use aprint_*_dev and device_xname 2008-04-08 07:35:35 +00:00
tsutsui
40009ad586 struct lpt_softc doesn't have sc_dev in it. Use ppbus_dev.sc_dev. 2008-02-27 12:52:36 +00:00
dyoung
0ba85a6f89 Use device_t and accessors. Use &sc->sc_dev instead of cast to
device_t.  Remove superfluous detach warning.
2008-02-22 23:11:35 +00:00
ad
a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
drochner
747abe99e5 add zero initializers to make that compile again 2006-10-24 19:16:50 +00:00
thorpej
ec03de0c39 Use device_pprivate(). 2006-03-29 17:23:56 +00:00
thorpej
5887891a8d Use device_parent(). 2006-03-25 03:44:35 +00:00
rpaulo
e868ae92cb PR/32381: Paul Shupak. Convert to ktrace-lwp. 2005-12-25 18:43:31 +00:00
christos
95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
perry
f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
jdolecek
9300becc32 allow setting of interrupt usage, priming and auto LF behaviour
via ioctl; drop the traditional device minor mapping for those in favour
of setting via lptctl(8)

introduce notion of 'control' device (minor bit 0x100 set); ATM this
device always skips the priming, which allows device open even with
disconnected printer

this also changes the default for interrupt use - polling is used
by default now
2004-02-03 21:15:03 +00:00
jdolecek
f44dc9ed8b overhaul the ioctl interface to be better suited for extensions and to
reduce number of separate ioctls - have only 'get mode', 'set mode',
'get flags', 'set flags'
2004-02-03 19:57:00 +00:00
jdolecek
9898c64ca9 g/c some unused/write-only/redundant lpt_softc stuff
some style changes in lptwrite() + some printfs adjusted
2004-02-03 18:48:39 +00:00
jdolecek
8081dfaa4b whitespace fixes, make LPTIO_DISABLE_DMA 'succeed' if DMA is not supported 2004-01-30 11:40:55 +00:00
jdolecek
f06d010f7f make testbyte[] in lpt_detect() static const 2004-01-28 18:03:45 +00:00
jdolecek
89ba3070d0 do not use enums in ioctl structure, use fixed width integers instead
g/c boolean_t enum, explicitly assign numbers for lpt_mode_t enum

Note: lptctl needs to be recompiled to print status properly withh new kernel
2004-01-28 09:29:06 +00:00
jdolecek
ce4629f6f2 say 'port mode = <foo>' in autoconf message, so that it would be more
clear it's port attribute, not driver attribute
2004-01-25 11:43:09 +00:00
bjh21
1c34707a4c Remove dollar signs from foreign RCSIDs per doc/3RDPARTY.
Add __KERNEL_RCSID() to .c files.
2004-01-25 00:28:01 +00:00
bjh21
58859f40c7 Don't use "int" when we mean "size_t". Fixes compile on ARM. 2004-01-22 01:18:54 +00:00
bjh21
f782033436 Add RCSID comments. 2004-01-21 00:33:37 +00:00
jdolecek
9bf083c370 attach this with lpt_ppbus, just to make co-existence with dev/ic/lpt.c
easier
fix a printf() format string
2004-01-20 19:16:13 +00:00
jdolecek
e23cd1a78a Import Gary Thorpe's netbsd-ppbus 1.3. This is NetBSD port
of FreeBSD Parallel Port Bus framework. Work in progress.
2004-01-19 23:22:23 +00:00