[PATCH] dosfs: Unsigned compared against 0

Ralf Kirchner ralf.kirchner at embedded-brains.de
Fri Sep 6 16:46:13 UTC 2013


Hi Gedare,
Iconv() does not return any negative values. It returns "(size_t)-1" in
case of an error and the number of non-reversibly converted characters
in case of success.

Thus please revert to size_t for the return value type and in addition
apply this patch:

---
 cpukit/libfs/src/dosfs/msdos_conv_utf8.c |   11 ++++++++---
 1 Datei geändert, 8 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)

diff --git a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
index 18aebc6..6760d2e 100644
--- a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
+++ b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
@@ -69,10 +69,15 @@ static int msdos_utf8_convert_with_iconv(

   *dst_size -= outbytes_left;

-  if ( iconv_status > 0 ) {
-    eno = EINVAL;
-  } else if ( iconv_status < 0 ) {
+  if ( iconv_status == (size_t)-1 ) {
+    /* iconv() has detected an error. The most likely reason seems to +
      be a too small outbuf */
     eno = ENOMEM;
+  } else if ( iconv_status > 0 ) {
+    /* iconv_status contains the number of characters converted in a +
      non-reversible way.
+       We want to use reversible conversions only.
+       Characters permitted within DOSFS names seem to be reversible. */
+    eno = EINVAL;
   }

   return eno;
-- 
1.7.10.4

Am 05.09.2013 19:18, schrieb Gedare Bloom:
> On Thu, Sep 5, 2013 at 1:17 PM, Gedare Bloom <gedare at rtems.org> wrote:
>> Change the type for storing the return from iconv to be signed.
>> ---
>>  cpukit/libfs/src/dosfs/msdos_conv_utf8.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>> index a80db7e..18aebc6 100644
>> --- a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>> +++ b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>> @@ -57,7 +57,7 @@ static int msdos_utf8_convert_with_iconv(
>>    size_t  outbytes_left = *dst_size;
>>    char   *inbuf = (void *) (uintptr_t) src;
>>    char   *outbuf = dst;
>> -  size_t  iconv_status;
>> +  ssize_t iconv_status;
>>
>>    iconv_status = iconv(
> Note that iconv returns a size_t. Perhaps the return value should be
> cast explicitly to make this clear. newlib returns (size_t)-1 in case
> of an error in iconv.
> 
>>      desc,
>> --
>> 1.7.1
>>
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel
> 


-- 
--------------------------------------------
Embedded Brains GmbH
Ralf Kirchner          Dornierstr. 4
D-82178 Puchheim       Germany
email: ralf.kirchner at embedded-brains.de
Phone: +49-89-18 94 741-17
Fax:   +49-89-18 94 741-08

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list