@@ -176,8 +176,7 @@ int fioOpen(const char *name, int mode)
176176 WaitSema (_fio_completion_sema );
177177
178178 arg .mode = mode ;
179- strncpy (arg .name , name , FIO_PATH_MAX - 1 );
180- arg .name [FIO_PATH_MAX - 1 ] = 0 ;
179+ strlcpy (arg .name , name , sizeof (arg .name ));
181180
182181 if ((res = sceSifCallRpc (& _fio_cd , FIO_F_OPEN , _fio_block_mode , & arg , sizeof arg ,
183182 _fio_recv_data , 4 , (void * )_fio_intr , NULL )) >= 0 ) {
@@ -399,8 +398,7 @@ int fioRemove(const char *name)
399398 WaitSema (_fio_io_sema );
400399 WaitSema (_fio_completion_sema );
401400
402- strncpy (arg .path , name , FIO_PATH_MAX - 1 );
403- arg .path [FIO_PATH_MAX - 1 ] = 0 ;
401+ strlcpy (arg .path , name , sizeof (arg .path ));
404402
405403 if ((res = sceSifCallRpc (& _fio_cd , FIO_F_REMOVE , 0 , & arg , sizeof arg ,
406404 & arg , 4 , (void * )_fio_intr , NULL )) >= 0 ) {
@@ -432,8 +430,7 @@ int fioMkdir(const char *path)
432430 WaitSema (_fio_io_sema );
433431 WaitSema (_fio_completion_sema );
434432
435- strncpy (arg .path , path , FIO_PATH_MAX - 1 );
436- arg .path [FIO_PATH_MAX - 1 ] = 0 ;
433+ strlcpy (arg .path , path , sizeof (arg .path ));
437434
438435 if ((res = sceSifCallRpc (& _fio_cd , FIO_F_MKDIR , 0 , & arg , sizeof arg ,
439436 & arg , 4 , (void * )_fio_intr , NULL )) >= 0 ) {
@@ -465,8 +462,7 @@ int fioRmdir(const char *dirname)
465462 WaitSema (_fio_io_sema );
466463 WaitSema (_fio_completion_sema );
467464
468- strncpy (arg .path , dirname , FIO_PATH_MAX - 1 );
469- arg .path [FIO_PATH_MAX - 1 ] = 0 ;
465+ strlcpy (arg .path , dirname , sizeof (arg .path ));
470466
471467 if ((res = sceSifCallRpc (& _fio_cd , FIO_F_RMDIR , 0 , & arg , sizeof arg ,
472468 & arg , 4 , (void * )_fio_intr , NULL )) >= 0 ) {
@@ -542,8 +538,7 @@ int fioDopen(const char *name)
542538 WaitSema (_fio_io_sema );
543539 WaitSema (_fio_completion_sema );
544540
545- strncpy (arg .name , name , FIO_PATH_MAX - 1 );
546- arg .name [FIO_PATH_MAX - 1 ] = 0 ;
541+ strlcpy (arg .name , name , sizeof (arg .name ));
547542
548543 if ((res = sceSifCallRpc (& _fio_cd , FIO_F_DOPEN , 0 , & arg , sizeof arg ,
549544 & arg , 4 , (void * )_fio_intr , NULL )) >= 0 ) {
@@ -636,8 +631,7 @@ int fioGetstat(const char *name, io_stat_t *buf)
636631 WaitSema (_fio_completion_sema );
637632
638633 arg .p .buf = buf ;
639- strncpy (arg .name , name , FIO_PATH_MAX - 1 );
640- arg .name [FIO_PATH_MAX - 1 ] = 0 ;
634+ strlcpy (arg .name , name , sizeof (arg .name ));
641635
642636 if (!IS_UNCACHED_SEG (buf ))
643637 sceSifWriteBackDCache (buf , sizeof (io_stat_t ));
@@ -670,8 +664,7 @@ int fioChstat(const char *name, io_stat_t *buf, u32 cbit)
670664
671665 arg .p .cbit = cbit ;
672666 memcpy (& arg .stat , buf , sizeof (io_stat_t ));
673- strncpy (arg .name , name , FIO_PATH_MAX - 1 );
674- arg .name [FIO_PATH_MAX - 1 ] = 0 ;
667+ strlcpy (arg .name , name , sizeof (arg .name ));
675668
676669 if ((res = sceSifCallRpc (& _fio_cd , FIO_F_CHSTAT , 0 , & arg , sizeof arg ,
677670 & arg , 4 , (void * )_fio_intr , NULL )) >= 0 ) {
@@ -703,8 +696,7 @@ int fioFormat(const char *name)
703696 WaitSema (_fio_io_sema );
704697 WaitSema (_fio_completion_sema );
705698
706- strncpy (arg .path , name , FIO_PATH_MAX - 1 );
707- arg .path [FIO_PATH_MAX - 1 ] = 0 ;
699+ strlcpy (arg .path , name , sizeof (arg .path ));
708700
709701 if ((res = sceSifCallRpc (& _fio_cd , FIO_F_FORMAT , 0 , & arg , sizeof arg ,
710702 & arg , 4 , (void * )_fio_intr , NULL )) >= 0 ) {
0 commit comments