Bug 1046841 - Convert remaining files in xpcom/{ds,glue,sample}/ to Gecko style. r=froydnj
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Mon, 25 Aug 2014 12:17:28 -0700
changeset 223096 7afb7c612b5af06164e8495b12fa126b071c2a0e
parent 223095 fe4f8a3cdb1991c1e6fba042dcab1fd345ad4357
child 223097 e8e520884505d30ba184c162bb30f15b5210645a
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1046841
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1046841 - Convert remaining files in xpcom/{ds,glue,sample}/ to Gecko style. r=froydnj
xpcom/ds/nsCharSeparatedTokenizer.h
xpcom/ds/nsWhitespaceTokenizer.h
xpcom/glue/standalone/nsXPCOMGlue.cpp
xpcom/glue/standalone/nsXPCOMGlue.h
xpcom/sample/nsSample.cpp
xpcom/sample/nsSample.h
xpcom/sample/nsSampleModule.cpp
xpcom/sample/program/nsTestSample.cpp
--- a/xpcom/ds/nsCharSeparatedTokenizer.h
+++ b/xpcom/ds/nsCharSeparatedTokenizer.h
@@ -31,141 +31,142 @@
  */
 template<typename DependentSubstringType, bool IsWhitespace(char16_t)>
 class nsTCharSeparatedTokenizer
 {
   typedef typename DependentSubstringType::char_type CharType;
   typedef typename DependentSubstringType::substring_type SubstringType;
 
 public:
-    // Flags -- only one for now. If we need more, they should be defined to
-    // be 1 << 1, 1 << 2, etc. (They're masks, and aFlags is a bitfield.)
-    enum {
-        SEPARATOR_OPTIONAL = 1
-    };
+  // Flags -- only one for now. If we need more, they should be defined to
+  // be 1 << 1, 1 << 2, etc. (They're masks, and aFlags is a bitfield.)
+  enum
+  {
+    SEPARATOR_OPTIONAL = 1
+  };
 
-    nsTCharSeparatedTokenizer(const SubstringType& aSource,
-                              CharType aSeparatorChar,
-                              uint32_t aFlags = 0)
-        : mIter(aSource.Data(), aSource.Length()),
-          mEnd(aSource.Data() + aSource.Length(), aSource.Data(),
-               aSource.Length()),
-          mSeparatorChar(aSeparatorChar),
-          mWhitespaceBeforeFirstToken(false),
-          mWhitespaceAfterCurrentToken(false),
-          mSeparatorAfterCurrentToken(false),
-          mSeparatorOptional(aFlags & SEPARATOR_OPTIONAL)
-    {
-        // Skip initial whitespace
-        while (mIter < mEnd && IsWhitespace(*mIter)) {
-            mWhitespaceBeforeFirstToken = true;
-            ++mIter;
-        }
+  nsTCharSeparatedTokenizer(const SubstringType& aSource,
+                            CharType aSeparatorChar,
+                            uint32_t aFlags = 0)
+    : mIter(aSource.Data(), aSource.Length())
+    , mEnd(aSource.Data() + aSource.Length(), aSource.Data(),
+           aSource.Length())
+    , mSeparatorChar(aSeparatorChar)
+    , mWhitespaceBeforeFirstToken(false)
+    , mWhitespaceAfterCurrentToken(false)
+    , mSeparatorAfterCurrentToken(false)
+    , mSeparatorOptional(aFlags & SEPARATOR_OPTIONAL)
+  {
+    // Skip initial whitespace
+    while (mIter < mEnd && IsWhitespace(*mIter)) {
+      mWhitespaceBeforeFirstToken = true;
+      ++mIter;
     }
+  }
+
+  /**
+   * Checks if any more tokens are available.
+   */
+  bool hasMoreTokens() const
+  {
+    MOZ_ASSERT(mIter == mEnd || !IsWhitespace(*mIter),
+               "Should be at beginning of token if there is one");
+
+    return mIter < mEnd;
+  }
+
+  /*
+   * Returns true if there is whitespace prior to the first token.
+   */
+  bool whitespaceBeforeFirstToken() const
+  {
+    return mWhitespaceBeforeFirstToken;
+  }
 
-    /**
-     * Checks if any more tokens are available.
-     */
-    bool hasMoreTokens() const
-    {
-        MOZ_ASSERT(mIter == mEnd || !IsWhitespace(*mIter),
-                   "Should be at beginning of token if there is one");
+  /*
+   * Returns true if there is a separator after the current token.
+   * Useful if you want to check whether the last token has a separator
+   * after it which may not be valid.
+   */
+  bool separatorAfterCurrentToken() const
+  {
+    return mSeparatorAfterCurrentToken;
+  }
 
-        return mIter < mEnd;
-    }
+  /*
+   * Returns true if there is any whitespace after the current token.
+   */
+  bool whitespaceAfterCurrentToken() const
+  {
+    return mWhitespaceAfterCurrentToken;
+  }
 
-    /*
-     * Returns true if there is whitespace prior to the first token.
-     */
-    bool whitespaceBeforeFirstToken() const
-    {
-        return mWhitespaceBeforeFirstToken;
-    }
+  /**
+   * Returns the next token.
+   */
+  const DependentSubstringType nextToken()
+  {
+    mozilla::RangedPtr<const CharType> tokenStart = mIter;
+    mozilla::RangedPtr<const CharType> tokenEnd = mIter;
+
+    MOZ_ASSERT(mIter == mEnd || !IsWhitespace(*mIter),
+               "Should be at beginning of token if there is one");
 
-    /*
-     * Returns true if there is a separator after the current token.
-     * Useful if you want to check whether the last token has a separator
-     * after it which may not be valid.
-     */
-    bool separatorAfterCurrentToken() const
-    {
-        return mSeparatorAfterCurrentToken;
-    }
+    // Search until we hit separator or end (or whitespace, if a separator
+    // isn't required -- see clause with 'break' below).
+    while (mIter < mEnd && *mIter != mSeparatorChar) {
+      // Skip to end of the current word.
+      while (mIter < mEnd &&
+             !IsWhitespace(*mIter) && *mIter != mSeparatorChar) {
+        ++mIter;
+      }
+      tokenEnd = mIter;
 
-    /*
-     * Returns true if there is any whitespace after the current token.
-     */
-    bool whitespaceAfterCurrentToken() const
-    {
-        return mWhitespaceAfterCurrentToken;
+      // Skip whitespace after the current word.
+      mWhitespaceAfterCurrentToken = false;
+      while (mIter < mEnd && IsWhitespace(*mIter)) {
+        mWhitespaceAfterCurrentToken = true;
+        ++mIter;
+      }
+      if (mSeparatorOptional) {
+        // We've hit (and skipped) whitespace, and that's sufficient to end
+        // our token, regardless of whether we've reached a SeparatorChar.
+        break;
+      } // (else, we'll keep looping until we hit mEnd or SeparatorChar)
     }
 
-    /**
-     * Returns the next token.
-     */
-    const DependentSubstringType nextToken()
-    {
-        mozilla::RangedPtr<const CharType> tokenStart = mIter;
-        mozilla::RangedPtr<const CharType> tokenEnd = mIter;
-
-        MOZ_ASSERT(mIter == mEnd || !IsWhitespace(*mIter),
-                   "Should be at beginning of token if there is one");
-
-        // Search until we hit separator or end (or whitespace, if a separator
-        // isn't required -- see clause with 'break' below).
-        while (mIter < mEnd && *mIter != mSeparatorChar) {
-          // Skip to end of the current word.
-          while (mIter < mEnd &&
-                 !IsWhitespace(*mIter) && *mIter != mSeparatorChar) {
-              ++mIter;
-          }
-          tokenEnd = mIter;
+    mSeparatorAfterCurrentToken = (mIter != mEnd &&
+                                   *mIter == mSeparatorChar);
+    MOZ_ASSERT(mSeparatorOptional ||
+               (mSeparatorAfterCurrentToken == (mIter < mEnd)),
+               "If we require a separator and haven't hit the end of "
+               "our string, then we shouldn't have left the loop "
+               "unless we hit a separator");
 
-          // Skip whitespace after the current word.
-          mWhitespaceAfterCurrentToken = false;
-          while (mIter < mEnd && IsWhitespace(*mIter)) {
-              mWhitespaceAfterCurrentToken = true;
-              ++mIter;
-          }
-          if (mSeparatorOptional) {
-            // We've hit (and skipped) whitespace, and that's sufficient to end
-            // our token, regardless of whether we've reached a SeparatorChar.
-            break;
-          } // (else, we'll keep looping until we hit mEnd or SeparatorChar)
-        }
+    // Skip separator (and any whitespace after it), if we're at one.
+    if (mSeparatorAfterCurrentToken) {
+      ++mIter;
 
-        mSeparatorAfterCurrentToken = (mIter != mEnd &&
-                                       *mIter == mSeparatorChar);
-        MOZ_ASSERT(mSeparatorOptional ||
-                   (mSeparatorAfterCurrentToken == (mIter < mEnd)),
-                   "If we require a separator and haven't hit the end of "
-                   "our string, then we shouldn't have left the loop "
-                   "unless we hit a separator");
-
-        // Skip separator (and any whitespace after it), if we're at one.
-        if (mSeparatorAfterCurrentToken) {
-            ++mIter;
-
-            while (mIter < mEnd && IsWhitespace(*mIter)) {
-                mWhitespaceAfterCurrentToken = true;
-                ++mIter;
-            }
-        }
-
-        return Substring(tokenStart.get(), tokenEnd.get());
+      while (mIter < mEnd && IsWhitespace(*mIter)) {
+        mWhitespaceAfterCurrentToken = true;
+        ++mIter;
+      }
     }
 
+    return Substring(tokenStart.get(), tokenEnd.get());
+  }
+
 private:
-    mozilla::RangedPtr<const CharType> mIter;
-    const mozilla::RangedPtr<const CharType> mEnd;
-    CharType mSeparatorChar;
-    bool mWhitespaceBeforeFirstToken;
-    bool mWhitespaceAfterCurrentToken;
-    bool mSeparatorAfterCurrentToken;
-    bool mSeparatorOptional;
+  mozilla::RangedPtr<const CharType> mIter;
+  const mozilla::RangedPtr<const CharType> mEnd;
+  CharType mSeparatorChar;
+  bool mWhitespaceBeforeFirstToken;
+  bool mWhitespaceAfterCurrentToken;
+  bool mSeparatorAfterCurrentToken;
+  bool mSeparatorOptional;
 };
 
 template<bool IsWhitespace(char16_t) = NS_IsAsciiWhitespace>
 class nsCharSeparatedTokenizerTemplate
   : public nsTCharSeparatedTokenizer<nsDependentSubstring, IsWhitespace>
 {
 public:
   nsCharSeparatedTokenizerTemplate(const nsSubstring& aSource,
--- a/xpcom/ds/nsWhitespaceTokenizer.h
+++ b/xpcom/ds/nsWhitespaceTokenizer.h
@@ -12,77 +12,77 @@
 
 template<typename DependentSubstringType, bool IsWhitespace(char16_t)>
 class nsTWhitespaceTokenizer
 {
   typedef typename DependentSubstringType::char_type CharType;
   typedef typename DependentSubstringType::substring_type SubstringType;
 
 public:
-    explicit nsTWhitespaceTokenizer(const SubstringType& aSource)
-        : mIter(aSource.Data(), aSource.Length()),
-          mEnd(aSource.Data() + aSource.Length(), aSource.Data(),
-               aSource.Length()),
-          mWhitespaceBeforeFirstToken(false),
-          mWhitespaceAfterCurrentToken(false)
-    {
-        while (mIter < mEnd && IsWhitespace(*mIter)) {
-            mWhitespaceBeforeFirstToken = true;
-            ++mIter;
-        }
-    }
-
-    /**
-     * Checks if any more tokens are available.
-     */
-    bool hasMoreTokens() const
-    {
-        return mIter < mEnd;
-    }
-
-    /*
-     * Returns true if there is whitespace prior to the first token.
-     */
-    bool whitespaceBeforeFirstToken() const
-    {
-        return mWhitespaceBeforeFirstToken;
+  explicit nsTWhitespaceTokenizer(const SubstringType& aSource)
+    : mIter(aSource.Data(), aSource.Length())
+    , mEnd(aSource.Data() + aSource.Length(), aSource.Data(),
+           aSource.Length())
+    , mWhitespaceBeforeFirstToken(false)
+    , mWhitespaceAfterCurrentToken(false)
+  {
+    while (mIter < mEnd && IsWhitespace(*mIter)) {
+      mWhitespaceBeforeFirstToken = true;
+      ++mIter;
     }
+  }
 
-    /*
-     * Returns true if there is any whitespace after the current token.
-     * This is always true unless we're reading the last token.
-     */
-    bool whitespaceAfterCurrentToken() const
-    {
-        return mWhitespaceAfterCurrentToken;
-    }
+  /**
+   * Checks if any more tokens are available.
+   */
+  bool hasMoreTokens() const
+  {
+    return mIter < mEnd;
+  }
+
+  /*
+   * Returns true if there is whitespace prior to the first token.
+   */
+  bool whitespaceBeforeFirstToken() const
+  {
+    return mWhitespaceBeforeFirstToken;
+  }
 
-    /**
-     * Returns the next token.
-     */
-    const DependentSubstringType nextToken()
-    {
-        const mozilla::RangedPtr<const CharType> tokenStart = mIter;
-        while (mIter < mEnd && !IsWhitespace(*mIter)) {
-            ++mIter;
-        }
-        const mozilla::RangedPtr<const CharType> tokenEnd = mIter;
-        mWhitespaceAfterCurrentToken = false;
-        while (mIter < mEnd && IsWhitespace(*mIter)) {
-            mWhitespaceAfterCurrentToken = true;
-            ++mIter;
-        }
-        return Substring(tokenStart.get(), tokenEnd.get());
+  /*
+   * Returns true if there is any whitespace after the current token.
+   * This is always true unless we're reading the last token.
+   */
+  bool whitespaceAfterCurrentToken() const
+  {
+    return mWhitespaceAfterCurrentToken;
+  }
+
+  /**
+   * Returns the next token.
+   */
+  const DependentSubstringType nextToken()
+  {
+    const mozilla::RangedPtr<const CharType> tokenStart = mIter;
+    while (mIter < mEnd && !IsWhitespace(*mIter)) {
+      ++mIter;
     }
+    const mozilla::RangedPtr<const CharType> tokenEnd = mIter;
+    mWhitespaceAfterCurrentToken = false;
+    while (mIter < mEnd && IsWhitespace(*mIter)) {
+      mWhitespaceAfterCurrentToken = true;
+      ++mIter;
+    }
+    return Substring(tokenStart.get(), tokenEnd.get());
+  }
 
 private:
-    mozilla::RangedPtr<const CharType> mIter;
-    const mozilla::RangedPtr<const CharType> mEnd;
-    bool mWhitespaceBeforeFirstToken;
-    bool mWhitespaceAfterCurrentToken;
+  mozilla::RangedPtr<const CharType> mIter;
+  const mozilla::RangedPtr<const CharType> mEnd;
+  bool mWhitespaceBeforeFirstToken;
+  bool mWhitespaceAfterCurrentToken;
 };
 
 template<bool IsWhitespace(char16_t) = NS_IsAsciiWhitespace>
 class nsWhitespaceTokenizerTemplate
   : public nsTWhitespaceTokenizer<nsDependentSubstring, IsWhitespace>
 {
 public:
   explicit nsWhitespaceTokenizerTemplate(const nsSubstring& aSource)
--- a/xpcom/glue/standalone/nsXPCOMGlue.cpp
+++ b/xpcom/glue/standalone/nsXPCOMGlue.cpp
@@ -42,105 +42,107 @@ static bool do_preload = false;
 #include <mbstring.h>
 #define snprintf _snprintf
 
 typedef HINSTANCE LibHandleType;
 
 static LibHandleType
 GetLibHandle(pathstr_t aDependentLib)
 {
-    LibHandleType libHandle =
-        LoadLibraryExW(aDependentLib, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
+  LibHandleType libHandle =
+    LoadLibraryExW(aDependentLib, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
 
-    if (!libHandle) {
-        DWORD err = GetLastError();
+  if (!libHandle) {
+    DWORD err = GetLastError();
 #ifdef DEBUG
-        LPVOID lpMsgBuf;
-        FormatMessage(
-                      FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                      FORMAT_MESSAGE_FROM_SYSTEM |
-                      FORMAT_MESSAGE_IGNORE_INSERTS,
-                      nullptr,
-                      err,
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      (LPTSTR) &lpMsgBuf,
-                      0,
-                      nullptr
-                      );
-        wprintf(L"Error loading %ls: %s\n", aDependentLib, lpMsgBuf);
-        LocalFree(lpMsgBuf);
+    LPVOID lpMsgBuf;
+    FormatMessage(
+      FORMAT_MESSAGE_ALLOCATE_BUFFER |
+      FORMAT_MESSAGE_FROM_SYSTEM |
+      FORMAT_MESSAGE_IGNORE_INSERTS,
+      nullptr,
+      err,
+      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+      (LPTSTR)&lpMsgBuf,
+      0,
+      nullptr
+    );
+    wprintf(L"Error loading %ls: %s\n", aDependentLib, lpMsgBuf);
+    LocalFree(lpMsgBuf);
 #endif
-    }
+  }
 
-    return libHandle;
+  return libHandle;
 }
 
 static NSFuncPtr
-GetSymbol(LibHandleType aLibHandle, const char *aSymbol)
+GetSymbol(LibHandleType aLibHandle, const char* aSymbol)
 {
-    return (NSFuncPtr) GetProcAddress(aLibHandle, aSymbol);
+  return (NSFuncPtr)GetProcAddress(aLibHandle, aSymbol);
 }
 
 static void
 CloseLibHandle(LibHandleType aLibHandle)
 {
-    FreeLibrary(aLibHandle);
+  FreeLibrary(aLibHandle);
 }
 
 #elif defined(XP_MACOSX)
 #include <mach-o/dyld.h>
 
-typedef const mach_header *LibHandleType;
+typedef const mach_header* LibHandleType;
 
 static LibHandleType
 GetLibHandle(pathstr_t aDependentLib)
 {
-    LibHandleType libHandle = NSAddImage(aDependentLib,
-                                         NSADDIMAGE_OPTION_RETURN_ON_ERROR |
-                                         NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME);
-    if (!libHandle) {
-        NSLinkEditErrors linkEditError;
-        int errorNum;
-        const char *errorString;
-        const char *fileName;
-        NSLinkEditError(&linkEditError, &errorNum, &fileName, &errorString);
-        fprintf(stderr, "XPCOMGlueLoad error %d:%d for file %s:\n%s\n",
-                linkEditError, errorNum, fileName, errorString);
-    }
-    return libHandle;
+  LibHandleType libHandle = NSAddImage(aDependentLib,
+                                       NSADDIMAGE_OPTION_RETURN_ON_ERROR |
+                                       NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME);
+  if (!libHandle) {
+    NSLinkEditErrors linkEditError;
+    int errorNum;
+    const char* errorString;
+    const char* fileName;
+    NSLinkEditError(&linkEditError, &errorNum, &fileName, &errorString);
+    fprintf(stderr, "XPCOMGlueLoad error %d:%d for file %s:\n%s\n",
+            linkEditError, errorNum, fileName, errorString);
+  }
+  return libHandle;
 }
 
 static NSFuncPtr
-GetSymbol(LibHandleType aLibHandle, const char *aSymbol)
+GetSymbol(LibHandleType aLibHandle, const char* aSymbol)
 {
-    // Try to use |NSLookupSymbolInImage| since it is faster than searching
-    // the global symbol table.  If we couldn't get a mach_header pointer
-    // for the XPCOM dylib, then use |NSLookupAndBindSymbol| to search the
-    // global symbol table (this shouldn't normally happen, unless the user
-    // has called XPCOMGlueStartup(".") and relies on libxpcom.dylib
-    // already being loaded).
-    NSSymbol sym = nullptr;
-    if (aLibHandle) {
-        sym = NSLookupSymbolInImage(aLibHandle, aSymbol,
-                                 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
-                                 NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
-    } else {
-        if (NSIsSymbolNameDefined(aSymbol))
-            sym = NSLookupAndBindSymbol(aSymbol);
+  // Try to use |NSLookupSymbolInImage| since it is faster than searching
+  // the global symbol table.  If we couldn't get a mach_header pointer
+  // for the XPCOM dylib, then use |NSLookupAndBindSymbol| to search the
+  // global symbol table (this shouldn't normally happen, unless the user
+  // has called XPCOMGlueStartup(".") and relies on libxpcom.dylib
+  // already being loaded).
+  NSSymbol sym = nullptr;
+  if (aLibHandle) {
+    sym = NSLookupSymbolInImage(aLibHandle, aSymbol,
+                                NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
+                                NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+  } else {
+    if (NSIsSymbolNameDefined(aSymbol)) {
+      sym = NSLookupAndBindSymbol(aSymbol);
     }
-    if (!sym)
-        return nullptr;
+  }
+  if (!sym) {
+    return nullptr;
+  }
 
-    return (NSFuncPtr) NSAddressOfSymbol(sym);
+  return (NSFuncPtr)NSAddressOfSymbol(sym);
 }
 
 static void
 CloseLibHandle(LibHandleType aLibHandle)
 {
-    // we cannot unload dylibs on OS X
+  // we cannot unload dylibs on OS X
 }
 
 #else
 #include <dlfcn.h>
 
 #if defined(MOZ_LINKER) && !defined(ANDROID)
 extern "C" {
 NS_HIDDEN __typeof(dlopen) __wrap_dlopen;
@@ -167,762 +169,824 @@ static __ptr_t (*_malloc)(size_t) = __li
 static __ptr_t (*_calloc)(size_t, size_t) = __libc_calloc;
 static __ptr_t (*_realloc)(__ptr_t, size_t) = __libc_realloc;
 static void (*_free)(__ptr_t) = __libc_free;
 static __ptr_t (*_memalign)(size_t, size_t) = __libc_memalign;
 static __ptr_t (*_valloc)(size_t) = __libc_valloc;
 
 NS_EXPORT_(__ptr_t) malloc(size_t size)
 {
-    return _malloc(size);
+  return _malloc(size);
 }
 
 NS_EXPORT_(__ptr_t) calloc(size_t nmemb, size_t size)
 {
-    return _calloc(nmemb, size);
+  return _calloc(nmemb, size);
 }
 
 NS_EXPORT_(__ptr_t) realloc(__ptr_t ptr, size_t size)
 {
-    return _realloc(ptr, size);
+  return _realloc(ptr, size);
 }
 
 NS_EXPORT_(void) free(__ptr_t ptr)
 {
-    _free(ptr);
+  _free(ptr);
 }
 
 NS_EXPORT_(void) cfree(__ptr_t ptr)
 {
-    _free(ptr);
+  _free(ptr);
 }
 
 NS_EXPORT_(__ptr_t) memalign(size_t boundary, size_t size)
 {
-    return _memalign(boundary, size);
+  return _memalign(boundary, size);
 }
 
 NS_EXPORT_(int)
-posix_memalign(void **memptr, size_t alignment, size_t size)
+posix_memalign(void** memptr, size_t alignment, size_t size)
 {
-    __ptr_t ptr = _memalign(alignment, size);
-    if (!ptr)
-        return ENOMEM;
-    *memptr = ptr;
-    return 0;
+  __ptr_t ptr = _memalign(alignment, size);
+  if (!ptr) {
+    return ENOMEM;
+  }
+  *memptr = ptr;
+  return 0;
 }
 
 NS_EXPORT_(__ptr_t) valloc(size_t size)
 {
-    return _valloc(size);
+  return _valloc(size);
 }
 #endif /* NS_TRACE_MALLOC */
 
-typedef void *LibHandleType;
+typedef void* LibHandleType;
 
 static LibHandleType
 GetLibHandle(pathstr_t aDependentLib)
 {
-    LibHandleType libHandle = dlopen(aDependentLib, RTLD_GLOBAL | RTLD_LAZY);
-    if (!libHandle) {
-        fprintf(stderr, "XPCOMGlueLoad error for file %s:\n%s\n", aDependentLib, dlerror());
-    }
-    return libHandle;
+  LibHandleType libHandle = dlopen(aDependentLib, RTLD_GLOBAL | RTLD_LAZY);
+  if (!libHandle) {
+    fprintf(stderr, "XPCOMGlueLoad error for file %s:\n%s\n", aDependentLib,
+            dlerror());
+  }
+  return libHandle;
 }
 
 static NSFuncPtr
-GetSymbol(LibHandleType aLibHandle, const char *aSymbol)
+GetSymbol(LibHandleType aLibHandle, const char* aSymbol)
 {
-    return (NSFuncPtr) dlsym(aLibHandle, aSymbol);
+  return (NSFuncPtr)dlsym(aLibHandle, aSymbol);
 }
 
 static void
 CloseLibHandle(LibHandleType aLibHandle)
 {
-    dlclose(aLibHandle);
+  dlclose(aLibHandle);
 }
 #endif
 
 struct DependentLib
 {
-    LibHandleType libHandle;
-    DependentLib *next;
+  LibHandleType libHandle;
+  DependentLib* next;
 };
 
-static DependentLib *sTop;
+static DependentLib* sTop;
 
 static void
-AppendDependentLib(LibHandleType libHandle)
+AppendDependentLib(LibHandleType aLibHandle)
 {
-    DependentLib *d = new DependentLib;
-    if (!d)
-        return;
+  DependentLib* d = new DependentLib;
+  if (!d) {
+    return;
+  }
 
-    d->next = sTop;
-    d->libHandle = libHandle;
+  d->next = sTop;
+  d->libHandle = aLibHandle;
 
-    sTop = d;
+  sTop = d;
 }
 
 static bool
-ReadDependentCB(pathstr_t aDependentLib, bool do_preload)
+ReadDependentCB(pathstr_t aDependentLib, bool aDoPreload)
 {
-    if (do_preload) {
-        ReadAheadLib(aDependentLib);
-    }
-    LibHandleType libHandle = GetLibHandle(aDependentLib);
-    if (libHandle) {
-        AppendDependentLib(libHandle);
-    }
+  if (aDoPreload) {
+    ReadAheadLib(aDependentLib);
+  }
+  LibHandleType libHandle = GetLibHandle(aDependentLib);
+  if (libHandle) {
+    AppendDependentLib(libHandle);
+  }
 
-    return libHandle;
+  return libHandle;
 }
 
 #ifdef XP_WIN
 static bool
-ReadDependentCB(const char *aDependentLib, bool do_preload)
+ReadDependentCB(const char* aDependentLib, bool do_preload)
 {
-    wchar_t wideDependentLib[MAX_PATH];
-    MultiByteToWideChar(CP_UTF8, 0, aDependentLib, -1, wideDependentLib, MAX_PATH);
-    return ReadDependentCB(wideDependentLib, do_preload);
+  wchar_t wideDependentLib[MAX_PATH];
+  MultiByteToWideChar(CP_UTF8, 0, aDependentLib, -1, wideDependentLib, MAX_PATH);
+  return ReadDependentCB(wideDependentLib, do_preload);
 }
 
-inline FILE *TS_tfopen (const char *path, const wchar_t *mode)
+inline FILE*
+TS_tfopen(const char* path, const wchar_t* mode)
 {
-    wchar_t wPath[MAX_PATH];
-    MultiByteToWideChar(CP_UTF8, 0, path, -1, wPath, MAX_PATH);
-    return _wfopen(wPath, mode);
+  wchar_t wPath[MAX_PATH];
+  MultiByteToWideChar(CP_UTF8, 0, path, -1, wPath, MAX_PATH);
+  return _wfopen(wPath, mode);
 }
 #else
-inline FILE *TS_tfopen (const char *path, const char *mode)
+inline FILE*
+TS_tfopen(const char* aPath, const char* aMode)
 {
-    return fopen(path, mode);
+  return fopen(aPath, aMode);
 }
 #endif
 
 /* RAII wrapper for FILE descriptors */
 struct ScopedCloseFileTraits
 {
-    typedef FILE *type;
-    static type empty() { return nullptr; }
-    static void release(type f) {
-        if (f) {
-            fclose(f);
-        }
+  typedef FILE* type;
+  static type empty() { return nullptr; }
+  static void release(type aFile)
+  {
+    if (aFile) {
+      fclose(aFile);
     }
+  }
 };
 typedef Scoped<ScopedCloseFileTraits> ScopedCloseFile;
 
 static void
 XPCOMGlueUnload()
 {
 #if !defined(XP_WIN) && !defined(XP_MACOSX) && defined(NS_TRACE_MALLOC)
-    if (sTop) {
-        _malloc = __libc_malloc;
-        _calloc = __libc_calloc;
-        _realloc = __libc_realloc;
-        _free = __libc_free;
-        _memalign = __libc_memalign;
-        _valloc = __libc_valloc;
-    }
+  if (sTop) {
+    _malloc = __libc_malloc;
+    _calloc = __libc_calloc;
+    _realloc = __libc_realloc;
+    _free = __libc_free;
+    _memalign = __libc_memalign;
+    _valloc = __libc_valloc;
+  }
 #endif
 
-    while (sTop) {
-        CloseLibHandle(sTop->libHandle);
+  while (sTop) {
+    CloseLibHandle(sTop->libHandle);
 
-        DependentLib *temp = sTop;
-        sTop = sTop->next;
+    DependentLib* temp = sTop;
+    sTop = sTop->next;
 
-        delete temp;
-    }
+    delete temp;
+  }
 }
 
 #if defined(XP_WIN)
 // like strpbrk but finds the *last* char, not the first
 static const char*
-ns_strrpbrk(const char *string, const char *strCharSet)
+ns_strrpbrk(const char* string, const char* strCharSet)
 {
-    const char *found = nullptr;
-    for (; *string; ++string) {
-        for (const char *search = strCharSet; *search; ++search) {
-            if (*search == *string) {
-                found = string;
-                // Since we're looking for the last char, we save "found"
-                // until we're at the end of the string.
-            }
-        }
+  const char* found = nullptr;
+  for (; *string; ++string) {
+    for (const char* search = strCharSet; *search; ++search) {
+      if (*search == *string) {
+        found = string;
+        // Since we're looking for the last char, we save "found"
+        // until we're at the end of the string.
+      }
     }
+  }
 
-    return found;
+  return found;
 }
 #endif
 
 static GetFrozenFunctionsFunc
-XPCOMGlueLoad(const char *xpcomFile)
+XPCOMGlueLoad(const char* aXPCOMFile)
 {
-    char xpcomDir[MAXPATHLEN];
+  char xpcomDir[MAXPATHLEN];
 #if defined(XP_WIN)
-    const char *lastSlash = ns_strrpbrk(xpcomFile, "/\\");
+  const char* lastSlash = ns_strrpbrk(aXPCOMFile, "/\\");
 #else
-    const char *lastSlash = strrchr(xpcomFile, '/');
+  const char* lastSlash = strrchr(aXPCOMFile, '/');
 #endif
-    char *cursor;
-    if (lastSlash) {
-        size_t len = size_t(lastSlash - xpcomFile);
+  char* cursor;
+  if (lastSlash) {
+    size_t len = size_t(lastSlash - aXPCOMFile);
 
-        if (len > MAXPATHLEN - sizeof(XPCOM_FILE_PATH_SEPARATOR
-                                      XPCOM_DEPENDENT_LIBS_LIST)) {
-            return nullptr;
-        }
-        memcpy(xpcomDir, xpcomFile, len);
-        strcpy(xpcomDir + len, XPCOM_FILE_PATH_SEPARATOR
-                               XPCOM_DEPENDENT_LIBS_LIST);
-        cursor = xpcomDir + len + 1;
-    } else {
-        strcpy(xpcomDir, XPCOM_DEPENDENT_LIBS_LIST);
-        cursor = xpcomDir;
+    if (len > MAXPATHLEN - sizeof(XPCOM_FILE_PATH_SEPARATOR
+                                  XPCOM_DEPENDENT_LIBS_LIST)) {
+      return nullptr;
     }
+    memcpy(xpcomDir, aXPCOMFile, len);
+    strcpy(xpcomDir + len, XPCOM_FILE_PATH_SEPARATOR
+           XPCOM_DEPENDENT_LIBS_LIST);
+    cursor = xpcomDir + len + 1;
+  } else {
+    strcpy(xpcomDir, XPCOM_DEPENDENT_LIBS_LIST);
+    cursor = xpcomDir;
+  }
 
-    if (getenv("MOZ_RUN_GTEST")) {
-        strcat(xpcomDir, ".gtest");
-    }
+  if (getenv("MOZ_RUN_GTEST")) {
+    strcat(xpcomDir, ".gtest");
+  }
 
-    ScopedCloseFile flist;
-    flist = TS_tfopen(xpcomDir, READ_TEXTMODE);
-    if (!flist) {
-        return nullptr;
+  ScopedCloseFile flist;
+  flist = TS_tfopen(xpcomDir, READ_TEXTMODE);
+  if (!flist) {
+    return nullptr;
+  }
+
+  *cursor = '\0';
+
+  char buffer[MAXPATHLEN];
+
+  while (fgets(buffer, sizeof(buffer), flist)) {
+    int l = strlen(buffer);
+
+    // ignore empty lines and comments
+    if (l == 0 || *buffer == '#') {
+      continue;
     }
 
-    *cursor = '\0';
-
-    char buffer[MAXPATHLEN];
-
-    while (fgets(buffer, sizeof(buffer), flist)) {
-        int l = strlen(buffer);
-
-        // ignore empty lines and comments
-        if (l == 0 || *buffer == '#') {
-            continue;
-        }
+    // cut the trailing newline, if present
+    if (buffer[l - 1] == '\n') {
+      buffer[l - 1] = '\0';
+    }
 
-        // cut the trailing newline, if present
-        if (buffer[l - 1] == '\n')
-            buffer[l - 1] = '\0';
-
-        if (l + size_t(cursor - xpcomDir) > MAXPATHLEN) {
-            return nullptr;
-        }
-
-        strcpy(cursor, buffer);
-        if (!ReadDependentCB(xpcomDir, do_preload)) {
-            XPCOMGlueUnload();
-            return nullptr;
-        }
+    if (l + size_t(cursor - xpcomDir) > MAXPATHLEN) {
+      return nullptr;
     }
 
-    GetFrozenFunctionsFunc sym =
-        (GetFrozenFunctionsFunc) GetSymbol(sTop->libHandle, LEADING_UNDERSCORE "NS_GetFrozenFunctions");
+    strcpy(cursor, buffer);
+    if (!ReadDependentCB(xpcomDir, do_preload)) {
+      XPCOMGlueUnload();
+      return nullptr;
+    }
+  }
 
-    if (!sym) { // No symbol found.
-        XPCOMGlueUnload();
-        return nullptr;
-    }
+  GetFrozenFunctionsFunc sym =
+    (GetFrozenFunctionsFunc)GetSymbol(sTop->libHandle,
+                                      LEADING_UNDERSCORE "NS_GetFrozenFunctions");
+
+  if (!sym) { // No symbol found.
+    XPCOMGlueUnload();
+    return nullptr;
+  }
 
 #if !defined(XP_WIN) && !defined(XP_MACOSX) && defined(NS_TRACE_MALLOC)
-    _malloc = (__ptr_t(*)(size_t)) GetSymbol(sTop->libHandle, "malloc");
-    _calloc = (__ptr_t(*)(size_t, size_t)) GetSymbol(sTop->libHandle, "calloc");
-    _realloc = (__ptr_t(*)(__ptr_t, size_t)) GetSymbol(sTop->libHandle, "realloc");
-    _free = (void(*)(__ptr_t)) GetSymbol(sTop->libHandle, "free");
-    _memalign = (__ptr_t(*)(size_t, size_t)) GetSymbol(sTop->libHandle, "memalign");
-    _valloc = (__ptr_t(*)(size_t)) GetSymbol(sTop->libHandle, "valloc");
+  _malloc = (__ptr_t(*)(size_t)) GetSymbol(sTop->libHandle, "malloc");
+  _calloc = (__ptr_t(*)(size_t, size_t)) GetSymbol(sTop->libHandle, "calloc");
+  _realloc = (__ptr_t(*)(__ptr_t, size_t)) GetSymbol(sTop->libHandle, "realloc");
+  _free = (void(*)(__ptr_t)) GetSymbol(sTop->libHandle, "free");
+  _memalign = (__ptr_t(*)(size_t, size_t)) GetSymbol(sTop->libHandle, "memalign");
+  _valloc = (__ptr_t(*)(size_t)) GetSymbol(sTop->libHandle, "valloc");
 #endif
 
-    return sym;
+  return sym;
 }
 
 nsresult
-XPCOMGlueLoadXULFunctions(const nsDynamicFunctionLoad *symbols)
+XPCOMGlueLoadXULFunctions(const nsDynamicFunctionLoad* aSymbols)
 {
-    // We don't null-check sXULLibHandle because this might work even
-    // if it is null (same as RTLD_DEFAULT)
+  // We don't null-check sXULLibHandle because this might work even
+  // if it is null (same as RTLD_DEFAULT)
 
-    nsresult rv = NS_OK;
-    while (symbols->functionName) {
-        char buffer[512];
-        snprintf(buffer, sizeof(buffer),
-                 LEADING_UNDERSCORE "%s", symbols->functionName);
+  nsresult rv = NS_OK;
+  while (aSymbols->functionName) {
+    char buffer[512];
+    snprintf(buffer, sizeof(buffer),
+             LEADING_UNDERSCORE "%s", aSymbols->functionName);
 
-        *symbols->function = (NSFuncPtr) GetSymbol(sTop->libHandle, buffer);
-        if (!*symbols->function)
-            rv = NS_ERROR_LOSS_OF_SIGNIFICANT_DATA;
+    *aSymbols->function = (NSFuncPtr)GetSymbol(sTop->libHandle, buffer);
+    if (!*aSymbols->function) {
+      rv = NS_ERROR_LOSS_OF_SIGNIFICANT_DATA;
+    }
 
-        ++symbols;
-    }
-    return rv;
+    ++aSymbols;
+  }
+  return rv;
 }
 
-void XPCOMGlueEnablePreload()
+void
+XPCOMGlueEnablePreload()
 {
-    do_preload = true;
+  do_preload = true;
 }
 
-nsresult XPCOMGlueStartup(const char* xpcomFile)
+nsresult
+XPCOMGlueStartup(const char* aXPCOMFile)
 {
-    xpcomFunctions.version = XPCOM_GLUE_VERSION;
-    xpcomFunctions.size    = sizeof(XPCOMFunctions);
+  xpcomFunctions.version = XPCOM_GLUE_VERSION;
+  xpcomFunctions.size    = sizeof(XPCOMFunctions);
 
-    if (!xpcomFile)
-        xpcomFile = XPCOM_DLL;
+  if (!aXPCOMFile) {
+    aXPCOMFile = XPCOM_DLL;
+  }
 
-    GetFrozenFunctionsFunc func = XPCOMGlueLoad(xpcomFile);
-    if (!func)
-        return NS_ERROR_NOT_AVAILABLE;
+  GetFrozenFunctionsFunc func = XPCOMGlueLoad(aXPCOMFile);
+  if (!func) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
 
-    nsresult rv = (*func)(&xpcomFunctions, nullptr);
-    if (NS_FAILED(rv)) {
-        XPCOMGlueUnload();
-        return rv;
-    }
+  nsresult rv = (*func)(&xpcomFunctions, nullptr);
+  if (NS_FAILED(rv)) {
+    XPCOMGlueUnload();
+    return rv;
+  }
 
-    return NS_OK;
+  return NS_OK;
 }
 
 XPCOM_API(nsresult)
-NS_InitXPCOM2(nsIServiceManager* *result, 
-              nsIFile* binDirectory,
-              nsIDirectoryServiceProvider* appFileLocationProvider)
+NS_InitXPCOM2(nsIServiceManager** aResult,
+              nsIFile* aBinDirectory,
+              nsIDirectoryServiceProvider* aAppFileLocationProvider)
 {
-    if (!xpcomFunctions.init)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.init(result, binDirectory, appFileLocationProvider);
+  if (!xpcomFunctions.init) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.init(aResult, aBinDirectory, aAppFileLocationProvider);
 }
 
 XPCOM_API(nsresult)
-NS_ShutdownXPCOM(nsIServiceManager* servMgr)
+NS_ShutdownXPCOM(nsIServiceManager* aServMgr)
 {
-    if (!xpcomFunctions.shutdown)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.shutdown(servMgr);
+  if (!xpcomFunctions.shutdown) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.shutdown(aServMgr);
 }
 
 XPCOM_API(nsresult)
-NS_GetServiceManager(nsIServiceManager* *result)
+NS_GetServiceManager(nsIServiceManager** aResult)
 {
-    if (!xpcomFunctions.getServiceManager)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.getServiceManager(result);
+  if (!xpcomFunctions.getServiceManager) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.getServiceManager(aResult);
 }
 
 XPCOM_API(nsresult)
-NS_GetComponentManager(nsIComponentManager* *result)
+NS_GetComponentManager(nsIComponentManager** aResult)
 {
-    if (!xpcomFunctions.getComponentManager)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.getComponentManager(result);
+  if (!xpcomFunctions.getComponentManager) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.getComponentManager(aResult);
 }
 
 XPCOM_API(nsresult)
-NS_GetComponentRegistrar(nsIComponentRegistrar* *result)
+NS_GetComponentRegistrar(nsIComponentRegistrar** aResult)
 {
-    if (!xpcomFunctions.getComponentRegistrar)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.getComponentRegistrar(result);
+  if (!xpcomFunctions.getComponentRegistrar) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.getComponentRegistrar(aResult);
 }
 
 XPCOM_API(nsresult)
-NS_GetMemoryManager(nsIMemory* *result)
+NS_GetMemoryManager(nsIMemory** aResult)
 {
-    if (!xpcomFunctions.getMemoryManager)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.getMemoryManager(result);
+  if (!xpcomFunctions.getMemoryManager) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.getMemoryManager(aResult);
 }
 
 XPCOM_API(nsresult)
-NS_NewLocalFile(const nsAString &path, bool followLinks, nsIFile* *result)
+NS_NewLocalFile(const nsAString& aPath, bool aFollowLinks, nsIFile** aResult)
 {
-    if (!xpcomFunctions.newLocalFile)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.newLocalFile(path, followLinks, result);
+  if (!xpcomFunctions.newLocalFile) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.newLocalFile(aPath, aFollowLinks, aResult);
 }
 
 XPCOM_API(nsresult)
-NS_NewNativeLocalFile(const nsACString &path, bool followLinks, nsIFile* *result)
+NS_NewNativeLocalFile(const nsACString& aPath, bool aFollowLinks,
+                      nsIFile** aResult)
 {
-    if (!xpcomFunctions.newNativeLocalFile)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.newNativeLocalFile(path, followLinks, result);
+  if (!xpcomFunctions.newNativeLocalFile) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.newNativeLocalFile(aPath, aFollowLinks, aResult);
 }
 
 XPCOM_API(nsresult)
-NS_GetDebug(nsIDebug* *result)
+NS_GetDebug(nsIDebug** aResult)
 {
-    if (!xpcomFunctions.getDebug)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.getDebug(result);
+  if (!xpcomFunctions.getDebug) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.getDebug(aResult);
 }
 
 
 XPCOM_API(nsresult)
-NS_StringContainerInit(nsStringContainer &aStr)
+NS_StringContainerInit(nsStringContainer& aStr)
 {
-    if (!xpcomFunctions.stringContainerInit)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.stringContainerInit(aStr);
+  if (!xpcomFunctions.stringContainerInit) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.stringContainerInit(aStr);
 }
 
 XPCOM_API(nsresult)
-NS_StringContainerInit2(nsStringContainer &aStr,
-                        const char16_t   *aData,
-                        uint32_t           aDataLength,
-                        uint32_t           aFlags)
+NS_StringContainerInit2(nsStringContainer& aStr, const char16_t* aData,
+                        uint32_t aDataLength, uint32_t aFlags)
 {
-    if (!xpcomFunctions.stringContainerInit2)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.stringContainerInit2(aStr, aData, aDataLength, aFlags);
+  if (!xpcomFunctions.stringContainerInit2) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.stringContainerInit2(aStr, aData, aDataLength, aFlags);
 }
 
 XPCOM_API(void)
-NS_StringContainerFinish(nsStringContainer &aStr)
+NS_StringContainerFinish(nsStringContainer& aStr)
 {
-    if (xpcomFunctions.stringContainerFinish)
-        xpcomFunctions.stringContainerFinish(aStr);
+  if (xpcomFunctions.stringContainerFinish) {
+    xpcomFunctions.stringContainerFinish(aStr);
+  }
 }
 
 XPCOM_API(uint32_t)
-NS_StringGetData(const nsAString &aStr, const char16_t **aBuf, bool *aTerm)
+NS_StringGetData(const nsAString& aStr, const char16_t** aBuf, bool* aTerm)
 {
-    if (!xpcomFunctions.stringGetData) {
-        *aBuf = nullptr;
-        return 0;
-    }
-    return xpcomFunctions.stringGetData(aStr, aBuf, aTerm);
+  if (!xpcomFunctions.stringGetData) {
+    *aBuf = nullptr;
+    return 0;
+  }
+  return xpcomFunctions.stringGetData(aStr, aBuf, aTerm);
 }
 
 XPCOM_API(uint32_t)
-NS_StringGetMutableData(nsAString &aStr, uint32_t aLen, char16_t **aBuf)
+NS_StringGetMutableData(nsAString& aStr, uint32_t aLen, char16_t** aBuf)
 {
-    if (!xpcomFunctions.stringGetMutableData) {
-        *aBuf = nullptr;
-        return 0;
-    }
-    return xpcomFunctions.stringGetMutableData(aStr, aLen, aBuf);
+  if (!xpcomFunctions.stringGetMutableData) {
+    *aBuf = nullptr;
+    return 0;
+  }
+  return xpcomFunctions.stringGetMutableData(aStr, aLen, aBuf);
 }
 
 XPCOM_API(char16_t*)
-NS_StringCloneData(const nsAString &aStr)
+NS_StringCloneData(const nsAString& aStr)
 {
-    if (!xpcomFunctions.stringCloneData)
-        return nullptr;
-    return xpcomFunctions.stringCloneData(aStr);
+  if (!xpcomFunctions.stringCloneData) {
+    return nullptr;
+  }
+  return xpcomFunctions.stringCloneData(aStr);
 }
 
 XPCOM_API(nsresult)
-NS_StringSetData(nsAString &aStr, const char16_t *aBuf, uint32_t aCount)
+NS_StringSetData(nsAString& aStr, const char16_t* aBuf, uint32_t aCount)
 {
-    if (!xpcomFunctions.stringSetData)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!xpcomFunctions.stringSetData) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
 
-    return xpcomFunctions.stringSetData(aStr, aBuf, aCount);
+  return xpcomFunctions.stringSetData(aStr, aBuf, aCount);
 }
 
 XPCOM_API(nsresult)
-NS_StringSetDataRange(nsAString &aStr, uint32_t aCutStart, uint32_t aCutLength,
-                      const char16_t *aBuf, uint32_t aCount)
+NS_StringSetDataRange(nsAString& aStr, uint32_t aCutStart, uint32_t aCutLength,
+                      const char16_t* aBuf, uint32_t aCount)
 {
-    if (!xpcomFunctions.stringSetDataRange)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.stringSetDataRange(aStr, aCutStart, aCutLength, aBuf, aCount);
+  if (!xpcomFunctions.stringSetDataRange) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.stringSetDataRange(aStr, aCutStart, aCutLength, aBuf,
+                                           aCount);
 }
 
 XPCOM_API(nsresult)
-NS_StringCopy(nsAString &aDest, const nsAString &aSrc)
+NS_StringCopy(nsAString& aDest, const nsAString& aSrc)
 {
-    if (!xpcomFunctions.stringCopy)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.stringCopy(aDest, aSrc);
+  if (!xpcomFunctions.stringCopy) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.stringCopy(aDest, aSrc);
 }
 
 XPCOM_API(void)
-NS_StringSetIsVoid(nsAString &aStr, const bool aIsVoid)
+NS_StringSetIsVoid(nsAString& aStr, const bool aIsVoid)
 {
-    if (xpcomFunctions.stringSetIsVoid)
-        xpcomFunctions.stringSetIsVoid(aStr, aIsVoid);
+  if (xpcomFunctions.stringSetIsVoid) {
+    xpcomFunctions.stringSetIsVoid(aStr, aIsVoid);
+  }
 }
 
 XPCOM_API(bool)
-NS_StringGetIsVoid(const nsAString &aStr)
+NS_StringGetIsVoid(const nsAString& aStr)
 {
-    if (!xpcomFunctions.stringGetIsVoid)
-        return false;
-    return xpcomFunctions.stringGetIsVoid(aStr);
+  if (!xpcomFunctions.stringGetIsVoid) {
+    return false;
+  }
+  return xpcomFunctions.stringGetIsVoid(aStr);
 }
 
 XPCOM_API(nsresult)
-NS_CStringContainerInit(nsCStringContainer &aStr)
+NS_CStringContainerInit(nsCStringContainer& aStr)
 {
-    if (!xpcomFunctions.cstringContainerInit)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.cstringContainerInit(aStr);
+  if (!xpcomFunctions.cstringContainerInit) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.cstringContainerInit(aStr);
 }
 
 XPCOM_API(nsresult)
-NS_CStringContainerInit2(nsCStringContainer &aStr,
-                         const char         *aData,
-                         uint32_t           aDataLength,
-                         uint32_t           aFlags)
+NS_CStringContainerInit2(nsCStringContainer& aStr, const char* aData,
+                         uint32_t aDataLength, uint32_t aFlags)
 {
-    if (!xpcomFunctions.cstringContainerInit2)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.cstringContainerInit2(aStr, aData, aDataLength, aFlags);
+  if (!xpcomFunctions.cstringContainerInit2) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.cstringContainerInit2(aStr, aData, aDataLength, aFlags);
 }
 
 XPCOM_API(void)
-NS_CStringContainerFinish(nsCStringContainer &aStr)
+NS_CStringContainerFinish(nsCStringContainer& aStr)
 {
-    if (xpcomFunctions.cstringContainerFinish)
-        xpcomFunctions.cstringContainerFinish(aStr);
+  if (xpcomFunctions.cstringContainerFinish) {
+    xpcomFunctions.cstringContainerFinish(aStr);
+  }
 }
 
 XPCOM_API(uint32_t)
-NS_CStringGetData(const nsACString &aStr, const char **aBuf, bool *aTerm)
+NS_CStringGetData(const nsACString& aStr, const char** aBuf, bool* aTerm)
 {
-    if (!xpcomFunctions.cstringGetData) {
-        *aBuf = nullptr;
-        return 0;
-    }
-    return xpcomFunctions.cstringGetData(aStr, aBuf, aTerm);
+  if (!xpcomFunctions.cstringGetData) {
+    *aBuf = nullptr;
+    return 0;
+  }
+  return xpcomFunctions.cstringGetData(aStr, aBuf, aTerm);
 }
 
 XPCOM_API(uint32_t)
-NS_CStringGetMutableData(nsACString &aStr, uint32_t aLen, char **aBuf)
+NS_CStringGetMutableData(nsACString& aStr, uint32_t aLen, char** aBuf)
 {
-    if (!xpcomFunctions.cstringGetMutableData) {
-        *aBuf = nullptr;
-        return 0;
-    }
-    return xpcomFunctions.cstringGetMutableData(aStr, aLen, aBuf);
+  if (!xpcomFunctions.cstringGetMutableData) {
+    *aBuf = nullptr;
+    return 0;
+  }
+  return xpcomFunctions.cstringGetMutableData(aStr, aLen, aBuf);
 }
 
 XPCOM_API(char*)
-NS_CStringCloneData(const nsACString &aStr)
+NS_CStringCloneData(const nsACString& aStr)
 {
-    if (!xpcomFunctions.cstringCloneData)
-        return nullptr;
-    return xpcomFunctions.cstringCloneData(aStr);
+  if (!xpcomFunctions.cstringCloneData) {
+    return nullptr;
+  }
+  return xpcomFunctions.cstringCloneData(aStr);
+}
+
+XPCOM_API(nsresult)
+NS_CStringSetData(nsACString& aStr, const char* aBuf, uint32_t aCount)
+{
+  if (!xpcomFunctions.cstringSetData) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.cstringSetData(aStr, aBuf, aCount);
 }
 
 XPCOM_API(nsresult)
-NS_CStringSetData(nsACString &aStr, const char *aBuf, uint32_t aCount)
+NS_CStringSetDataRange(nsACString& aStr, uint32_t aCutStart,
+                       uint32_t aCutLength, const char* aBuf, uint32_t aCount)
 {
-    if (!xpcomFunctions.cstringSetData)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.cstringSetData(aStr, aBuf, aCount);
+  if (!xpcomFunctions.cstringSetDataRange) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.cstringSetDataRange(aStr, aCutStart, aCutLength, aBuf,
+                                            aCount);
 }
 
 XPCOM_API(nsresult)
-NS_CStringSetDataRange(nsACString &aStr, uint32_t aCutStart, uint32_t aCutLength,
-                       const char *aBuf, uint32_t aCount)
+NS_CStringCopy(nsACString& aDest, const nsACString& aSrc)
 {
-    if (!xpcomFunctions.cstringSetDataRange)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.cstringSetDataRange(aStr, aCutStart, aCutLength, aBuf, aCount);
-}
-
-XPCOM_API(nsresult)
-NS_CStringCopy(nsACString &aDest, const nsACString &aSrc)
-{
-    if (!xpcomFunctions.cstringCopy)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.cstringCopy(aDest, aSrc);
+  if (!xpcomFunctions.cstringCopy) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.cstringCopy(aDest, aSrc);
 }
 
 XPCOM_API(void)
-NS_CStringSetIsVoid(nsACString &aStr, const bool aIsVoid)
+NS_CStringSetIsVoid(nsACString& aStr, const bool aIsVoid)
 {
-    if (xpcomFunctions.cstringSetIsVoid)
-        xpcomFunctions.cstringSetIsVoid(aStr, aIsVoid);
+  if (xpcomFunctions.cstringSetIsVoid) {
+    xpcomFunctions.cstringSetIsVoid(aStr, aIsVoid);
+  }
 }
 
 XPCOM_API(bool)
-NS_CStringGetIsVoid(const nsACString &aStr)
+NS_CStringGetIsVoid(const nsACString& aStr)
 {
-    if (!xpcomFunctions.cstringGetIsVoid)
-        return false;
-    return xpcomFunctions.cstringGetIsVoid(aStr);
+  if (!xpcomFunctions.cstringGetIsVoid) {
+    return false;
+  }
+  return xpcomFunctions.cstringGetIsVoid(aStr);
 }
 
 XPCOM_API(nsresult)
-NS_CStringToUTF16(const nsACString &aSrc, nsCStringEncoding aSrcEncoding, nsAString &aDest)
+NS_CStringToUTF16(const nsACString& aSrc, nsCStringEncoding aSrcEncoding,
+                  nsAString& aDest)
 {
-    if (!xpcomFunctions.cstringToUTF16)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.cstringToUTF16(aSrc, aSrcEncoding, aDest);
+  if (!xpcomFunctions.cstringToUTF16) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.cstringToUTF16(aSrc, aSrcEncoding, aDest);
 }
 
 XPCOM_API(nsresult)
-NS_UTF16ToCString(const nsAString &aSrc, nsCStringEncoding aDestEncoding, nsACString &aDest)
+NS_UTF16ToCString(const nsAString& aSrc, nsCStringEncoding aDestEncoding,
+                  nsACString& aDest)
 {
-    if (!xpcomFunctions.utf16ToCString)
-        return NS_ERROR_NOT_INITIALIZED;
-    return xpcomFunctions.utf16ToCString(aSrc, aDestEncoding, aDest);
+  if (!xpcomFunctions.utf16ToCString) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+  return xpcomFunctions.utf16ToCString(aSrc, aDestEncoding, aDest);
 }
 
 XPCOM_API(void*)
-NS_Alloc(size_t size)
+NS_Alloc(size_t aSize)
 {
-    if (!xpcomFunctions.allocFunc)
-        return nullptr;
-    return xpcomFunctions.allocFunc(size);
+  if (!xpcomFunctions.allocFunc) {
+    return nullptr;
+  }
+  return xpcomFunctions.allocFunc(aSize);
 }
 
 XPCOM_API(void*)
-NS_Realloc(void* ptr, size_t size)
+NS_Realloc(void* aPtr, size_t aSize)
 {
-    if (!xpcomFunctions.reallocFunc)
-        return nullptr;
-    return xpcomFunctions.reallocFunc(ptr, size);
+  if (!xpcomFunctions.reallocFunc) {
+    return nullptr;
+  }
+  return xpcomFunctions.reallocFunc(aPtr, aSize);
 }
 
 XPCOM_API(void)
-NS_Free(void* ptr)
+NS_Free(void* aPtr)
 {
-    if (xpcomFunctions.freeFunc)
-        xpcomFunctions.freeFunc(ptr);
+  if (xpcomFunctions.freeFunc) {
+    xpcomFunctions.freeFunc(aPtr);
+  }
 }
 
 XPCOM_API(void)
-NS_DebugBreak(uint32_t aSeverity, const char *aStr, const char *aExpr,
-              const char *aFile, int32_t aLine)
+NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr,
+              const char* aFile, int32_t aLine)
 {
-    if (xpcomFunctions.debugBreakFunc)
-        xpcomFunctions.debugBreakFunc(aSeverity, aStr, aExpr, aFile, aLine);
+  if (xpcomFunctions.debugBreakFunc) {
+    xpcomFunctions.debugBreakFunc(aSeverity, aStr, aExpr, aFile, aLine);
+  }
 }
 
 XPCOM_API(void)
 NS_LogInit()
 {
-    if (xpcomFunctions.logInitFunc)
-        xpcomFunctions.logInitFunc();
+  if (xpcomFunctions.logInitFunc) {
+    xpcomFunctions.logInitFunc();
+  }
 }
 
 XPCOM_API(void)
 NS_LogTerm()
 {
-    if (xpcomFunctions.logTermFunc)
-        xpcomFunctions.logTermFunc();
+  if (xpcomFunctions.logTermFunc) {
+    xpcomFunctions.logTermFunc();
+  }
 }
 
 XPCOM_API(void)
-NS_LogAddRef(void *aPtr, nsrefcnt aNewRefCnt,
-             const char *aTypeName, uint32_t aInstanceSize)
+NS_LogAddRef(void* aPtr, nsrefcnt aNewRefCnt,
+             const char* aTypeName, uint32_t aInstanceSize)
 {
-    if (xpcomFunctions.logAddRefFunc)
-        xpcomFunctions.logAddRefFunc(aPtr, aNewRefCnt,
-                                     aTypeName, aInstanceSize);
+  if (xpcomFunctions.logAddRefFunc)
+    xpcomFunctions.logAddRefFunc(aPtr, aNewRefCnt,
+                                 aTypeName, aInstanceSize);
 }
 
 XPCOM_API(void)
-NS_LogRelease(void *aPtr, nsrefcnt aNewRefCnt, const char *aTypeName)
+NS_LogRelease(void* aPtr, nsrefcnt aNewRefCnt, const char* aTypeName)
 {
-    if (xpcomFunctions.logReleaseFunc)
-        xpcomFunctions.logReleaseFunc(aPtr, aNewRefCnt, aTypeName);
+  if (xpcomFunctions.logReleaseFunc) {
+    xpcomFunctions.logReleaseFunc(aPtr, aNewRefCnt, aTypeName);
+  }
 }
 
 XPCOM_API(void)
-NS_LogCtor(void *aPtr, const char *aTypeName, uint32_t aInstanceSize)
+NS_LogCtor(void* aPtr, const char* aTypeName, uint32_t aInstanceSize)
 {
-    if (xpcomFunctions.logCtorFunc)
-        xpcomFunctions.logCtorFunc(aPtr, aTypeName, aInstanceSize);
+  if (xpcomFunctions.logCtorFunc) {
+    xpcomFunctions.logCtorFunc(aPtr, aTypeName, aInstanceSize);
+  }
 }
 
 XPCOM_API(void)
-NS_LogDtor(void *aPtr, const char *aTypeName, uint32_t aInstanceSize)
+NS_LogDtor(void* aPtr, const char* aTypeName, uint32_t aInstanceSize)
 {
-    if (xpcomFunctions.logDtorFunc)
-        xpcomFunctions.logDtorFunc(aPtr, aTypeName, aInstanceSize);
+  if (xpcomFunctions.logDtorFunc) {
+    xpcomFunctions.logDtorFunc(aPtr, aTypeName, aInstanceSize);
+  }
 }
 
 XPCOM_API(void)
-NS_LogCOMPtrAddRef(void *aCOMPtr, nsISupports *aObject)
+NS_LogCOMPtrAddRef(void* aCOMPtr, nsISupports* aObject)
 {
-    if (xpcomFunctions.logCOMPtrAddRefFunc)
-        xpcomFunctions.logCOMPtrAddRefFunc(aCOMPtr, aObject);
+  if (xpcomFunctions.logCOMPtrAddRefFunc) {
+    xpcomFunctions.logCOMPtrAddRefFunc(aCOMPtr, aObject);
+  }
 }
 
 XPCOM_API(void)
-NS_LogCOMPtrRelease(void *aCOMPtr, nsISupports *aObject)
+NS_LogCOMPtrRelease(void* aCOMPtr, nsISupports* aObject)
 {
-    if (xpcomFunctions.logCOMPtrReleaseFunc)
-        xpcomFunctions.logCOMPtrReleaseFunc(aCOMPtr, aObject);
+  if (xpcomFunctions.logCOMPtrReleaseFunc) {
+    xpcomFunctions.logCOMPtrReleaseFunc(aCOMPtr, aObject);
+  }
 }
 
 XPCOM_API(nsresult)
 NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
-                  nsISomeInterface* *aStub)
+                  nsISomeInterface** aStub)
 {
-    if (!xpcomFunctions.getXPTCallStubFunc)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!xpcomFunctions.getXPTCallStubFunc) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
 
-    return xpcomFunctions.getXPTCallStubFunc(aIID, aOuter, aStub);
+  return xpcomFunctions.getXPTCallStubFunc(aIID, aOuter, aStub);
 }
 
 XPCOM_API(void)
 NS_DestroyXPTCallStub(nsISomeInterface* aStub)
 {
-    if (xpcomFunctions.destroyXPTCallStubFunc)
-        xpcomFunctions.destroyXPTCallStubFunc(aStub);
+  if (xpcomFunctions.destroyXPTCallStubFunc) {
+    xpcomFunctions.destroyXPTCallStubFunc(aStub);
+  }
 }
 
 XPCOM_API(nsresult)
-NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
-                 uint32_t paramCount, nsXPTCVariant* params)
+NS_InvokeByIndex(nsISupports* aThat, uint32_t aMethodIndex,
+                 uint32_t aParamCount, nsXPTCVariant* aParams)
 {
-    if (!xpcomFunctions.invokeByIndexFunc)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!xpcomFunctions.invokeByIndexFunc) {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
 
-    return xpcomFunctions.invokeByIndexFunc(that, methodIndex,
-                                            paramCount, params);
+  return xpcomFunctions.invokeByIndexFunc(aThat, aMethodIndex,
+                                          aParamCount, aParams);
 }
 
 XPCOM_API(bool)
-NS_CycleCollectorSuspect(nsISupports* obj)
+NS_CycleCollectorSuspect(nsISupports* aObj)
 {
-    if (!xpcomFunctions.cycleSuspectFunc)
-        return false;
+  if (!xpcomFunctions.cycleSuspectFunc) {
+    return false;
+  }
 
-    return xpcomFunctions.cycleSuspectFunc(obj);
+  return xpcomFunctions.cycleSuspectFunc(aObj);
 }
 
 XPCOM_API(bool)
-NS_CycleCollectorForget(nsISupports* obj)
+NS_CycleCollectorForget(nsISupports* aObj)
 {
-    if (!xpcomFunctions.cycleForgetFunc)
-        return false;
+  if (!xpcomFunctions.cycleForgetFunc) {
+    return false;
+  }
 
-    return xpcomFunctions.cycleForgetFunc(obj);
+  return xpcomFunctions.cycleForgetFunc(aObj);
 }
 
 XPCOM_API(nsPurpleBufferEntry*)
-NS_CycleCollectorSuspect2(void* obj, nsCycleCollectionParticipant *p)
+NS_CycleCollectorSuspect2(void* aObj, nsCycleCollectionParticipant* aCp)
 {
-    if (!xpcomFunctions.cycleSuspect2Func)
-        return nullptr;
+  if (!xpcomFunctions.cycleSuspect2Func) {
+    return nullptr;
+  }
 
-    return xpcomFunctions.cycleSuspect2Func(obj, p);
+  return xpcomFunctions.cycleSuspect2Func(aObj, aCp);
 }
 
 XPCOM_API(void)
-NS_CycleCollectorSuspect3(void* obj, nsCycleCollectionParticipant *p,
+NS_CycleCollectorSuspect3(void* aObj, nsCycleCollectionParticipant* aCp,
                           nsCycleCollectingAutoRefCnt* aRefCnt,
                           bool* aShouldDelete)
 {
-    if (xpcomFunctions.cycleSuspect3Func)
-        xpcomFunctions.cycleSuspect3Func(obj, p, aRefCnt, aShouldDelete);
+  if (xpcomFunctions.cycleSuspect3Func) {
+    xpcomFunctions.cycleSuspect3Func(aObj, aCp, aRefCnt, aShouldDelete);
+  }
 }
 
 XPCOM_API(bool)
-NS_CycleCollectorForget2(nsPurpleBufferEntry* e)
+NS_CycleCollectorForget2(nsPurpleBufferEntry* aEntry)
 {
-    if (!xpcomFunctions.cycleForget2Func)
-        return false;
+  if (!xpcomFunctions.cycleForget2Func) {
+    return false;
+  }
 
-    return xpcomFunctions.cycleForget2Func(e);
+  return xpcomFunctions.cycleForget2Func(aEntry);
 }
--- a/xpcom/glue/standalone/nsXPCOMGlue.h
+++ b/xpcom/glue/standalone/nsXPCOMGlue.h
@@ -19,17 +19,17 @@
  * Enabled preloading of dynamically loaded libraries
  */
 extern "C" NS_HIDDEN_(void) XPCOMGlueEnablePreload();
 
 /**
  * Initialize the XPCOM glue by dynamically linking against the XPCOM
  * shared library indicated by xpcomFile.
  */
-extern "C" NS_HIDDEN_(nsresult) XPCOMGlueStartup(const char* xpcomFile);
+extern "C" NS_HIDDEN_(nsresult) XPCOMGlueStartup(const char* aXPCOMFile);
 
 typedef void (*NSFuncPtr)();
 
 struct nsDynamicFunctionLoad
 {
   const char* functionName;
   NSFuncPtr* function;
 };
@@ -38,12 +38,12 @@ struct nsDynamicFunctionLoad
  * Dynamically load functions from libxul.
  *
  * @throws NS_ERROR_NOT_INITIALIZED if XPCOMGlueStartup() was not called or
  *         if the libxul DLL was not found.
  * @throws NS_ERROR_LOSS_OF_SIGNIFICANT_DATA if only some of the required
  *         functions were found.
  */
 extern "C" NS_HIDDEN_(nsresult)
-XPCOMGlueLoadXULFunctions(const nsDynamicFunctionLoad* symbols);
+XPCOMGlueLoadXULFunctions(const nsDynamicFunctionLoad* aSymbols);
 
 #endif // XPCOM_GLUE
 #endif // nsXPCOMGlue_h__
--- a/xpcom/sample/nsSample.cpp
+++ b/xpcom/sample/nsSample.cpp
@@ -16,30 +16,31 @@
 #include "nsMemory.h"
 
 #include "nsEmbedString.h"
 #include "nsIClassInfoImpl.h"
 ////////////////////////////////////////////////////////////////////////
 
 nsSampleImpl::nsSampleImpl() : mValue(nullptr)
 {
-    mValue = (char*)nsMemory::Clone("initial value", 14);
+  mValue = (char*)nsMemory::Clone("initial value", 14);
 }
 
 nsSampleImpl::~nsSampleImpl()
 {
-    if (mValue)
-        nsMemory::Free(mValue);
+  if (mValue) {
+    nsMemory::Free(mValue);
+  }
 }
 
 /**
  * NS_IMPL_ISUPPORTS expands to a simple implementation of the nsISupports
  * interface.  This includes a proper implementation of AddRef, Release,
  * and QueryInterface.  If this class supported more interfaces than just
- * nsISupports, 
+ * nsISupports,
  * you could use NS_IMPL_ADDREF() and NS_IMPL_RELEASE() to take care of the
  * simple stuff, but you would have to create QueryInterface on your own.
  * nsSampleFactory.cpp is an example of this approach.
  * Notice that the second parameter to the macro is name of the interface, and
  * NOT the #defined IID.
  *
  * The _CI variant adds support for nsIClassInfo, which permits introspection
  * and interface flattening.
@@ -49,101 +50,106 @@ NS_IMPL_ISUPPORTS_CI(nsSampleImpl, nsISa
 /**
  * Notice that in the protoype for this function, the NS_IMETHOD macro was
  * used to declare the return type.  For the implementation, the return
  * type is declared by NS_IMETHODIMP
  */
 NS_IMETHODIMP
 nsSampleImpl::GetValue(char** aValue)
 {
-    NS_PRECONDITION(aValue != nullptr, "null ptr");
-    if (! aValue)
-        return NS_ERROR_NULL_POINTER;
+  NS_PRECONDITION(aValue != nullptr, "null ptr");
+  if (!aValue) {
+    return NS_ERROR_NULL_POINTER;
+  }
 
-    if (mValue) {
-        /**
-         * GetValue's job is to return data known by an instance of
-         * nsSampleImpl to the outside world.  If we  were to simply return 
-         * a pointer to data owned by this instance, and the client were to
-         * free it, bad things would surely follow.
-         * On the other hand, if we create a new copy of the data for our
-         * client, and it turns out that client is implemented in JavaScript,
-         * there would be no way to free the buffer.  The solution to the 
-         * buffer ownership problem is the nsMemory singleton.  Any buffer
-         * returned by an XPCOM method should be allocated by the nsMemory.
-         * This convention lets things like JavaScript reflection do their
-         * job, and simplifies the way C++ clients deal with returned buffers.
-         */
-        *aValue = (char*) nsMemory::Clone(mValue, strlen(mValue) + 1);
-        if (! *aValue)
-            return NS_ERROR_NULL_POINTER;
+  if (mValue) {
+    /**
+     * GetValue's job is to return data known by an instance of
+     * nsSampleImpl to the outside world.  If we  were to simply return
+     * a pointer to data owned by this instance, and the client were to
+     * free it, bad things would surely follow.
+     * On the other hand, if we create a new copy of the data for our
+     * client, and it turns out that client is implemented in JavaScript,
+     * there would be no way to free the buffer.  The solution to the
+     * buffer ownership problem is the nsMemory singleton.  Any buffer
+     * returned by an XPCOM method should be allocated by the nsMemory.
+     * This convention lets things like JavaScript reflection do their
+     * job, and simplifies the way C++ clients deal with returned buffers.
+     */
+    *aValue = (char*)nsMemory::Clone(mValue, strlen(mValue) + 1);
+    if (!*aValue) {
+      return NS_ERROR_NULL_POINTER;
     }
-    else {
-        *aValue = nullptr;
-    }
-    return NS_OK;
+  } else {
+    *aValue = nullptr;
+  }
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSampleImpl::SetValue(const char* aValue)
 {
-    NS_PRECONDITION(aValue != nullptr, "null ptr");
-    if (! aValue)
-        return NS_ERROR_NULL_POINTER;
+  NS_PRECONDITION(aValue != nullptr, "null ptr");
+  if (!aValue) {
+    return NS_ERROR_NULL_POINTER;
+  }
 
-    if (mValue) {
-        nsMemory::Free(mValue);
-    }
+  if (mValue) {
+    nsMemory::Free(mValue);
+  }
 
-    /**
-     * Another buffer passing convention is that buffers passed INTO your
-     * object ARE NOT YOURS.  Keep your hands off them, unless they are
-     * declared "inout".  If you want to keep the value for posterity,
-     * you will have to make a copy of it.
-     */
-    mValue = (char*) nsMemory::Clone(aValue, strlen(aValue) + 1);
-    return NS_OK;
+  /**
+   * Another buffer passing convention is that buffers passed INTO your
+   * object ARE NOT YOURS.  Keep your hands off them, unless they are
+   * declared "inout".  If you want to keep the value for posterity,
+   * you will have to make a copy of it.
+   */
+  mValue = (char*)nsMemory::Clone(aValue, strlen(aValue) + 1);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSampleImpl::Poke(const char* aValue)
 {
-    return SetValue((char*) aValue);
+  return SetValue((char*)aValue);
 }
 
 
-static void GetStringValue(nsACString& aValue)
+static void
+GetStringValue(nsACString& aValue)
 {
-    NS_CStringSetData(aValue, "GetValue");
+  NS_CStringSetData(aValue, "GetValue");
 }
 
 NS_IMETHODIMP
 nsSampleImpl::WriteValue(const char* aPrefix)
 {
-    NS_PRECONDITION(aPrefix != nullptr, "null ptr");
-    if (! aPrefix)
-        return NS_ERROR_NULL_POINTER;
+  NS_PRECONDITION(aPrefix != nullptr, "null ptr");
+  if (!aPrefix) {
+    return NS_ERROR_NULL_POINTER;
+  }
+
+  printf("%s %s\n", aPrefix, mValue);
 
-    printf("%s %s\n", aPrefix, mValue);
+  // This next part illustrates the nsEmbedString:
+  nsEmbedString foopy;
+  foopy.Append(char16_t('f'));
+  foopy.Append(char16_t('o'));
+  foopy.Append(char16_t('o'));
+  foopy.Append(char16_t('p'));
+  foopy.Append(char16_t('y'));
 
-    // This next part illustrates the nsEmbedString:
-    nsEmbedString foopy;
-    foopy.Append(char16_t('f'));
-    foopy.Append(char16_t('o'));
-    foopy.Append(char16_t('o'));
-    foopy.Append(char16_t('p'));
-    foopy.Append(char16_t('y'));
-    
-    const char16_t* f = foopy.get();
-    uint32_t l = foopy.Length();
-    printf("%c%c%c%c%c %d\n", char(f[0]), char(f[1]), char(f[2]), char(f[3]), char(f[4]), l);
-    
-    nsEmbedCString foopy2;
-    GetStringValue(foopy2);
+  const char16_t* f = foopy.get();
+  uint32_t l = foopy.Length();
+  printf("%c%c%c%c%c %d\n",
+         char(f[0]), char(f[1]), char(f[2]), char(f[3]), char(f[4]), l);
+
+  nsEmbedCString foopy2;
+  GetStringValue(foopy2);
 
-    //foopy2.AppendLiteral("foopy");
-    const char* f2 = foopy2.get();
-    uint32_t l2 = foopy2.Length();
+  //foopy2.AppendLiteral("foopy");
+  const char* f2 = foopy2.get();
+  uint32_t l2 = foopy2.Length();
 
-    printf("%s %d\n", f2, l2);
+  printf("%s %d\n", f2, l2);
 
-    return NS_OK;
+  return NS_OK;
 }
--- a/xpcom/sample/nsSample.h
+++ b/xpcom/sample/nsSample.h
@@ -30,74 +30,74 @@
 { 0x7cb5b7a0, 0x7d7, 0x11d3, { 0xbd, 0xe2, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
 
 #define NS_SAMPLE_CONTRACTID "@mozilla.org/sample;1"
 
 
 class nsSampleImpl MOZ_FINAL : public nsISample
 {
 public:
-    nsSampleImpl();
+  nsSampleImpl();
 
-    /**
-     * This macro expands into a declaration of the nsISupports interface.
-     * Every XPCOM component needs to implement nsISupports, as it acts
-     * as the gateway to other interfaces this component implements.  You
-     * could manually declare QueryInterface, AddRef, and Release instead
-     * of using this macro, but why?
-     */
-    // nsISupports interface
-    NS_DECL_ISUPPORTS
+  /**
+   * This macro expands into a declaration of the nsISupports interface.
+   * Every XPCOM component needs to implement nsISupports, as it acts
+   * as the gateway to other interfaces this component implements.  You
+   * could manually declare QueryInterface, AddRef, and Release instead
+   * of using this macro, but why?
+   */
+  // nsISupports interface
+  NS_DECL_ISUPPORTS
 
-    /**
-     * This macro is defined in the nsISample.h file, and is generated
-     * automatically by the xpidl compiler.  It expands to
-     * declarations of all of the methods required to implement the
-     * interface.  xpidl will generate a NS_DECL_[INTERFACENAME] macro
-     * for each interface that it processes.
-     *
-     * The methods of nsISample are discussed individually below, but
-     * commented out (because this macro already defines them.)
-     */
-    NS_DECL_NSISAMPLE
+  /**
+   * This macro is defined in the nsISample.h file, and is generated
+   * automatically by the xpidl compiler.  It expands to
+   * declarations of all of the methods required to implement the
+   * interface.  xpidl will generate a NS_DECL_[INTERFACENAME] macro
+   * for each interface that it processes.
+   *
+   * The methods of nsISample are discussed individually below, but
+   * commented out (because this macro already defines them.)
+   */
+  NS_DECL_NSISAMPLE
 
-    /**
-     * The following is an explanation of how the interface header
-     * file expands to for a c++ implementation. NS_DELC_NSISAMPLE
-     * takes care of defining the right c++ implementation.
-     *
-     * The following if provided for more understanding.
-     *
-     * NS_IMETHOD expands to the standard XPCOM return type.  XPCOM methods
-     * should never return any other type.  The return value is used
-     * behind the scenes by the XPConnect runtime to figure out if the call
-     * failed in any way.
-     * These methods were generated by "attribute string Value" in 
-     * nsISample.idl.  When reflected into JavaScript, XPCOM will use these
-     * calls as Getter/Setter ops, so that they can be called transparently
-     * as "sample.Value='foo';" and "var val = sample.Value"
-     */
-    /* NS_IMETHOD GetValue(char * *aValue); */
-    /* NS_IMETHOD SetValue(char * aValue); */
+  /**
+   * The following is an explanation of how the interface header
+   * file expands to for a c++ implementation. NS_DELC_NSISAMPLE
+   * takes care of defining the right c++ implementation.
+   *
+   * The following if provided for more understanding.
+   *
+   * NS_IMETHOD expands to the standard XPCOM return type.  XPCOM methods
+   * should never return any other type.  The return value is used
+   * behind the scenes by the XPConnect runtime to figure out if the call
+   * failed in any way.
+   * These methods were generated by "attribute string Value" in
+   * nsISample.idl.  When reflected into JavaScript, XPCOM will use these
+   * calls as Getter/Setter ops, so that they can be called transparently
+   * as "sample.Value='foo';" and "var val = sample.Value"
+   */
+  /* NS_IMETHOD GetValue(char** aValue); */
+  /* NS_IMETHOD SetValue(char* aValue); */
 
-    /**
-     * The const came from the "in" specifier in nsISample.idl.  "in"
-     * specifies that the value of this parameter is used only for input,
-     * this method is not allowed to modify the contents of the buffer.
-     */
-    /* NS_IMETHOD WriteValue(const char *aPrefix); */
+  /**
+   * The const came from the "in" specifier in nsISample.idl.  "in"
+   * specifies that the value of this parameter is used only for input,
+   * this method is not allowed to modify the contents of the buffer.
+   */
+  /* NS_IMETHOD WriteValue(const char* aPrefix); */
 
-    /**
-     * nsISample.idl specifies all of its string types as string, instead
-     * of wstring (wide string), the Unicode type.  If the world were a
-     * perfect place, all normal strings in XPCOM interfaces would be unicode.
-     * If this type had been specified as wstring, it would appear as
-     * char16_t * in C++, which is the NSPR type for unicode characters.
-     */
-    /* NS_IMETHOD Poke(const char* aValue); */
+  /**
+   * nsISample.idl specifies all of its string types as string, instead
+   * of wstring (wide string), the Unicode type.  If the world were a
+   * perfect place, all normal strings in XPCOM interfaces would be unicode.
+   * If this type had been specified as wstring, it would appear as
+   * char16_t * in C++, which is the NSPR type for unicode characters.
+   */
+  /* NS_IMETHOD Poke(const char* aValue); */
 
 private:
-    ~nsSampleImpl();
+  ~nsSampleImpl();
 
-    char* mValue;
+  char* mValue;
 };
 
 #endif
--- a/xpcom/sample/nsSampleModule.cpp
+++ b/xpcom/sample/nsSampleModule.cpp
@@ -30,44 +30,44 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSampleI
 // The following line defines a kNS_SAMPLE_CID CID variable.
 NS_DEFINE_NAMED_CID(NS_SAMPLE_CID);
 
 // Build a table of ClassIDs (CIDs) which are implemented by this module. CIDs
 // should be completely unique UUIDs.
 // each entry has the form { CID, service, factoryproc, constructorproc }
 // where factoryproc is usually nullptr.
 static const mozilla::Module::CIDEntry kSampleCIDs[] = {
-    { &kNS_SAMPLE_CID, false, nullptr, nsSampleImplConstructor },
-    { nullptr }
+  { &kNS_SAMPLE_CID, false, nullptr, nsSampleImplConstructor },
+  { nullptr }
 };
 
 // Build a table which maps contract IDs to CIDs.
 // A contract is a string which identifies a particular set of functionality. In some
 // cases an extension component may override the contract ID of a builtin gecko component
 // to modify or extend functionality.
 static const mozilla::Module::ContractIDEntry kSampleContracts[] = {
-    { NS_SAMPLE_CONTRACTID, &kNS_SAMPLE_CID },
-    { nullptr }
+  { NS_SAMPLE_CONTRACTID, &kNS_SAMPLE_CID },
+  { nullptr }
 };
 
 // Category entries are category/key/value triples which can be used
 // to register contract ID as content handlers or to observe certain
 // notifications. Most modules do not need to register any category
 // entries: this is just a sample of how you'd do it.
 // @see nsICategoryManager for information on retrieving category data.
 static const mozilla::Module::CategoryEntry kSampleCategories[] = {
-    { "my-category", "my-key", NS_SAMPLE_CONTRACTID },
-    { nullptr }
+  { "my-category", "my-key", NS_SAMPLE_CONTRACTID },
+  { nullptr }
 };
 
 static const mozilla::Module kSampleModule = {
-    mozilla::Module::kVersion,
-    kSampleCIDs,
-    kSampleContracts,
-    kSampleCategories
+  mozilla::Module::kVersion,
+  kSampleCIDs,
+  kSampleContracts,
+  kSampleCategories
 };
 
 // The following line implements the one-and-only "NSModule" symbol exported from this
 // shared library.
 NSMODULE_DEFN(nsSampleModule) = &kSampleModule;
 
 // The following line implements the one-and-only "NSGetModule" symbol
 // for compatibility with mozilla 1.9.2. You should only use this
--- a/xpcom/sample/program/nsTestSample.cpp
+++ b/xpcom/sample/program/nsTestSample.cpp
@@ -17,93 +17,87 @@
 #include "nsISample.h"
 #include "nsIServiceManager.h"
 #include "nsIComponentManager.h"
 #include "nsIComponentRegistrar.h"
 
 #define NS_SAMPLE_CONTRACTID "@mozilla.org/sample;1"
 
 int
-main(void)
+main()
 {
-    nsresult rv;
+  nsresult rv;
 
-    XPCOMGlueStartup(nullptr);
+  XPCOMGlueStartup(nullptr);
 
-    // Initialize XPCOM
-    nsCOMPtr<nsIServiceManager> servMan;
-    rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
-    if (NS_FAILED(rv))
-    {
-        printf("ERROR: XPCOM intialization error [%x].\n",
-               static_cast<uint32_t>(rv));
-        return -1;
-    }
+  // Initialize XPCOM
+  nsCOMPtr<nsIServiceManager> servMan;
+  rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
+  if (NS_FAILED(rv)) {
+    printf("ERROR: XPCOM intialization error [%x].\n",
+           static_cast<uint32_t>(rv));
+    return -1;
+  }
 
-    nsCOMPtr<nsIComponentManager> manager = do_QueryInterface(servMan);
+  nsCOMPtr<nsIComponentManager> manager = do_QueryInterface(servMan);
 
-    // Create an instance of our component
-    nsCOMPtr<nsISample> mysample;
-    rv = manager->CreateInstanceByContractID(NS_SAMPLE_CONTRACTID,
-                                             nullptr,
-                                             NS_GET_IID(nsISample),
-                                             getter_AddRefs(mysample));
-    if (NS_FAILED(rv))
-    {
-        printf("ERROR: Cannot create instance of component " NS_SAMPLE_CONTRACTID " [%x].\n"
-               "Debugging hint:\n"
-               "\tsetenv NSPR_LOG_MODULES nsComponentManager:5\n"
-               "\tsetenv NSPR_LOG_FILE xpcom.log\n"
-               "\t./nsTestSample\n"
-               "\t<check the contents for xpcom.log for possible cause of error>.\n",
-               static_cast<uint32_t>(rv));
-        return -2;
-    }
+  // Create an instance of our component
+  nsCOMPtr<nsISample> mysample;
+  rv = manager->CreateInstanceByContractID(NS_SAMPLE_CONTRACTID,
+                                           nullptr,
+                                           NS_GET_IID(nsISample),
+                                           getter_AddRefs(mysample));
+  if (NS_FAILED(rv)) {
+    printf("ERROR: Cannot create instance of component " NS_SAMPLE_CONTRACTID " [%x].\n"
+           "Debugging hint:\n"
+           "\tsetenv NSPR_LOG_MODULES nsComponentManager:5\n"
+           "\tsetenv NSPR_LOG_FILE xpcom.log\n"
+           "\t./nsTestSample\n"
+           "\t<check the contents for xpcom.log for possible cause of error>.\n",
+           static_cast<uint32_t>(rv));
+    return -2;
+  }
 
-    // Call methods on our sample to test it out.
-    rv = mysample->WriteValue("Inital print:");
-    if (NS_FAILED(rv))
-    {
-        printf("ERROR: Calling nsISample::WriteValue() [%x]\n",
-               static_cast<uint32_t>(rv));
-        return -3;
-    }
+  // Call methods on our sample to test it out.
+  rv = mysample->WriteValue("Inital print:");
+  if (NS_FAILED(rv)) {
+    printf("ERROR: Calling nsISample::WriteValue() [%x]\n",
+           static_cast<uint32_t>(rv));
+    return -3;
+  }
 
-    const char *testValue = "XPCOM defies gravity";
-    rv = mysample->SetValue(testValue);
-    if (NS_FAILED(rv))
-    {
-        printf("ERROR: Calling nsISample::SetValue() [%x]\n",
-               static_cast<uint32_t>(rv));
-        return -3;
-    }
-    printf("Set value to: %s\n", testValue);
-    char *str;
-    rv = mysample->GetValue(&str);
+  const char* testValue = "XPCOM defies gravity";
+  rv = mysample->SetValue(testValue);
+  if (NS_FAILED(rv)) {
+    printf("ERROR: Calling nsISample::SetValue() [%x]\n",
+           static_cast<uint32_t>(rv));
+    return -3;
+  }
+  printf("Set value to: %s\n", testValue);
+  char* str;
+  rv = mysample->GetValue(&str);
 
-    if (NS_FAILED(rv))
-    {
-        printf("ERROR: Calling nsISample::GetValue() [%x]\n",
-               static_cast<uint32_t>(rv));
-        return -3;
-    }
-    if (strcmp(str, testValue))
-    {
-        printf("Test FAILED.\n");
-        return -4;
-    }
+  if (NS_FAILED(rv)) {
+    printf("ERROR: Calling nsISample::GetValue() [%x]\n",
+           static_cast<uint32_t>(rv));
+    return -3;
+  }
+  if (strcmp(str, testValue)) {
+    printf("Test FAILED.\n");
+    return -4;
+  }
 
-    NS_Free(str);
+  NS_Free(str);
 
-    rv = mysample->WriteValue("Final print :");
-    printf("Test passed.\n");
-    
-    // All nsCOMPtr's must be deleted prior to calling shutdown XPCOM
-    // as we should not hold references passed XPCOM Shutdown.
-    servMan = 0;
-    manager = 0;
-    mysample = 0;
-    
-    // Shutdown XPCOM
-    NS_ShutdownXPCOM(nullptr);
+  rv = mysample->WriteValue("Final print :");
+  printf("Test passed.\n");
 
-    return 0;
+  // All nsCOMPtr's must be deleted prior to calling shutdown XPCOM
+  // as we should not hold references passed XPCOM Shutdown.
+  servMan = 0;
+  manager = 0;
+  mysample = 0;
+
+  // Shutdown XPCOM
+  NS_ShutdownXPCOM(nullptr);
+
+  return 0;
 }