Fix bug-prone patterns found by ClangTidy

* signed shift result sets the sign bit of the shift expression's type
  ('int') and becomes negative
* constructing string from nullptr is undefined behaviour

PiperOrigin-RevId: 251948690
Change-Id: Ia69429504f6f8e3c350acf3c63765ad2a8e95e01
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/55771
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp
index 338a719..6483859 100644
--- a/core/fxge/cfx_folderfontinfo.cpp
+++ b/core/fxge/cfx_folderfontinfo.cpp
@@ -245,23 +245,23 @@
   if (os2.GetLength() >= 86) {
     const uint8_t* p = os2.raw_str() + 78;
     uint32_t codepages = GET_TT_LONG(p);
-    if (codepages & (1 << 17)) {
+    if (codepages & (1U << 17)) {
       m_pMapper->AddInstalledFont(facename, FX_CHARSET_ShiftJIS);
       pInfo->m_Charsets |= CHARSET_FLAG_SHIFTJIS;
     }
-    if (codepages & (1 << 18)) {
+    if (codepages & (1U << 18)) {
       m_pMapper->AddInstalledFont(facename, FX_CHARSET_ChineseSimplified);
       pInfo->m_Charsets |= CHARSET_FLAG_GB;
     }
-    if (codepages & (1 << 20)) {
+    if (codepages & (1U << 20)) {
       m_pMapper->AddInstalledFont(facename, FX_CHARSET_ChineseTraditional);
       pInfo->m_Charsets |= CHARSET_FLAG_BIG5;
     }
-    if ((codepages & (1 << 19)) || (codepages & (1 << 21))) {
+    if ((codepages & (1U << 19)) || (codepages & (1U << 21))) {
       m_pMapper->AddInstalledFont(facename, FX_CHARSET_Hangul);
       pInfo->m_Charsets |= CHARSET_FLAG_KOREAN;
     }
-    if (codepages & (1 << 31)) {
+    if (codepages & (1U << 31)) {
       m_pMapper->AddInstalledFont(facename, FX_CHARSET_Symbol);
       pInfo->m_Charsets |= CHARSET_FLAG_SYMBOL;
     }
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index d24be39..8d4d592 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -154,5 +154,5 @@
       }
     }
   }
-  return (0xff << 24) | (r << 16) | (g << 8) | b;
+  return (0xffU << 24) | (r << 16) | (g << 8) | b;
 }
diff --git a/testing/fx_string_testhelpers.cpp b/testing/fx_string_testhelpers.cpp
index 17d90cc..4a7bda7 100644
--- a/testing/fx_string_testhelpers.cpp
+++ b/testing/fx_string_testhelpers.cpp
@@ -42,7 +42,7 @@
 
 std::wstring GetPlatformWString(FPDF_WIDESTRING wstr) {
   if (!wstr)
-    return nullptr;
+    return std::wstring();
 
   size_t characters = 0;
   while (wstr[characters])