Ignore:
Timestamp:
Jul 16, 2015, 3:29:10 PM (9 years ago)
Author:
guerin
Message:

fat32: use strcmp instead of strncmp

The length argument was wrong most of the time. Avoid confusion by
not specifying it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_fat32/fat32.c

    r617 r619  
    20432043        name , parent->name );
    20442044#endif
    2045 
    2046     // compute name lenth
    2047     unsigned int length = _strlen( name );
    20482045   
    20492046    // scan inodes in the parent directory
    20502047    for ( current = parent->child ; current ; current = current->next )
    20512048    {
    2052         if ( _strncmp( name , current->name , length ) == 0 )
     2049        if ( _strcmp( name , current->name ) == 0 )
    20532050        {
    20542051
     
    21532150                   
    21542151                // test if extracted name == searched name
    2155                 if ( _strncmp( name , cname , length ) == 0 )
     2152                if ( _strcmp( name , cname ) == 0 )
    21562153                {
    21572154                    cluster = (_read_entry( DIR_FST_CLUS_HI , buffer + offset , 1 ) << 16) |
     
    22232220
    22242221    // handle root directory case
    2225     if ( _strncmp( pathname , "/" , 2 ) == 0 )
     2222    if ( _strcmp( pathname , "/" ) == 0 )
    22262223    {
    22272224
     
    22592256#endif
    22602257
    2261         if ( _strncmp( name, "..", _strlen( name ) + 1 ) == 0)
     2258        if ( _strcmp( name, ".." ) == 0)
    22622259        {
    22632260            // found special name "..", try to go up
     
    22682265                child = parent;
    22692266        }
    2270         else if ( _strncmp( name, ".", _strlen( name ) + 1 ) == 0 )
     2267        else if ( _strcmp( name, "." ) == 0 )
    22712268        {
    22722269            // found special name ".", stay on the same level
     
    24122409    char            cname[32];            // buffer for a full name in a directory entry
    24132410    unsigned int    nb_read;              // number of characters analysed in path
    2414     unsigned int    length;               // searched name length
    24152411    unsigned int    parent_cluster;       // cluster index for the parent directory
    24162412    unsigned int    child_cluster = 0;    // cluster index for the searched file/dir
     
    24452441#endif
    24462442        found  = 0;
    2447         length = _strlen( name );
    24482443
    24492444        // scan clusters containing the parent directory
     
    25202515                   
    25212516                    // test if extracted name == searched name
    2522                     if ( _strncmp( name , cname , length ) == 0 )
     2517                    if ( _strcmp( name , cname ) == 0 )
    25232518                    {
    25242519                        child_cluster = (_read_entry( DIR_FST_CLUS_HI , buf , 1 ) << 16) |
Note: See TracChangeset for help on using the changeset viewer.