| Age | Commit message (Collapse) | Author |
|
more knf-compliant
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
fread() may return short reads, whereas the current
code assumes either EOF or a full read.
change if to a while. really, it's that simple.
just loop until it's done. i probably b0rked this
myself when refactoring the GNU code.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
i treated ftell errors as fatal, but if fttell fails
with ESPIPE, and someone's using -d, the program may
exit immediately, even though there's no problem.
instead, skip printing the offset (basically no debug).
this fixes a bug that i introduced myself, when i forked
this code, because i added that error check; the GNU
code didn't have any check whatsoever.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
we currently read small amounts of data with fread,
repeatedly, which is quite taxing on the CPU, on
very old systems.
48khz audio. 48000 calls to fread() per second?
yeah. let's optimise this.
performance now should be roughly O(1) in practise.
this and the other recent changes means no modulo
or division, reduced branching, memory memory roads,
and lots of buffering.
the buffering here is quite conservative, so the human
won't notice any difference. we're cutting the number
of times we call fread by a factor of several thousand,
but you'll still see text scrolling down pretty quick,
with minimal lag.
the old GNU code i forked was terrible at this.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
make it clearer about next/old, in the loop. this also
improves performance on older systems (cache the values
first, don't re-calculate)
again, this is GNU code. but you wouldn't know it, in my
current version. i forked this from GRUB several years
ago and started cleaning it for fun.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
the signal check should be its own function,
for clearer understanding
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
frame handling, error checks, pulse decoding and
character decoding are all jumbled up. this patch
separates them a bit, making it clearer.
should also help codegen. this tool is dealing with
high bandwidth text, which on slower computers may
be cumbersome. every optimisation counts.
not really relevant on newer systems.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
instead of computing next every time, just advance
two indexes. another performance optimisation on
older machines, especially old compilers, because
it reduces the amount of logical branching.
the old code was pretty much just advancing two
indexes in lockstep, when getting the next pulse,
but recalculating one of them based on the other,
each time.
this is yet another hangover from the old GNU code
that i forked three years ago.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
it's slow on older compilers/systems that don't optimise.
instead, we branch (cheaper) and just do an above or
equal comparison), resetting appropriately or subtracting.
should yield an actually useful performance gain, on older
systems. a bit theoretical on modern systems, which optimise
well (modern compilers will produce assembly code much like
what the new C code is doing)
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
a bit pedantic. but that's my intention.
for backwards compatibility with older systems.
this flag means: create the directory. on modern
versions on all systems, it's the default behaviour.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
i used a bunch of global variables. that's gone.
added proper externs, including for errno. lots of
old unix systems require this. this version should
be perfectly polished and portable now.
all status is now handled in a struct, making the
code a bit easier to understand, because the variables
now are clearly pertinent to the state of the decoder,
rather than being seemingly random.
some indentation reduced.
also cleaned up ftell/feof usage again. the new code
is a bit more robust when dealing with piped input(which
is literally what this program takes, exclusively)
i started my cleanup of this tool from GNU GRUB in 2023.
i finished it today.
also the Openbsd pledge is more portable now (code made
to compile on pre-pledge openbsd as well)
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
also handle EOF condition and exit cleanly.
don't use dirty feof.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
i use -pedantic and std=c90
also add the define
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
borrowing recent improvements from nvmutil
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
using a special leah-only technique
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
subtract and add iteratively
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
accidentally removed it during re-factor
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
skip it if there is a valid checksum, to mitigate
erroneous errno state upon exit from run_cmd(),
because we can assume by this point that we
are in fact ready to write at this point.
the check at the end still exists, which will catch
any error set by write, and any error set before
that. this fixes a weird warning on cmd_dump.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
reset it in callers instead.
this means that the main function is more generalised.
we know by the time we exit that there is no error.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
in the new file i/o functions, my own setting
of errno should be done with set_err. this
avoids clobbering what the real libc set.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
i set it to ecanceled before. now i set it more
appropriately, for each type of error.
where a real syscall was called, or my file i/o
functions are used, err() is called with errno
itself as input, to avoid clobbering real errno.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
i forgot to set urandom_fd
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
This reverts commit b28076557b4c12965c15d6fad7c06e34c67f7921.
nope. the check was already correct before.
|
|
in practise it's ok, but some compilers might complain.
all this change costs is a bit of branching inside a
loop, but compilers will sort that out.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
only use errno itself as the value
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Use its return value. Don't exit from the function,
but actually treat it like a real syscall.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
on some systems, it is otherwise blocking, but blocking
can be disabled, making access more reliable.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
preventative fix, since the values are currently
quite tiny. this new check is the same, but goes
the other way to eliminate overflow.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
this is essentially what it already did, but it
wasn't explicitly stated. now it's clearer.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
the old one assumes that ssize_t is signed size_t,
which let's face it, is always true in practise,
but not actually guaranteed!
so now i'm using one that's even more pedantic.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|