Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 22 Aug 2012 11:56:38 -0400
changeset 20367 8162dbfb50b73da77461d6ed0920434b66808695
parent 20366 893424209bf051b2682149c50a980e7c988b5198
child 20376 efa60ab5882351c123d7ef6699aadd4f2e842615
push id1209
push usermbanner@mozilla.com
push dateTue, 02 Sep 2014 16:59:36 +0000
treeherdercomm-beta@842e0fd167ee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs579517
Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double
mailnews/mime/src/nsCMS.cpp
mailnews/mime/src/nsCMS.h
mailnews/mime/src/nsCMSSecureMessage.cpp
mailnews/mime/src/nsCMSSecureMessage.h
--- a/mailnews/mime/src/nsCMS.cpp
+++ b/mailnews/mime/src/nsCMS.cpp
@@ -192,35 +192,35 @@ NS_IMETHODIMP nsCMSMessage::GetEncryptio
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown())
     return NS_ERROR_NOT_AVAILABLE;
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-NS_IMETHODIMP nsCMSMessage::VerifyDetachedSignature(unsigned char* aDigestData, PRUint32 aDigestDataLen)
+NS_IMETHODIMP nsCMSMessage::VerifyDetachedSignature(unsigned char* aDigestData, uint32_t aDigestDataLen)
 {
   if (!aDigestData || !aDigestDataLen)
     return NS_ERROR_FAILURE;
 
   return CommonVerifySignature(aDigestData, aDigestDataLen);
 }
 
-nsresult nsCMSMessage::CommonVerifySignature(unsigned char* aDigestData, PRUint32 aDigestDataLen)
+nsresult nsCMSMessage::CommonVerifySignature(unsigned char* aDigestData, uint32_t aDigestDataLen)
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown())
     return NS_ERROR_NOT_AVAILABLE;
 
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSMessage::CommonVerifySignature, content level count %d\n", NSS_CMSMessage_ContentLevelCount(m_cmsMsg)));
   NSSCMSContentInfo *cinfo = nullptr;
   NSSCMSSignedData *sigd = nullptr;
   NSSCMSSignerInfo *si;
-  PRInt32 nsigners;
+  int32_t nsigners;
   nsresult rv = NS_ERROR_FAILURE;
   nsRefPtr<nsCERTValInParamWrapper> survivingParams;
   nsCOMPtr<nsINSSComponent> inss;
 
   if (!NSS_CMSMessage_IsSigned(m_cmsMsg)) {
     PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSMessage::CommonVerifySignature - not signed\n"));
     return NS_ERROR_CMS_VERIFY_NOT_SIGNED;
   } 
@@ -350,26 +350,26 @@ loser:
 NS_IMETHODIMP nsCMSMessage::AsyncVerifySignature(
                               nsISMimeVerificationListener *aListener)
 {
   return CommonAsyncVerifySignature(aListener, nullptr, 0);
 }
 
 NS_IMETHODIMP nsCMSMessage::AsyncVerifyDetachedSignature(
                               nsISMimeVerificationListener *aListener,
-                              unsigned char* aDigestData, PRUint32 aDigestDataLen)
+                              unsigned char* aDigestData, uint32_t aDigestDataLen)
 {
   if (!aDigestData || !aDigestDataLen)
     return NS_ERROR_FAILURE;
 
   return CommonAsyncVerifySignature(aListener, aDigestData, aDigestDataLen);
 }
 
 nsresult nsCMSMessage::CommonAsyncVerifySignature(nsISMimeVerificationListener *aListener,
-                                                  unsigned char* aDigestData, PRUint32 aDigestDataLen)
+                                                  unsigned char* aDigestData, uint32_t aDigestDataLen)
 {
   nsSMimeVerificationJob *job = new nsSMimeVerificationJob;
   if (!job)
     return NS_ERROR_OUT_OF_MEMORY;
   
   if (aDigestData)
   {
     job->digest_data = new unsigned char[aDigestDataLen];
@@ -422,28 +422,28 @@ public:
 
   void destructorSafeDestroyNSSReference()
   {
     if (isAlreadyShutDown())
       return;
 
     if (mCerts)
     {
-      for (PRUint32 i=0; i < mSize; i++) {
+      for (uint32_t i=0; i < mSize; i++) {
         if (mCerts[i]) {
           CERT_DestroyCertificate(mCerts[i]);
         }
       }
     }
 
     if (mPoolp)
       PORT_FreeArena(mPoolp, false);
   }
 
-  bool allocate(PRUint32 count)
+  bool allocate(uint32_t count)
   {
     // only allow allocation once
     if (mPoolp)
       return false;
   
     mSize = count;
 
     if (!mSize)
@@ -455,40 +455,40 @@ public:
 
     mCerts = (CERTCertificate**)PORT_ArenaZAlloc(
       mPoolp, (count+1)*sizeof(CERTCertificate*));
 
     if (!mCerts)
       return false;
 
     // null array, including zero termination
-    for (PRUint32 i = 0; i < count+1; i++) {
+    for (uint32_t i = 0; i < count+1; i++) {
       mCerts[i] = nullptr;
     }
 
     return true;
   }
   
-  void set(PRUint32 i, CERTCertificate *c)
+  void set(uint32_t i, CERTCertificate *c)
   {
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown())
       return;
 
     if (i >= mSize)
       return;
     
     if (mCerts[i]) {
       CERT_DestroyCertificate(mCerts[i]);
     }
     
     mCerts[i] = CERT_DupCertificate(c);
   }
   
-  CERTCertificate *get(PRUint32 i)
+  CERTCertificate *get(uint32_t i)
   {
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown())
       return nullptr;
 
     if (i >= mSize)
       return nullptr;
     
@@ -502,38 +502,38 @@ public:
       return nullptr;
 
     return mCerts;
   }
 
 private:
   CERTCertificate **mCerts;
   PLArenaPool *mPoolp;
-  PRUint32 mSize;
+  uint32_t mSize;
 };
 
 NS_IMETHODIMP nsCMSMessage::CreateEncrypted(nsIArray * aRecipientCerts)
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown())
     return NS_ERROR_NOT_AVAILABLE;
 
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSMessage::CreateEncrypted\n"));
   NSSCMSContentInfo *cinfo;
   NSSCMSEnvelopedData *envd;
   NSSCMSRecipientInfo *recipientInfo;
   nsZeroTerminatedCertArray recipientCerts;
   SECOidTag bulkAlgTag;
   int keySize;
-  PRUint32 i;
+  uint32_t i;
   nsCOMPtr<nsIX509Cert2> nssRecipientCert;
   nsresult rv = NS_ERROR_FAILURE;
 
   // Check the recipient certificates //
-  PRUint32 recipientCertCount;
+  uint32_t recipientCertCount;
   aRecipientCerts->GetLength(&recipientCertCount);
   PR_ASSERT(recipientCertCount > 0);
 
   if (!recipientCerts.allocate(recipientCertCount)) {
     goto loser;
   }
 
   for (i=0; i<recipientCertCount; i++) {
@@ -600,17 +600,17 @@ loser:
   if (m_cmsMsg) {
     NSS_CMSMessage_Destroy(m_cmsMsg);
     m_cmsMsg = nullptr;
   }
 
   return rv;
 }
 
-NS_IMETHODIMP nsCMSMessage::CreateSigned(nsIX509Cert* aSigningCert, nsIX509Cert* aEncryptCert, unsigned char* aDigestData, PRUint32 aDigestDataLen)
+NS_IMETHODIMP nsCMSMessage::CreateSigned(nsIX509Cert* aSigningCert, nsIX509Cert* aEncryptCert, unsigned char* aDigestData, uint32_t aDigestDataLen)
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown())
     return NS_ERROR_NOT_AVAILABLE;
 
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSMessage::CreateSigned\n"));
   NSSCMSContentInfo *cinfo;
   NSSCMSSignedData *sigd;
@@ -798,17 +798,17 @@ NS_IMETHODIMP nsCMSDecoder::Start(NSSCMS
   if (!m_dcx) {
     PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSDecoder::Start - can't start decoder\n"));
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 /* void update (in string bug, in long len); */
-NS_IMETHODIMP nsCMSDecoder::Update(const char *buf, PRInt32 len)
+NS_IMETHODIMP nsCMSDecoder::Update(const char *buf, int32_t len)
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown())
     return NS_ERROR_NOT_AVAILABLE;
 
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSDecoder::Update\n"));
   NSS_CMSDecoder_Update(m_dcx, (char *)buf, len);
   return NS_OK;
@@ -884,17 +884,17 @@ NS_IMETHODIMP nsCMSEncoder::Start(nsICMS
   if (m_ecx == nullptr) {
     PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSEncoder::Start - can't start encoder\n"));
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 /* void update (in string aBuf, in long aLen); */
-NS_IMETHODIMP nsCMSEncoder::Update(const char *aBuf, PRInt32 aLen)
+NS_IMETHODIMP nsCMSEncoder::Update(const char *aBuf, int32_t aLen)
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown())
     return NS_ERROR_NOT_AVAILABLE;
 
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSEncoder::Update\n"));
   if (!m_ecx || NSS_CMSEncoder_Update(m_ecx, aBuf, aLen) != SECSuccess) {
     PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSEncoder::Update - can't update encoder\n"));
--- a/mailnews/mime/src/nsCMS.h
+++ b/mailnews/mime/src/nsCMS.h
@@ -38,20 +38,20 @@ public:
   virtual ~nsCMSMessage();
   
   void referenceContext(nsIInterfaceRequestor* aContext) {m_ctx = aContext;}
   NSSCMSMessage* getCMS() {return m_cmsMsg;}
 private:
   nsCOMPtr<nsIInterfaceRequestor> m_ctx;
   NSSCMSMessage * m_cmsMsg;
   NSSCMSSignerInfo* GetTopLevelSignerInfo();
-  nsresult CommonVerifySignature(unsigned char* aDigestData, PRUint32 aDigestDataLen);
+  nsresult CommonVerifySignature(unsigned char* aDigestData, uint32_t aDigestDataLen);
 
   nsresult CommonAsyncVerifySignature(nsISMimeVerificationListener *aListener,
-                                      unsigned char* aDigestData, PRUint32 aDigestDataLen);
+                                      unsigned char* aDigestData, uint32_t aDigestDataLen);
 
   virtual void virtualDestroyNSSReference();
   void destructorSafeDestroyNSSReference();
 
 friend class nsSMimeVerificationJob;
 };
 
 // ===============================================
--- a/mailnews/mime/src/nsCMSSecureMessage.cpp
+++ b/mailnews/mime/src/nsCMSSecureMessage.cpp
@@ -95,17 +95,17 @@ done:
 
 // nsCMSSecureMessage::DecodeCert
 nsresult nsCMSSecureMessage::
 DecodeCert(const char *value, nsIX509Cert ** _retval)
 {
   nsNSSShutDownPreventionLock locker;
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSSecureMessage::DecodeCert\n"));
   nsresult rv = NS_OK;
-  PRInt32 length;
+  int32_t length;
   unsigned char *data = 0;
 
   *_retval = 0;
 
   if (!value) { return NS_ERROR_FAILURE; }
 
   rv = decode(value, &data, &length);
   if (NS_FAILED(rv)) {
@@ -132,17 +132,17 @@ nsresult nsCMSSecureMessage::
 SendMessage(const char *msg, const char *base64Cert, char ** _retval)
 {
   nsNSSShutDownPreventionLock locker;
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSSecureMessage::SendMessage\n"));
   nsresult rv = NS_OK;
   CERTCertificate *cert = 0;
   NSSCMSMessage *cmsMsg = 0;
   unsigned char *certDER = 0;
-  PRInt32 derLen;
+  int32_t derLen;
   NSSCMSEnvelopedData *env;
   NSSCMSContentInfo *cinfo;
   NSSCMSRecipientInfo *rcpt;
   SECItem output;
   PLArenaPool *arena = PORT_NewArena(1024);
   SECStatus s;
   nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();
 
@@ -259,17 +259,17 @@ done:
 nsresult nsCMSSecureMessage::
 ReceiveMessage(const char *msg, char **_retval)
 {
   nsNSSShutDownPreventionLock locker;
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSSecureMessage::ReceiveMessage\n"));
   nsresult rv = NS_OK;
   NSSCMSDecoderContext *dcx;
   unsigned char *der = 0;
-  PRInt32 derLen;
+  int32_t derLen;
   NSSCMSMessage *cmsMsg = 0;
   SECItem *content;
   nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();
 
   /* Step 1. Decode the base64 wrapper */
   rv = decode(msg, &der, &derLen);
   if (NS_FAILED(rv)) {
     PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSSecureMessage::ReceiveMessage - can't base64 decode\n"));
@@ -307,33 +307,33 @@ ReceiveMessage(const char *msg, char **_
 done:
   if (der) free(der);
   if (cmsMsg) NSS_CMSMessage_Destroy(cmsMsg);
 
   return rv;
 }
 
 nsresult nsCMSSecureMessage::
-encode(const unsigned char *data, PRInt32 dataLen, char **_retval)
+encode(const unsigned char *data, int32_t dataLen, char **_retval)
 {
   nsresult rv = NS_OK;
 
   *_retval = PL_Base64Encode((const char *)data, dataLen, NULL);
   if (!*_retval) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; }
 
 loser:
   return rv;
 }
 
 nsresult nsCMSSecureMessage::
-decode(const char *data, unsigned char **result, PRInt32 * _retval)
+decode(const char *data, unsigned char **result, int32_t * _retval)
 {
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("nsCMSSecureMessage::decode\n"));
   nsresult rv = NS_OK;
-  PRUint32 len = PL_strlen(data);
+  uint32_t len = PL_strlen(data);
   int adjust = 0;
 
   /* Compute length adjustment */
   if (data[len-1] == '=') {
     adjust++;
     if (data[len-2] == '=') adjust++;
   }
 
--- a/mailnews/mime/src/nsCMSSecureMessage.h
+++ b/mailnews/mime/src/nsCMSSecureMessage.h
@@ -24,14 +24,14 @@ class nsCMSSecureMessage
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSICMSSECUREMESSAGE
 
   nsCMSSecureMessage();
   virtual ~nsCMSSecureMessage();
 
 private:
-  NS_METHOD encode(const unsigned char *data, PRInt32 dataLen, char **_retval);
-  NS_METHOD decode(const char *data, unsigned char **result, PRInt32 * _retval);
+  NS_METHOD encode(const unsigned char *data, int32_t dataLen, char **_retval);
+  NS_METHOD decode(const char *data, unsigned char **result, int32_t * _retval);
 };
 
 
 #endif /* _NSCMSMESSAGE_H_ */