Age | Commit message (Collapse) | Author |
|
|
|
|
|
When a 'hard' error occurs, fwrite reports that all data was written or
buffered even if that is not the case. It should report how much data
was actually written and buffered.
Signed-off-by: Jan Vangorp <jan.vangorp_ext@softathome.com>
|
|
The man page for fopencookie prescribes that custom write functions
should return 0 on error (and should definitely not return a negative
value) [1].
However, the uClibc implementation expects a negative return value in
case of an error (libc/stdio/_WRITE.c). If the write function returns 0
on error, we drop into an infinite loop if the error persists.
This patch wraps the user supplied write function such that a 0 return
value is converted to -1. errno is first set to EAGAIN such that if the
custom write function does not set errno in case of error, this is
treated as a "soft" error.
Custom write functions that cater towards uClibc and _do_ return a
negative value are not affected.
If no custom write function is supplied, set errno to EINVAL such that
this condition is treated as a "hard" error. Previously the behaviour
depended on whether the last error before the write happened to be a "hard"
or a "soft" error.
[1] http://git.kernel.org/cgit/docs/man-pages/man-pages.git/tree/man3/fopencookie.3?id=6c0d0ef0c7a9c4bcf805c6f9e9bc1ef1c3865ea0#n164
Signed-off-by: Jan Vangorp <jan.vangorp_ext@softathome.com>
|
|
|
|
portability on system with default shell on a different directory, like for instance on android.
Signed-off-by: Ubaldo Porcheddu <ubaldo@eja.it>
|
|
Save 20 bytes per FILE structure, avoid indirect call for
read/write/seek/close operations for normal streams.
Additionally, custom streams has fileno = -2 now, like in glibc.
bloat-o-meter report (UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y):
function old new delta
fopencookie 69 131 +62
ftello64 233 260 +27
fseeko64 298 319 +21
fclose 423 442 +19
.rodata 16696 16708 +12
fileno_unlocked 53 45 -8
__ns_name_pack 859 851 -8
vswscanf 184 144 -40
vdprintf 231 187 -44
vsscanf 210 151 -59
vswprintf 269 201 -68
vsnprintf 249 181 -68
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/7 up/down: 141/-295) Total: -154 bytes
Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
|
|
Reduce the initial buffer size for open_memstream (used by vasprintf),
as most strings are usually smaller than that.
Realloc the buffer after finishing the string to further reduce size.
Problem appears in case of UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y,
see http://dev.openwrt.org/ticket/13024
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
|
|
Change __gen_tempname() prototype in order to pass the additional
suffix lenght. In __gen_tempname() add a new check for suffixlen.
Update some comments in the code.
Signed-off-by: Romain Naour <romain.naour@openwide.fr>
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
|
|
The current code implements the 'm' modifier only for 's'
conversions and would cause a segfault if it was used for 'c'
or '[' conversions. This patch extends the code to cover these
cases too.
The original version could write scanned data outside the passed buffer
because index i used in the '[' conversion handling block was clobbered.
Signed-off-by: Will Newton <will.newton@imgtec.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Only the stub warnings left for now.
|
|
|
|
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
|
|
Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
|
|
|
|
|
|
mkostemp(char *template, int flags) generates a unique temporary
filename from a template. The flags parameter accepts three of
the same flags as open(2): O_APPEND, O_CLOEXEC, and O_SYNC. The
current implementation of mkostemp(3) does not respect the flags
and in fact confuses the flags with the file mode which should
always be S_IRUSR | S_IWUSR. This patch corrects this issue.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
We were relying on FE_DIVBYZERO being turned off when printing
"%f", +-.0
Avoid the whole issue by looking at the sign-bit (in a rough
approximation).
Note that we do not handle gracefully:
printf ("\n%llf\n", -0.0);
printf ("\n%llf\n", 0.0);
nor %Lf for both when NOT cast to long double. Avoiding an FPE due to
broken numbers like these does not make sense to me.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
This reverts commit e567c399ff86d007d8c4586f0dd5e0ca61e283ca.
since it breaks badly (e.g. busybox netstat)
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
This eliminates a source of reproduceable freezes
Signed-off-by: Mirko Vogt <dev@nanl.de>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
We found that the testcase
int
main (void)
{
wchar_t s[10];
memset (s, 0, sizeof (s));
int r = sscanf ("s", "%ls", s);
printf ("%d\n", r);
printf ("%ls\n", s);
return 0;
}
printed
0
<blankline>
rather than the expected
1
s
The problem was the enum in _scanf.c, which has had a 'CONV_m' value
inserted. The attached patch fixes the problem in __psfs_parse_spec by
not presuming a particular displacement between the two sets of
char-like conversion values. With this patch the above program produces
the expected output.
Signed-off-by: Nathan Sidwell <nathan@codesourcery.com>
Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
|
|
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
This drops __signed, __volatile, and __const. Only the latter was
used in the code base, and for uClibc, not consistently. Much of
the code used plain "const" which meant "__const" was useless.
Really, the point of this is to stay in sync with what glibc did.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
|
|
This matches a similar change made to glibc.
No functional changes here.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
|
|
The current code implements the 'm' modifier only for 's'
conversions and would cause a segfault if it was used for 'c'
or '[' conversions. This patch extends the code to cover these
cases too.
Signed-off-by: Will Newton <will.newton@imgtec.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Define a common view of __errno_location, __h_errno_location in common header
and use that everywhere, __uClibc_main.c is no special.
The rule adopted:
for enabled threads we make in libc the __GI_x() variants strong, x() weak
and (should) provide another strong x() in libpthread.
If threads are disabled, even the __GI_x() variants are weak.
_stdio_init,_stdio_term,_locale_init: make all hidden weak in common header
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
remove code already in _fpmaxtostr.h
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Rely completely on the configuration options chosen,
in this case on UCLIBC_HAS_FLOATS.
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
It shows that the internal functions differ...
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
NL_MAX_ARG does not exist.
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Use one common prototype for consistency.
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
This should come properly from features.h or the build.
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Move __stdio_mutex_init,_stdio_openlist_{use,del}_count to _stdio.h.
Make _stdio_validate_FILE hidden.
Make _stdio_openlist_{add,del}_lock hidden for non-NPTL.
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Guard some UCLIBC specific parts.
Add comment about bits/getopt.h.
open_memstream.c: remove __restrict according to SuSv4.
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
use fputwc instead of fputc
add hidden fputwc to avoid jump relocation
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
The latest POSIX spec introduces a "m" character to allocate buffers for
the user when using scanf type functions. This is like the old glibc "a"
flag, but now standardized. With packages starting to use these, we need
to implement it.
for example:
char *s;
sscanf("foo", "%ms", &s);
printf("%s\n", s);
free(s);
This will automatically allocate storage for "s", read in "foo" to it,
and then display it.
I'm not terribly familiar with the stdio layer, so this could be wrong.
But it seems to work for me.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
|
|
Only really old systems (<=linux-2.0) lack a dedicated vfork system call.
The code that is in place to support them is causing issues with newer
arches that also don't provide a vfork system call -- instead, they do
vfork by calling clone in userspace.
If anyone cares about these really old systems, they can submit a patch
to make the system work with them while not breaking newer systems.
Signed-off-by: Mark Salter <msalter@redhat.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
|
|
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
|
Some test results:
The longer patch posted at Sun 14:46:24 +0100 made my target system
unbootable. I did not attempt to troubleshoot it, as we are focusing
our efforts on the shorter patch now.
The shorter patch posted at Mon 01:50:27 +0100 is a good start, but it
didn't completely fix the problem for me. I am posting an updated
version with a few changes at the end of this message; the patched
uClibc 0.9.32.1 tree passes both of my test cases.
My changes:
1) Need to break out of the loop on "hard" errors. Otherwise the
library call never returns:
open("/dev/null", O_RDONLY) = 4
dup2(4, 1) = 1
write(1, "hello world\n", 12) = -1 EBADF (Bad file descriptor)
write(1, "hello world\n", 12) = -1 EBADF (Bad file descriptor)
write(1, "hello world\n", 12) = -1 EBADF (Bad file descriptor)
write(1, "hello world\n", 12) = -1 EBADF (Bad file descriptor)
...
2) Move all of the error handling logic back into the "else" clause. In
particular, I believe we do not want to be checking errno unless
__WRITE() had indicated a failure, since the value may be undefined:
if (errno == EINTR
|| errno == EAGAIN
/* do we have other "soft" errors? */
) {
3) Whitespace/indentation consistency.
-- 8< --
From: Denys Vlasenko <vda.linux@googlemail.com>
Currently, uclibc retains buffered data on stdio write errors,
and subsequent fclose and fflush will try to write it out again
(in most cases, in vain).
Which results in something like this:
On Wednesday 26 January 2011 13:21, Baruch Siach wrote:
> Hi busybox list,
>
> I'm running the following command under strace (thanks Rob):
>
> echo 56 > /sys/class/gpio/export
>
> and I see the following output:
>
> write(1, "56\n", 3) = -1 EBUSY (Device or resource busy)
> write(1, "5", 1) = 1
>
> The first EBUSY is OK, since GPIO 56 is already requested. But the second
> write() attempt seems strange, and leads to an unwanted outcome. GPIO 5 gets
> exported.
This patch prevents that.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
|
|
Pulled assignments out of ifs.
do {...} while (1); is a weird method of writing "loop forever",
thus rewrote it.
No code changes: objdump output is the same.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|