[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: kdepim/kfile-plugins/vcf
From:       Nicolas Goutte <nicolasg () snafu ! de>
Date:       2003-12-16 17:06:39
[Download RAW message or body]

I am sorry but that is exactly an example why I do not understand why strlcpy 
is used instead of qstrncpy (and why strlcpy was introduced at all in KDE.)

sizeof( buf_name ) is even less than 32767 so why a long int would be needed 
as size. Also qstrncpy will be ported free of cost for KDE by Trolltech to 
any architecture than would give problems.

(Using systematically qstrncpy would make it even portable to old glibc where 
sizeof(size_t) != sizeof(long int),  would avoid the check in configure and 
the message now and then on kde-devel that nobody answers.)

(Yes, I know strlcat exist. What I do not understand is why it too cannot be 
more portable in a qstr* way.)

Have a nice day!

(PS.: by the way, the qstr* function are documented with QCString.)

--- Original Message ---
List:     kde-cvs
Subject:  kdepim/kfile-plugins/vcf
From:     Dirk Mueller <mueller () kde ! org>
Date:     2003-12-15 23:15:39

CVS commit by mueller: 

strncpy -> strlcpy. Just a minor beautification


  M +13 -13    kfile_vcf.cpp   1.6


--- kdepim/kfile-plugins/vcf/kfile_vcf.cpp  #1.5:1.6
@@ -97,9 +97,9 @@ bool KVcfPlugin::readInfo( KFileMetaInfo
             // we have a name
             myptr = linebuf + 3;
-            strncpy(buf_name, myptr, sizeof( buf_name ));
+            strlcpy(buf_name, myptr, sizeof( buf_name ));
         } else if (memcmp(linebuf, id_email, 15) == 0) {
             // we have a name
             myptr = linebuf + 15;
-            strncpy(buf_email, myptr, sizeof( buf_email ));
+            strlcpy(buf_email, myptr, sizeof( buf_email ));
         }
         

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic