Browse code

openvpnserv: Clean up use of TEXT() from DNS patches

These are slightly different and so not covered
by my automatic conversion script. Use __func__
to make the actual string slightly shorter.

Change-Id: If15862fe537496ac836fc443936ff8e7876a39c0
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250318173914.24425-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31161.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Frank Lichtenheld authored on 2025/03/19 02:39:06
Showing 1 changed files
... ...
@@ -1194,30 +1194,30 @@ ApplyDnsSettings(BOOL apply_gpol)
1194 1194
 
1195 1195
     if (apply_gpol && ApplyGpolSettings() == FALSE)
1196 1196
     {
1197
-        MsgToEventLog(M_ERR, L"ApplyDnsSettings: sending GPOL notification failed");
1197
+        MsgToEventLog(M_ERR, L"%s: sending GPOL notification failed", __func__);
1198 1198
     }
1199 1199
 
1200 1200
     scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
1201 1201
     if (scm == NULL)
1202 1202
     {
1203
-        MsgToEventLog(M_ERR, TEXT("ApplyDnsSettings: "
1204
-                                  "OpenSCManager call failed (%lu)"), GetLastError());
1203
+        MsgToEventLog(M_ERR, L"%s: OpenSCManager call failed (%lu)",
1204
+                      __func__, GetLastError());
1205 1205
         goto out;
1206 1206
     }
1207 1207
 
1208 1208
     dnssvc = OpenServiceA(scm, "Dnscache", SERVICE_PAUSE_CONTINUE);
1209 1209
     if (dnssvc == NULL)
1210 1210
     {
1211
-        MsgToEventLog(M_ERR, TEXT("ApplyDnsSettings: "
1212
-                                  "OpenService call failed (%lu)"), GetLastError());
1211
+        MsgToEventLog(M_ERR, L"%s: OpenService call failed (%lu)",
1212
+                      __func__, GetLastError());
1213 1213
         goto out;
1214 1214
     }
1215 1215
 
1216 1216
     SERVICE_STATUS status;
1217 1217
     if (ControlService(dnssvc, SERVICE_CONTROL_PARAMCHANGE, &status) == 0)
1218 1218
     {
1219
-        MsgToEventLog(M_ERR, TEXT("ApplyDnsSettings: "
1220
-                                  "ControlService call failed (%lu)"), GetLastError());
1219
+        MsgToEventLog(M_ERR, L"%s: ControlService call failed (%lu)",
1220
+                      __func__, GetLastError());
1221 1221
         goto out;
1222 1222
     }
1223 1223
 
... ...
@@ -1255,22 +1255,19 @@ InterfaceIdString(PCSTR itf_name, PWSTR str, size_t len)
1255 1255
     err = InterfaceLuid(itf_name, &luid);
1256 1256
     if (err)
1257 1257
     {
1258
-        MsgToEventLog(M_ERR, TEXT("InterfaceIdString: "
1259
-                                  "failed to convert itf alias '%s'"), itf_name);
1258
+        MsgToEventLog(M_ERR, L"%s: failed to convert itf alias '%s'", __func__, itf_name);
1260 1259
         goto out;
1261 1260
     }
1262 1261
     err = ConvertInterfaceLuidToGuid(&luid, &guid);
1263 1262
     if (err)
1264 1263
     {
1265
-        MsgToEventLog(M_ERR, TEXT("InterfaceIdString: "
1266
-                                  "Failed to convert itf '%s' LUID"), itf_name);
1264
+        MsgToEventLog(M_ERR, L"%s: Failed to convert itf '%s' LUID", __func__, itf_name);
1267 1265
         goto out;
1268 1266
     }
1269 1267
 
1270 1268
     if (StringFromIID(&guid, &iid_str) != S_OK)
1271 1269
     {
1272
-        MsgToEventLog(M_ERR, TEXT("InterfaceIdString: "
1273
-                                  "Failed to convert itf '%s' IID"), itf_name);
1270
+        MsgToEventLog(M_ERR, L"%s: Failed to convert itf '%s' IID", __func__, itf_name);
1274 1271
         err = ERROR_OUTOFMEMORY;
1275 1272
         goto out;
1276 1273
     }
... ...
@@ -1420,8 +1417,8 @@ InitialSearchListExists(HKEY key)
1420 1420
         {
1421 1421
             return FALSE;
1422 1422
         }
1423
-        MsgToEventLog(M_ERR, TEXT("InitialSearchListExists: "
1424
-                                  "failed to get InitialSearchList (%lu)"), err);
1423
+        MsgToEventLog(M_ERR, L"%s: failed to get InitialSearchList (%lu)",
1424
+                      __func__, err);
1425 1425
     }
1426 1426
 
1427 1427
     return TRUE;
... ...
@@ -1456,8 +1453,8 @@ StoreInitialDnsSearchList(HKEY key, PCWSTR list)
1456 1456
     LSTATUS err = RegSetValueExW(key, L"InitialSearchList", 0, REG_SZ, (PBYTE)list, size);
1457 1457
     if (err)
1458 1458
     {
1459
-        MsgToEventLog(M_ERR, TEXT("StoreInitialDnsSearchList: "
1460
-                                  "failed to set InitialSearchList value (%lu)"), err);
1459
+        MsgToEventLog(M_ERR, L"%s: failed to set InitialSearchList value (%lu)",
1460
+                      __func__, err);
1461 1461
         return FALSE;
1462 1462
     }
1463 1463
 
... ...
@@ -1485,8 +1482,8 @@ AddDnsSearchDomains(HKEY key, BOOL have_list, PCWSTR domains)
1485 1485
         err = RegGetValueW(key, NULL, L"SearchList", RRF_RT_REG_SZ, NULL, list, &size);
1486 1486
         if (err)
1487 1487
         {
1488
-            MsgToEventLog(M_SYSERR, TEXT("AddDnsSearchDomains: "
1489
-                                         "could not get SearchList from registry (%lu)"), err);
1488
+            MsgToEventLog(M_SYSERR, L"%s: could not get SearchList from registry (%lu)",
1489
+                          __func__, err);
1490 1490
             return FALSE;
1491 1491
         }
1492 1492
 
... ...
@@ -1499,9 +1496,8 @@ AddDnsSearchDomains(HKEY key, BOOL have_list, PCWSTR domains)
1499 1499
         size_t domlen = wcslen(domains);
1500 1500
         if (listlen + domlen + 2 > _countof(list))
1501 1501
         {
1502
-            MsgToEventLog(M_SYSERR, TEXT("AddDnsSearchDomains: "
1503
-                                         "not enough space in list for search domains (len=%lu)"),
1504
-                          domlen);
1502
+            MsgToEventLog(M_SYSERR, L"%s: not enough space in list for search domains (len=%lu)",
1503
+                          __func__, domlen);
1505 1504
             return FALSE;
1506 1505
         }
1507 1506
 
... ...
@@ -1519,8 +1515,8 @@ AddDnsSearchDomains(HKEY key, BOOL have_list, PCWSTR domains)
1519 1519
     err = RegSetValueExW(key, L"SearchList", 0, REG_SZ, (PBYTE)list, size);
1520 1520
     if (err)
1521 1521
     {
1522
-        MsgToEventLog(M_SYSERR, TEXT("AddDnsSearchDomains: "
1523
-                                     "could not set SearchList to registry (%lu)"), err);
1522
+        MsgToEventLog(M_SYSERR, L"%s: could not set SearchList to registry (%lu)",
1523
+                      __func__, err);
1524 1524
         return FALSE;
1525 1525
     }
1526 1526
 
... ...
@@ -1551,8 +1547,8 @@ ResetDnsSearchDomains(HKEY key)
1551 1551
     {
1552 1552
         if (err != ERROR_FILE_NOT_FOUND)
1553 1553
         {
1554
-            MsgToEventLog(M_SYSERR, TEXT("ResetDnsSearchDomains: "
1555
-                                         "could not get InitialSearchList from registry (%lu)"), err);
1554
+            MsgToEventLog(M_SYSERR, L"%s: could not get InitialSearchList from registry (%lu)",
1555
+                          __func__, err);
1556 1556
         }
1557 1557
         goto out;
1558 1558
     }
... ...
@@ -1561,8 +1557,8 @@ ResetDnsSearchDomains(HKEY key)
1561 1561
     err = RegSetValueExW(key, L"SearchList", 0, REG_SZ, (PBYTE)list, size);
1562 1562
     if (err)
1563 1563
     {
1564
-        MsgToEventLog(M_SYSERR, TEXT("ResetDnsSearchDomains: "
1565
-                                     "could not set SearchList in registry (%lu)"), err);
1564
+        MsgToEventLog(M_SYSERR, L"%s: could not set SearchList in registry (%lu)",
1565
+                      __func__, err);
1566 1566
         goto out;
1567 1567
     }
1568 1568
 
... ...
@@ -1589,16 +1585,15 @@ RemoveDnsSearchDomains(HKEY key, PCWSTR domains)
1589 1589
     err = RegGetValueW(key, NULL, L"SearchList", RRF_RT_REG_SZ, NULL, list, &size);
1590 1590
     if (err)
1591 1591
     {
1592
-        MsgToEventLog(M_SYSERR, TEXT("RemoveDnsSearchDomains: "
1593
-                                     "could not get SearchList from registry (%lu)"), err);
1592
+        MsgToEventLog(M_SYSERR, L"%s: could not get SearchList from registry (%lu)",
1593
+                      __func__, err);
1594 1594
         return;
1595 1595
     }
1596 1596
 
1597 1597
     PWSTR dst = wcsstr(list, domains);
1598 1598
     if (!dst)
1599 1599
     {
1600
-        MsgToEventLog(M_ERR, TEXT("RemoveDnsSearchDomains: "
1601
-                                  "could not find domains in search list"));
1600
+        MsgToEventLog(M_ERR, L"%s: could not find domains in search list", __func__);
1602 1601
         return;
1603 1602
     }
1604 1603
 
... ...
@@ -1618,8 +1613,8 @@ RemoveDnsSearchDomains(HKEY key, PCWSTR domains)
1618 1618
         err = RegGetValueW(key, NULL, L"InitialSearchList", RRF_RT_REG_SZ, NULL, initial, &size);
1619 1619
         if (err)
1620 1620
         {
1621
-            MsgToEventLog(M_SYSERR, TEXT("RemoveDnsSearchDomains: "
1622
-                                         "could not get InitialSearchList from registry (%lu)"), err);
1621
+            MsgToEventLog(M_SYSERR, L"%s: could not get InitialSearchList from registry (%lu)",
1622
+                          __func__, err);
1623 1623
             return;
1624 1624
         }
1625 1625
 
... ...
@@ -1635,8 +1630,8 @@ RemoveDnsSearchDomains(HKEY key, PCWSTR domains)
1635 1635
     err = RegSetValueExW(key, L"SearchList", 0, REG_SZ, (PBYTE)list, size);
1636 1636
     if (err)
1637 1637
     {
1638
-        MsgToEventLog(M_SYSERR, TEXT("RemoveDnsSearchDomains: "
1639
-                                     "could not set SearchList in registry (%lu)"), err);
1638
+        MsgToEventLog(M_SYSERR, L"%s: could not set SearchList in registry (%lu)",
1639
+                      __func__, err);
1640 1640
     }
1641 1641
 }
1642 1642
 
... ...
@@ -1692,8 +1687,7 @@ SetDnsSearchDomains(PCSTR itf_name, PCSTR domains, PBOOL gpol, undo_lists_t *lis
1692 1692
     BOOL have_list = GetDnsSearchListKey(itf_name, gpol, &list_key);
1693 1693
     if (list_key == INVALID_HANDLE_VALUE)
1694 1694
     {
1695
-        MsgToEventLog(M_SYSERR, TEXT("SetDnsSearchDomains: "
1696
-                                     "could not get search list registry key"));
1695
+        MsgToEventLog(M_SYSERR, L"%s: could not get search list registry key", __func__);
1697 1696
         return ERROR_FILE_NOT_FOUND;
1698 1697
     }
1699 1698
 
... ...
@@ -1762,9 +1756,8 @@ GetInterfacesKey(short family, PHKEY key)
1762 1762
     if (err)
1763 1763
     {
1764 1764
         *key = INVALID_HANDLE_VALUE;
1765
-        MsgToEventLog(M_SYSERR, TEXT("GetInterfacesKey: "
1766
-                                     "could not open interfaces registry key for family %d (%lu)"),
1767
-                      family, err);
1765
+        MsgToEventLog(M_SYSERR, L"%s: could not open interfaces registry key for family %d (%lu)",
1766
+                      __func__, family, err);
1768 1767
     }
1769 1768
 
1770 1769
     return err ? FALSE : TRUE;
... ...
@@ -1794,18 +1787,16 @@ SetNameServersValue(PCWSTR itf_id, short family, PCSTR value)
1794 1794
     err = RegOpenKeyExW(itfs, itf_id, 0, KEY_ALL_ACCESS, &itf);
1795 1795
     if (err)
1796 1796
     {
1797
-        MsgToEventLog(M_SYSERR, TEXT("SetNameServersValue: "
1798
-                                     "could not open interface key for %s family %d (%lu)"),
1799
-                      itf_id, family, err);
1797
+        MsgToEventLog(M_SYSERR, L"%s: could not open interface key for %s family %d (%lu)",
1798
+                      __func__, itf_id, family, err);
1800 1799
         goto out;
1801 1800
     }
1802 1801
 
1803 1802
     err = RegSetValueExA(itf, "NameServer", 0, REG_SZ, (PBYTE)value, strlen(value) + 1);
1804 1803
     if (err)
1805 1804
     {
1806
-        MsgToEventLog(M_SYSERR, TEXT("SetNameServersValue: "
1807
-                                     "could not set name servers '%S' for %s family %d (%lu)"),
1808
-                      value, itf_id, family, err);
1805
+        MsgToEventLog(M_SYSERR, L"%s: could not set name servers '%S' for %s family %d (%lu)",
1806
+                      __func__, value, itf_id, family, err);
1809 1807
     }
1810 1808
 
1811 1809
 out: