[llvm-commits] [PATCH] Remove the use of C string function in Errno.cpp

Martinez, Javier E javier.e.martinez at intel.com
Thu Sep 27 21:45:05 PDT 2012


Dmitri,

Great suggestion. Attached is the revised patch.

Thanks,
Javier

-----Original Message-----
From: Dmitri Gribenko [mailto:gribozavr at gmail.com] 
Sent: Thursday, September 27, 2012 1:55 AM
To: Martinez, Javier E
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] [PATCH] Remove the use of C string function in Errno.cpp

On Thu, Sep 27, 2012 at 9:55 AM, Martinez, Javier E <javier.e.martinez at intel.com> wrote:
> This patch is to remove the use of strncpy and sprintf in Errno.cpp 
> and replace them with operations on LLVM string objects. This is the 
> first of a series of patches to remove the use of C string functions. 
> For some background on this please the attached conversation. As I’m 
> pretty inexperienced submitting patches please let me know if I need 
> to do things differently.

-  sprintf(buffer, "Error #%d", errnum);
+  format_object1<int> formatError("Error #%d",errnum);  
+ formatError.snprint(buffer, MaxErrStrLen);  str = buffer;

I think it is better to use raw_string_ostream with str directly here.

Dmitri

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Errno.cpp.patch
Type: application/octet-stream
Size: 1402 bytes
Desc: Errno.cpp.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120928/b35b2d7a/attachment.obj>


More information about the llvm-commits mailing list