diff --git a/source/directory.c b/source/directory.c index 53bc548..65906d8 100644 --- a/source/directory.c +++ b/source/directory.c @@ -98,7 +98,8 @@ static int _FAT_directory_lfnLength (const char* name) { } // Make sure the name doesn't contain any control codes or codes not representable in UCS-2 for (i = 0; i < nameLength; i++) { - if (name[i] < 0x20 || name[i] >= ABOVE_UCS_RANGE) { + unsigned char ch = (unsigned char) name[i]; + if (ch < 0x20 || ch >= ABOVE_UCS_RANGE) { return -1; } } diff --git a/source/fatdir.c b/source/fatdir.c index 3a1f58d..4c3aaca 100644 --- a/source/fatdir.c +++ b/source/fatdir.c @@ -136,7 +136,7 @@ int _FAT_unlink_r (struct _reent *r, const char *path) { if (!_FAT_directory_isDot (&dirContents)) { // The directory had something in it that isn't a reference to itself or it's parent _FAT_unlock(&partition->lock); - r->_errno = EPERM; + r->_errno = ENOTEMPTY; return -1; } nextEntry = _FAT_directory_getNextEntry (partition, &dirContents); @@ -588,7 +588,6 @@ int _FAT_dirnext_r (struct _reent *r, DIR_ITER *dirState, char *filename, struct // Make sure there is another file to report on if (! state->validEntry) { _FAT_unlock(&state->partition->lock); - r->_errno = ENOENT; return -1; }