Match glibc behavior.
* libc/stdlib/stdlib.c (mbtowc): Fix end of string behavior.
Signed-off-by: Mickaël Guêné <mickael.guene(a)st.com>
Signed-off-by: Christophe Lyon <christophe.lyon(a)st.com>
diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c
index 075e6e5..f593663 100644
--- a/libc/stdlib/stdlib.c
+++ b/libc/stdlib/stdlib.c
@@ -895,9 +895,13 @@ int mbtowc(wchar_t *__restrict pwc, register const char *__restrict
s, size_t n)
return is_stateful(ENCODING);
}
- if (*s == '\0')
+ if (*s == '\0') {
/* According to the ISO C 89 standard this is the expected behaviour. */
+ /* Standard not very clear here, so do like glibc. */
+ if (pwc != NULL)
+ *pwc = L'\0';
return 0;
+ }
if ((r = mbrtowc(pwc, s, n, &state)) == (size_t) -2) {
/* TODO: Should we set an error state? */
--
2.6.3
Show replies by date
Handle EISDIR in shm_open like glibc does, and set EINVAL.
* librt/shm.c (shm_open): Handle EISDIR error.
Signed-off-by: Mickaël Guêné <mickael.guene(a)st.com>
Signed-off-by: Christophe Lyon <christophe.lyon(a)st.com>
diff --git a/librt/shm.c b/librt/shm.c
index 40e69fa..79c98a3 100644
--- a/librt/shm.c
+++ b/librt/shm.c
@@ -84,6 +84,9 @@ int shm_open(const char *name, int oflag, mode_t mode)
*/
}
#endif
+ if (fd < 0 && errno == EISDIR)
+ /* EISDIR is not valid for shm_open, replace it with EINVAL as glibc. */
+ __set_errno (EINVAL);
free(shm_name); /* doesn't affect errno */
return fd;
}
--
2.6.3
R_ARM_NONE contains no data, so avoid dereferencing it.
* ldso/ldso/arm/elfinterp.c (_dl_do_reloc): Handle R_ARM_NONE
relocation
(_dl_do_reloc_lazy): Likewise.
Signed-off-by: Mickaël Guêné <mickael.guene(a)st.com>
Signed-off-by: Christophe Lyon <christophe.lyon(a)st.com>
diff --git a/ldso/ldso/arm/elfinterp.c b/ldso/ldso/arm/elfinterp.c
index 3bcd675..2444ed7 100644
--- a/ldso/ldso/arm/elfinterp.c
+++ b/ldso/ldso/arm/elfinterp.c
@@ -289,7 +289,10 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope,
#if defined (__SUPPORT_LD_DEBUG__)
{
- unsigned long old_val = *reloc_addr;
+ unsigned long old_val;
+
+ if (reloc_type != R_ARM_NONE)
+ old_val = *reloc_addr;
#endif
switch (reloc_type) {
case R_ARM_NONE:
@@ -386,7 +389,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope,
return -1; /*call _dl_exit(1) */
}
#if defined (__SUPPORT_LD_DEBUG__)
- if (_dl_debug_reloc && _dl_debug_detail)
+ if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_ARM_NONE)
_dl_dprintf(_dl_debug_file, "\tpatch: %x ==> %x @ %x", old_val,
*reloc_addr, reloc_addr);
}
@@ -407,7 +410,10 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct r_scope_elem
*scope,
#if defined (__SUPPORT_LD_DEBUG__)
{
- unsigned long old_val = *reloc_addr;
+ unsigned long old_val;
+
+ if (reloc_type != R_ARM_NONE)
+ old_val = *reloc_addr;
#endif
switch (reloc_type) {
case R_ARM_NONE:
@@ -428,7 +434,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct r_scope_elem
*scope,
return -1; /*call _dl_exit(1) */
}
#if defined (__SUPPORT_LD_DEBUG__)
- if (_dl_debug_reloc && _dl_debug_detail)
+ if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_ARM_NONE)
_dl_dprintf(_dl_debug_file, "\tpatch: %x ==> %x @ %x", old_val,
*reloc_addr, reloc_addr);
}
--
2.6.3