diff --git a/winpr/include/winpr/cmdline.h b/winpr/include/winpr/cmdline.h
index 24d22d46e..a88d49404 100644
--- a/winpr/include/winpr/cmdline.h
+++ b/winpr/include/winpr/cmdline.h
@@ -159,7 +159,7 @@ extern "C"
/** @brief free arrays allocated by CommandLineParseCommaSeparatedValues(Ex)
*
- * @param ptr the pointer to free, may be \b NULL
+ * @param ptr the pointer to free, may be \b nullptr
*
* @since version 3.10.0
*/
diff --git a/winpr/include/winpr/collections.h b/winpr/include/winpr/collections.h
index d74ab638f..b090f7a0f 100644
--- a/winpr/include/winpr/collections.h
+++ b/winpr/include/winpr/collections.h
@@ -63,14 +63,14 @@ extern "C"
/** @brief helper function to clone a string
* @param pvstr the source string to clone
- * @return A clone of the source or \b NULL
+ * @return A clone of the source or \b nullptr
* @since version 3.3.0
*/
WINPR_API void* winpr_ObjectStringClone(const void* pvstr);
/** @brief helper function to clone a WCHAR string
* @param pvstr the source string to clone
- * @return A clone of the source or \b NULL
+ * @return A clone of the source or \b nullptr
* @since version 3.3.0
*/
WINPR_API void* winpr_ObjectWStringClone(const void* pvstr);
@@ -87,7 +87,7 @@ extern "C"
/** @brief Return the number of elements in the queue
*
- * @param queue A pointer to a queue, must not be \b NULL
+ * @param queue A pointer to a queue, must not be \b nullptr
*
* @return the number of objects queued
*/
@@ -95,7 +95,7 @@ extern "C"
/** @brief Return the allocated elements in the queue
*
- * @param queue A pointer to a queue, must not be \b NULL
+ * @param queue A pointer to a queue, must not be \b nullptr
*
* @return the number of objects allocated
*/
@@ -103,26 +103,26 @@ extern "C"
/** @brief Mutex-Lock a queue
*
- * @param queue A pointer to a queue, must not be \b NULL
+ * @param queue A pointer to a queue, must not be \b nullptr
*/
WINPR_API void Queue_Lock(wQueue* queue);
/** @brief Mutex-Unlock a queue
*
- * @param queue A pointer to a queue, must not be \b NULL
+ * @param queue A pointer to a queue, must not be \b nullptr
*/
WINPR_API void Queue_Unlock(wQueue* queue);
/** @brief Get an event handle for the queue, usable by \b WaitForSingleObject or \b
* WaitForMultipleObjects
*
- * @param queue A pointer to a queue, must not be \b NULL
+ * @param queue A pointer to a queue, must not be \b nullptr
*/
WINPR_API HANDLE Queue_Event(wQueue* queue);
/** @brief Mutex-Lock a queue
*
- * @param queue A pointer to a queue, must not be \b NULL
+ * @param queue A pointer to a queue, must not be \b nullptr
*
* @return A pointer to a \b wObject that contains the allocation/cleanup handlers for queue
* elements
@@ -131,13 +131,13 @@ extern "C"
/** @brief Remove all elements from a queue, call \b wObject cleanup functions \b fnObjectFree
*
- * @param queue A pointer to a queue, must not be \b NULL
+ * @param queue A pointer to a queue, must not be \b nullptr
*/
WINPR_API void Queue_Clear(wQueue* queue);
/** @brief Check if the queue contains an object
*
- * @param queue A pointer to a queue, must not be \b NULL
+ * @param queue A pointer to a queue, must not be \b nullptr
* @param obj The object to look for. \b fnObjectEquals is called internally
*
* @return \b TRUE if the object was found, \b FALSE otherwise.
@@ -160,7 +160,7 @@ extern "C"
*
* \param queue The queue to check
*
- * \return NULL if empty, a pointer to the memory on top of the queue otherwise.
+ * \return nullptr if empty, a pointer to the memory on top of the queue otherwise.
*/
WINPR_API void* Queue_Dequeue(wQueue* queue);
@@ -169,7 +169,7 @@ extern "C"
*
* \param queue The queue to check
*
- * \return NULL if empty, a pointer to the memory on top of the queue otherwise.
+ * \return nullptr if empty, a pointer to the memory on top of the queue otherwise.
*/
WINPR_API void* Queue_Peek(wQueue* queue);
@@ -184,7 +184,7 @@ extern "C"
/** @brief Clean up a queue, free all resources (e.g. calls \b Queue_Clear)
*
- * @param queue The queue to free, may be \b NULL
+ * @param queue The queue to free, may be \b nullptr
*/
WINPR_API void Queue_Free(wQueue* queue);
@@ -198,7 +198,7 @@ extern "C"
* values increase the allocation contingent. \b 0 or \b -1 apply default settings.
*
*
- * @return A newly allocated queue or \b NULL in case of failure
+ * @return A newly allocated queue or \b nullptr in case of failure
*/
WINPR_ATTR_MALLOC(Queue_Free, 1)
WINPR_ATTR_NODISCARD
@@ -282,23 +282,23 @@ extern "C"
/** @brief Get the \b wObject function pointer struct for the \b key of the dictionary.
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
*
- * @return a \b wObject used to initialize the key object, \b NULL in case of failure
+ * @return a \b wObject used to initialize the key object, \b nullptr in case of failure
*/
WINPR_API wObject* ListDictionary_KeyObject(wListDictionary* listDictionary);
/** @brief Get the \b wObject function pointer struct for the \b value of the dictionary.
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
*
- * @return a \b wObject used to initialize the value object, \b NULL in case of failure
+ * @return a \b wObject used to initialize the value object, \b nullptr in case of failure
*/
WINPR_API wObject* ListDictionary_ValueObject(wListDictionary* listDictionary);
/** @brief Return the number of entries in the dictionary
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
*
* @return the number of entries
*/
@@ -306,20 +306,20 @@ extern "C"
/** @brief mutex-lock a dictionary
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
*/
WINPR_API void ListDictionary_Lock(wListDictionary* listDictionary);
/** @brief mutex-unlock a dictionary
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
*/
WINPR_API void ListDictionary_Unlock(wListDictionary* listDictionary);
/** @brief mutex-lock a dictionary
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
* @param key The key identifying the entry, if set cloned with \b fnObjectNew
- * @param value The value to store for the \b key. May be \b NULL. if set cloned with \b
+ * @param value The value to store for the \b key. May be \b nullptr. if set cloned with \b
* fnObjectNew
*
* @return \b TRUE for successful addition, \b FALSE for failure
@@ -329,16 +329,16 @@ extern "C"
/** @brief Remove an item from the dictionary and return the value. Cleanup is up to the caller.
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
* @param key The key identifying the entry
*
- * @return a pointer to the value stored or \b NULL in case of failure or not found
+ * @return a pointer to the value stored or \b nullptr in case of failure or not found
*/
WINPR_API void* ListDictionary_Take(wListDictionary* listDictionary, const void* key);
/** @brief Remove an item from the dictionary and call \b fnObjectFree for key and value
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
* @param key The key identifying the entry
*/
WINPR_API void ListDictionary_Remove(wListDictionary* listDictionary, const void* key);
@@ -346,27 +346,27 @@ extern "C"
/** @brief Remove the head item from the dictionary and return the value. Cleanup is up to the
* caller.
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
*
- * @return a pointer to the value stored or \b NULL in case of failure or not found
+ * @return a pointer to the value stored or \b nullptr in case of failure or not found
*/
WINPR_API void* ListDictionary_Take_Head(wListDictionary* listDictionary);
/** @brief Remove the head item from the dictionary and call \b fnObjectFree for key and value
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
*/
WINPR_API void ListDictionary_Remove_Head(wListDictionary* listDictionary);
/** @brief Remove all items from the dictionary and call \b fnObjectFree for key and value
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
*/
WINPR_API void ListDictionary_Clear(wListDictionary* listDictionary);
/** @brief Check if a dictionary contains \b key (\b fnObjectEquals of the key object is called)
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
* @param key A key to look for
*
* @return \b TRUE if found, \b FALSE otherwise
@@ -375,28 +375,28 @@ extern "C"
/** @brief return all keys the dictionary contains
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
* @param ppKeys A pointer to a \b ULONG_PTR array that will hold the result keys. Call \b free
* if no longer required
*
- * @return the number of keys found in the dictionary or \b 0 if \b ppKeys is \b NULL
+ * @return the number of keys found in the dictionary or \b 0 if \b ppKeys is \b nullptr
*/
WINPR_API size_t ListDictionary_GetKeys(wListDictionary* listDictionary, ULONG_PTR** ppKeys);
/** @brief Get the value in the dictionary for a \b key. The ownership of the data stays with
* the dictionary.
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
* @param key A key to look for (\b fnObjectEquals of the key object is called)
*
- * @return A pointer to the data in the dictionary or \b NULL if not found
+ * @return A pointer to the data in the dictionary or \b nullptr if not found
*/
WINPR_API void* ListDictionary_GetItemValue(wListDictionary* listDictionary, const void* key);
/** @brief Set the value in the dictionary for a \b key. The entry must already exist, \b value
* is copied if \b fnObjectNew is set
*
- * @param listDictionary A dictionary to query, must not be \b NULL
+ * @param listDictionary A dictionary to query, must not be \b nullptr
* @param key A key to look for (\b fnObjectEquals of the key object is called)
* @param value A pointer to the value to set
*
@@ -407,7 +407,7 @@ extern "C"
/** @brief Free memory allocated by a dictionary. Calls \b ListDictionary_Clear
*
- * @param listDictionary A dictionary to query, may be \b NULL
+ * @param listDictionary A dictionary to query, may be \b nullptr
*/
WINPR_API void ListDictionary_Free(wListDictionary* listDictionary);
@@ -415,7 +415,7 @@ extern "C"
*
* @param synchronized Create the dictionary with automatic mutex lock
*
- * @return A newly allocated dictionary or \b NULL in case of failure
+ * @return A newly allocated dictionary or \b nullptr in case of failure
*/
WINPR_ATTR_MALLOC(ListDictionary_Free, 1)
WINPR_ATTR_NODISCARD
@@ -427,7 +427,7 @@ extern "C"
/** @brief Return the current number of elements in the linked list
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
* @return the number of elements in the list
*/
@@ -435,23 +435,23 @@ extern "C"
/** @brief Return the first element of the list, ownership stays with the list
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
- * @return A pointer to the element or \b NULL if empty
+ * @return A pointer to the element or \b nullptr if empty
*/
WINPR_API void* LinkedList_First(wLinkedList* list);
/** @brief Return the last element of the list, ownership stays with the list
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
- * @return A pointer to the element or \b NULL if empty
+ * @return A pointer to the element or \b nullptr if empty
*/
WINPR_API void* LinkedList_Last(wLinkedList* list);
/** @brief Check if the linked list contains a value
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
* @param value A value to check for
*
* @return \b TRUE if found, \b FALSE otherwise
@@ -461,7 +461,7 @@ extern "C"
/** @brief Remove all elements of the linked list. \b fnObjectUninit and \b fnObjectFree are
* called for each entry
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
*/
WINPR_API void LinkedList_Clear(wLinkedList* list);
@@ -469,7 +469,7 @@ extern "C"
/** @brief Add a new element at the start of the linked list. \b fnObjectNew and \b fnObjectInit
* is called for the new entry
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
* @param value The value to add
*
* @return \b TRUE if successful, \b FALSE otherwise.
@@ -479,7 +479,7 @@ extern "C"
/** @brief Add a new element at the end of the linked list. \b fnObjectNew and \b fnObjectInit
* is called for the new entry
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
* @param value The value to add
*
* @return \b TRUE if successful, \b FALSE otherwise.
@@ -489,7 +489,7 @@ extern "C"
/** @brief Remove a element identified by \b value from the linked list. \b fnObjectUninit and
* \b fnObjectFree is called for the entry
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
* @param value The value to remove
*
* @return \b TRUE if successful, \b FALSE otherwise.
@@ -499,7 +499,7 @@ extern "C"
/** @brief Remove the first element from the linked list. \b fnObjectUninit and \b fnObjectFree
* is called for the entry
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
*/
WINPR_API void LinkedList_RemoveFirst(wLinkedList* list);
@@ -507,29 +507,29 @@ extern "C"
/** @brief Remove the last element from the linked list. \b fnObjectUninit and \b fnObjectFree
* is called for the entry
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
*/
WINPR_API void LinkedList_RemoveLast(wLinkedList* list);
/** @brief Move enumerator to the first element
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
*/
WINPR_API void LinkedList_Enumerator_Reset(wLinkedList* list);
/** @brief Return the value for the current position of the enumerator
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
- * @return A pointer to the current entry or \b NULL
+ * @return A pointer to the current entry or \b nullptr
*/
WINPR_API void* LinkedList_Enumerator_Current(wLinkedList* list);
/** @brief Move enumerator to the next element
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
* @return \b TRUE if the move was successful, \b FALSE if not (e.g. no more entries)
*/
@@ -537,13 +537,13 @@ extern "C"
/** @brief Free a linked list
*
- * @param list A pointer to the list, may be \b NULL
+ * @param list A pointer to the list, may be \b nullptr
*/
WINPR_API void LinkedList_Free(wLinkedList* list);
/** @brief Allocate a linked list
*
- * @return A pointer to the newly allocated linked list or \b NULL in case of failure
+ * @return A pointer to the newly allocated linked list or \b nullptr in case of failure
*/
WINPR_ATTR_MALLOC(LinkedList_Free, 1)
WINPR_ATTR_NODISCARD
@@ -551,9 +551,9 @@ extern "C"
/** @brief Return the \b wObject function pointers for list elements
*
- * @param list A pointer to the list, must not be \b NULL
+ * @param list A pointer to the list, must not be \b nullptr
*
- * @return A pointer to the wObject or \b NULL in case of failure
+ * @return A pointer to the wObject or \b nullptr in case of failure
*/
WINPR_API wObject* LinkedList_Object(wLinkedList* list);
@@ -565,7 +565,7 @@ extern "C"
/** @brief return the current event count of the CountdownEvent
*
- * @param countdown A pointer to a CountdownEvent, must not be \b NULL
+ * @param countdown A pointer to a CountdownEvent, must not be \b nullptr
*
* @return The current event count
*/
@@ -573,7 +573,7 @@ extern "C"
/** @brief return the initial event count of the CountdownEvent
*
- * @param countdown A pointer to a CountdownEvent, must not be \b NULL
+ * @param countdown A pointer to a CountdownEvent, must not be \b nullptr
*
* @return The initial event count
*/
@@ -581,7 +581,7 @@ extern "C"
/** @brief return the current event state of the CountdownEvent
*
- * @param countdown A pointer to a CountdownEvent, must not be \b NULL
+ * @param countdown A pointer to a CountdownEvent, must not be \b nullptr
*
* @return \b TRUE if set, \b FALSE otherwise
*/
@@ -590,15 +590,15 @@ extern "C"
/** @brief return the event HANDLE of the CountdownEvent to be used by \b WaitForSingleObject or
* \b WaitForMultipleObjects
*
- * @param countdown A pointer to a CountdownEvent, must not be \b NULL
+ * @param countdown A pointer to a CountdownEvent, must not be \b nullptr
*
- * @return a \b HANDLE or \b NULL in case of failure
+ * @return a \b HANDLE or \b nullptr in case of failure
*/
WINPR_API HANDLE CountdownEvent_WaitHandle(wCountdownEvent* countdown);
/** @brief add \b signalCount to the current event count of the CountdownEvent
*
- * @param countdown A pointer to a CountdownEvent, must not be \b NULL
+ * @param countdown A pointer to a CountdownEvent, must not be \b nullptr
* @param signalCount The amount to add to CountdownEvent
*
*/
@@ -606,7 +606,7 @@ extern "C"
/** @brief Increase the current event signal state of the CountdownEvent
*
- * @param countdown A pointer to a CountdownEvent, must not be \b NULL
+ * @param countdown A pointer to a CountdownEvent, must not be \b nullptr
* @param signalCount The amount of signaled events to add
*
* @return \b TRUE if event is set, \b FALSE otherwise
@@ -615,14 +615,14 @@ extern "C"
/** @brief reset the CountdownEvent
*
- * @param countdown A pointer to a CountdownEvent, must not be \b NULL
+ * @param countdown A pointer to a CountdownEvent, must not be \b nullptr
*
*/
WINPR_API void CountdownEvent_Reset(wCountdownEvent* countdown, size_t count);
/** @brief Free a CountdownEvent
*
- * @param countdown A pointer to a CountdownEvent, may be \b NULL
+ * @param countdown A pointer to a CountdownEvent, may be \b nullptr
*/
WINPR_API void CountdownEvent_Free(wCountdownEvent* countdown);
@@ -630,7 +630,7 @@ extern "C"
*
* @param initialCount The initial value of the event
*
- * @return The newly allocated event or \b NULL in case of failure
+ * @return The newly allocated event or \b nullptr in case of failure
*/
WINPR_ATTR_MALLOC(CountdownEvent_Free, 1)
WINPR_ATTR_NODISCARD
@@ -746,7 +746,7 @@ extern "C"
/** @brief return the currently used number of elements in the queue
*
- * @param queue A pointer to the queue to query. Must not be \b NULL
+ * @param queue A pointer to the queue to query. Must not be \b nullptr
*
* @return The number of elements in the queue
*/
@@ -754,7 +754,7 @@ extern "C"
/** @brief return the currently allocated elements in the queue
*
- * @param queue A pointer to the queue to query. Must not be \b NULL
+ * @param queue A pointer to the queue to query. Must not be \b nullptr
*
* @return The number of currently allocated elements in the queue
*/
@@ -801,9 +801,9 @@ extern "C"
* 'MessageQueue_Clear'.
*
* \param callback a pointer to custom initialization / cleanup functions.
- * Can be NULL if not used.
+ * Can be nullptr if not used.
*
- * \return A pointer to a newly allocated MessageQueue or NULL.
+ * \return A pointer to a newly allocated MessageQueue or nullptr.
*/
WINPR_ATTR_MALLOC(MessageQueue_Free, 1)
WINPR_ATTR_NODISCARD
@@ -892,12 +892,12 @@ extern "C"
DEFINE_EVENT_SUBSCRIBE(name) \
DEFINE_EVENT_UNSUBSCRIBE(name)
-#define DEFINE_EVENT_ENTRY(name) \
- { \
-#name, { sizeof(name##EventArgs), NULL }, 0, \
- { \
- NULL \
- } \
+#define DEFINE_EVENT_ENTRY(name) \
+ { \
+ #name, { sizeof(name##EventArgs), nullptr }, 0, \
+ { \
+ nullptr \
+ } \
}
typedef struct s_wPubSub wPubSub;
diff --git a/winpr/include/winpr/crt.h b/winpr/include/winpr/crt.h
index 521f77943..e4dba7230 100644
--- a/winpr/include/winpr/crt.h
+++ b/winpr/include/winpr/crt.h
@@ -240,7 +240,8 @@ extern "C"
#endif /* !defined(_WIN32) || (defined(__MINGW32__) ... */
#if defined(_WIN32) && (!defined(__MINGW32__) || defined(_UCRT))
-#define winpr_aligned_calloc(count, size, alignment) _aligned_recalloc(NULL, count, size, alignment)
+#define winpr_aligned_calloc(count, size, alignment) \
+ _aligned_recalloc(nullptr, count, size, alignment)
#endif /* defined(_WIN32) && (!defined(__MINGW32__) || defined(_UCRT)) */
// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
diff --git a/winpr/include/winpr/custom-crypto.h b/winpr/include/winpr/custom-crypto.h
index aced0aa3a..56248f29e 100644
--- a/winpr/include/winpr/custom-crypto.h
+++ b/winpr/include/winpr/custom-crypto.h
@@ -288,7 +288,7 @@ extern "C"
* @param iv A pointer to the IV material (size must match expectations for the cipher used)
* @param ivlen The length in bytes of the IV
*
- * @return A newly allocated context or \b NULL
+ * @return A newly allocated context or \b nullptr
*
* @since version 3.10.0
*/
diff --git a/winpr/include/winpr/image.h b/winpr/include/winpr/image.h
index a25801771..56428d756 100644
--- a/winpr/include/winpr/image.h
+++ b/winpr/include/winpr/image.h
@@ -133,8 +133,8 @@ extern "C"
*
* @since version 3.3.0
*
- * @return \b NULL in case of failure, a pointer to an allocated buffer otherwise. Use \b free
- * as deallocator
+ * @return \b nullptr in case of failure, a pointer to an allocated buffer otherwise. Use \b
+ * free as deallocator
*/
WINPR_ATTR_MALLOC(free, 1)
WINPR_ATTR_NODISCARD
@@ -163,7 +163,7 @@ extern "C"
*
* @since version 3.3.0
*
- * @return a extension string if format has one or \b NULL
+ * @return a extension string if format has one or \b nullptr
*/
WINPR_API const char* winpr_image_format_extension(UINT32 format);
@@ -173,7 +173,7 @@ extern "C"
*
* @since version 3.3.0
*
- * @return a mime type string if format has one or \b NULL
+ * @return a mime type string if format has one or \b nullptr
*/
WINPR_API const char* winpr_image_format_mime(UINT32 format);
diff --git a/winpr/include/winpr/ini.h b/winpr/include/winpr/ini.h
index b88a161dc..30d28d283 100644
--- a/winpr/include/winpr/ini.h
+++ b/winpr/include/winpr/ini.h
@@ -32,7 +32,7 @@ extern "C"
/** @brief read an ini file from a buffer
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
* @param buffer The buffer to read from, must be a '\0' terminated string.
*
* @return > 0 for success, < 0 for failure
@@ -41,7 +41,7 @@ extern "C"
/** @brief read an ini file from a file
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
* @param filename The name of the file to read from, must be a '\0' terminated string.
*
* @return > 0 for success, < 0 for failure
@@ -50,15 +50,15 @@ extern "C"
/** @brief write an ini instance to a buffer
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
*
- * @return A newly allocated string, use \b free after use. \b NULL in case of failure
+ * @return A newly allocated string, use \b free after use. \b nullptr in case of failure
*/
WINPR_API char* IniFile_WriteBuffer(wIniFile* ini);
/** @brief write an ini instance to a file
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
* @param filename The name of the file as '\0' terminated string.
*
* @return > 0 for success, < 0 for failure
@@ -67,7 +67,7 @@ extern "C"
/** @brief Get the number and names of sections in the ini instance
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
* @param count A buffer that will contain the number of sections
*
* @return A newly allocated array of strings (size \b count). Use \b free after use
@@ -76,7 +76,7 @@ extern "C"
/** @brief Get the number and names of keys of a section in the ini instance
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
* @param section The name of the section as '\0' terminated string.
* @param count A buffer that will contain the number of sections
*
@@ -86,18 +86,18 @@ extern "C"
/** @brief Get an ini [section/key] value of type string
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
* @param section The name of the section as '\0' terminated string.
* @param key The name of the key as '\0' terminated string.
*
- * @return The value of the [section/key] as '\0' terminated string or \b NULL
+ * @return The value of the [section/key] as '\0' terminated string or \b nullptr
*/
WINPR_API const char* IniFile_GetKeyValueString(wIniFile* ini, const char* section,
const char* key);
/** @brief Get an ini [section/key] value of type int
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
* @param section The name of the section as '\0' terminated string.
* @param key The name of the key as '\0' terminated string.
*
@@ -107,7 +107,7 @@ extern "C"
/** @brief Set an ini [section/key] value of type string
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
* @param section The name of the section as '\0' terminated string.
* @param key The name of the key as '\0' terminated string.
* @param value The value of the [section/key] as '\0' terminated string.
@@ -119,7 +119,7 @@ extern "C"
/** @brief Set an ini [section/key] value of type int
*
- * @param ini The instance to use, must not be \b NULL
+ * @param ini The instance to use, must not be \b nullptr
* @param section The name of the section as '\0' terminated string.
* @param key The name of the key as '\0' terminated string.
* @param value The value of the [section/key]
@@ -131,13 +131,13 @@ extern "C"
/** @brief Free a ini instance
*
- * @param ini The instance to free, may be \b NULL
+ * @param ini The instance to free, may be \b nullptr
*/
WINPR_API void IniFile_Free(wIniFile* ini);
/** @brief Create a new ini instance
*
- * @return The newly allocated instance or \b NULL if failed.
+ * @return The newly allocated instance or \b nullptr if failed.
*/
WINPR_ATTR_MALLOC(IniFile_Free, 1)
WINPR_ATTR_NODISCARD
@@ -145,9 +145,9 @@ extern "C"
/** @brief Clone a ini instance
*
- * @param ini The instance to free, may be \b NULL
+ * @param ini The instance to free, may be \b nullptr
*
- * @return the cloned instance or \b NULL in case of \b ini was \b NULL or failure
+ * @return the cloned instance or \b nullptr in case of \b ini was \b nullptr or failure
*/
WINPR_API wIniFile* IniFile_Clone(const wIniFile* ini);
diff --git a/winpr/include/winpr/json.h b/winpr/include/winpr/json.h
index bae406710..63a6ee3be 100644
--- a/winpr/include/winpr/json.h
+++ b/winpr/include/winpr/json.h
@@ -60,7 +60,7 @@ extern "C"
* @brief Parse a '\0' terminated JSON string
*
* @param value A '\0' terminated JSON string
- * @return A @ref WINPR_JSON object holding the parsed string or \b NULL if failed
+ * @return A @ref WINPR_JSON object holding the parsed string or \b nullptr if failed
* @since version 3.6.0
*/
WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
@@ -72,7 +72,7 @@ extern "C"
*
* @param value A JSON string
* @param buffer_length The length in bytes of the JSON string
- * @return A @ref WINPR_JSON object holding the parsed string or \b NULL if failed
+ * @return A @ref WINPR_JSON object holding the parsed string or \b nullptr if failed
* @since version 3.6.0
*/
WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
@@ -83,7 +83,7 @@ extern "C"
* @brief Parse a JSON string read from a file \b filename
*
* @param filename the name of the file to read from
- * @return A @ref WINPR_JSON object holding the parsed string or \b NULL if failed
+ * @return A @ref WINPR_JSON object holding the parsed string or \b nullptr if failed
* @since version 3.16.0
*/
WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
@@ -94,7 +94,7 @@ extern "C"
* @brief Parse a JSON string read from a \b FILE
*
* @param fp a \b FILE pointer to read from.
- * @return A @ref WINPR_JSON object holding the parsed string or \b NULL if failed
+ * @return A @ref WINPR_JSON object holding the parsed string or \b nullptr if failed
* @since version 3.16.0
*/
WINPR_ATTR_MALLOC(WINPR_JSON_Delete, 1)
@@ -115,7 +115,7 @@ extern "C"
*
* @param array the JSON instance to query
* @param index The index of the array item
- * @return A pointer to the array item or \b NULL if failed
+ * @return A pointer to the array item or \b nullptr if failed
* @since version 3.6.0
*/
WINPR_API WINPR_JSON* WINPR_JSON_GetArrayItem(const WINPR_JSON* array, size_t index);
@@ -125,7 +125,7 @@ extern "C"
* @param object the JSON object
* @param string the name of the object (case is ignored)
*
- * @return A pointer to the object identified by \b string or \b NULL
+ * @return A pointer to the object identified by \b string or \b nullptr
* @since version 3.6.0
*/
WINPR_API WINPR_JSON* WINPR_JSON_GetObjectItem(const WINPR_JSON* object, const char* string);
@@ -135,7 +135,7 @@ extern "C"
*
* @param object the JSON instance to query
* @param string the name of the object
- * @return A pointer to the object identified by \b string or \b NULL
+ * @return A pointer to the object identified by \b string or \b nullptr
* @since version 3.6.0
*/
WINPR_API WINPR_JSON* WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON* object,
@@ -152,7 +152,7 @@ extern "C"
/**
* @brief Return an error string
- * @return A string describing the last error that occurred or \b NULL
+ * @return A string describing the last error that occurred or \b nullptr
* @since version 3.6.0
*/
WINPR_API const char* WINPR_JSON_GetErrorPtr(void);
@@ -160,7 +160,7 @@ extern "C"
/**
* @brief Return the String value of a JSON item
* @param item the JSON item to query
- * @return The string value or \b NULL if failed
+ * @return The string value or \b nullptr if failed
* @since version 3.6.0
*/
WINPR_API const char* WINPR_JSON_GetStringValue(WINPR_JSON* item);
@@ -391,8 +391,8 @@ extern "C"
/**
* @brief Add an item to an existing array
- * @param array An array to add to, must not be \b NULL
- * @param item An item to add, must not be \b NULL
+ * @param array An array to add to, must not be \b nullptr
+ * @param item An item to add, must not be \b nullptr
* @return \b TRUE for success, \b FALSE for failure
* @since version 3.7.0
*/
@@ -403,7 +403,7 @@ extern "C"
* for minimal size without formatting see @ref WINPR_JSON_PrintUnformatted
*
* @param item The JSON instance to serialize
- * @return A string representation of the JSON instance or \b NULL
+ * @return A string representation of the JSON instance or \b nullptr
* @since version 3.6.0
*/
WINPR_ATTR_MALLOC(free, 1)
@@ -415,7 +415,7 @@ extern "C"
* for human readable formatted output see @ref WINPR_JSON_Print
*
* @param item The JSON instance to serialize
- * @return A string representation of the JSON instance or \b NULL
+ * @return A string representation of the JSON instance or \b nullptr
* @since version 3.6.0
*/
WINPR_ATTR_MALLOC(free, 1)
diff --git a/winpr/include/winpr/library.h b/winpr/include/winpr/library.h
index 15bb84947..1fe54e60a 100644
--- a/winpr/include/winpr/library.h
+++ b/winpr/include/winpr/library.h
@@ -91,7 +91,7 @@ extern "C"
* @param name The name of the function
* @param type The type of the function pointer
* @since version 3.9.0
- * @return A new function pointer or \b NULL
+ * @return A new function pointer or \b nullptr
*/
#define GetProcAddressAs(module, name, type) WINPR_FUNC_PTR_CAST(GetProcAddress(module, name), type)
diff --git a/winpr/include/winpr/ncrypt.h b/winpr/include/winpr/ncrypt.h
index 6b182333c..c5ff19861 100644
--- a/winpr/include/winpr/ncrypt.h
+++ b/winpr/include/winpr/ncrypt.h
@@ -203,7 +203,7 @@ extern "C"
*
* @param phProvider [out] resulting provider handle
* @param dwFlags [in] the flags to use
- * @param modulePaths [in] an array of library path to try to load ended with a NULL string
+ * @param modulePaths [in] an array of library path to try to load ended with a nullptr string
* @return ERROR_SUCCESS or an NTE error code something failed
*/
WINPR_API SECURITY_STATUS winpr_NCryptOpenStorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
diff --git a/winpr/include/winpr/path.h b/winpr/include/winpr/path.h
index 620cb4934..ea0d5a2a6 100644
--- a/winpr/include/winpr/path.h
+++ b/winpr/include/winpr/path.h
@@ -46,7 +46,7 @@ extern "C"
/*
* Maximum number of characters we support using the "\\?\" syntax
- * (0x7FFF + 1 for NULL terminator)
+ * (0x7FFF + 1 for nullptr terminator)
*/
#define PATHCCH_MAX_CCH 0x8000
@@ -310,14 +310,14 @@ extern "C"
#endif
/** @brief Return the absolute path of a configuration file (the path of the configuration
- * directory if \b filename is \b NULL)
+ * directory if \b filename is \b nullptr)
*
* @param system a boolean indicating the configuration base, \b TRUE for system configuration,
* \b FALSE for user configuration
* @param filename an optional configuration file name to append.
*
- * @return The absolute path of the desired configuration or \b NULL in case of failure. Use \b
- * free to clean up the allocated string.
+ * @return The absolute path of the desired configuration or \b nullptr in case of failure. Use
+ * \b free to clean up the allocated string.
*
*
* @since version 3.9.0
@@ -329,10 +329,10 @@ extern "C"
/** @brief Get a config file sub path with a formatting argument constructing the filename
*
* @param system \b TRUE to return a system config path
- * @param filename The format string to generate the filename. Must not be \b NULL. Must not
+ * @param filename The format string to generate the filename. Must not be \b nullptr. Must not
* contain any forbidden characters.
*
- * @return A (absolute) configuration file path or \b NULL in case of failure.
+ * @return A (absolute) configuration file path or \b nullptr in case of failure.
* @since version 3.23.0
*/
WINPR_ATTR_MALLOC(free, 1)
@@ -344,11 +344,11 @@ extern "C"
/** @brief Get a config file sub path with a formatting argument constructing the filename
*
* @param system \b TRUE to return a system config path
- * @param filename The format string to generate the filename. Must not be \b NULL. Must not
+ * @param filename The format string to generate the filename. Must not be \b nullptr. Must not
* contain any forbidden characters.
* @param ap The argument list
*
- * @return A (absolute) configuration file path or \b NULL in case of failure.
+ * @return A (absolute) configuration file path or \b nullptr in case of failure.
* @since version 3.23.0
*/
WINPR_ATTR_MALLOC(free, 1)
@@ -370,9 +370,9 @@ extern "C"
/** @brief Append a path to some existing known path type.
*
* @param id a \ref eKnownPathTypes known path id
- * @param path the format string generating the subpath. Must not be \b NULL
+ * @param path the format string generating the subpath. Must not be \b nullptr
*
- * @return A string of combined \b id path and \b path or \b NULL in case of an error.
+ * @return A string of combined \b id path and \b path or \b nullptr in case of an error.
* @since version 3.23.0
*/
WINPR_ATTR_MALLOC(free, 1)
@@ -383,10 +383,10 @@ extern "C"
/** @brief Append a path to some existing known path type.
*
* @param id a \ref eKnownPathTypes known path id
- * @param path the format string generating the subpath. Must not be \b NULL
+ * @param path the format string generating the subpath. Must not be \b nullptr
* @param ap a va_list containing the format string arguments
- * * @return A string of combined \b basePath and \b path or \b NULL in case of an
- * error.
+ * * @return A string of combined \b basePath and \b path or \b nullptr in case of
+ * an error.
* * @version since 3.23.0
*/
WINPR_ATTR_MALLOC(free, 1)
@@ -404,10 +404,10 @@ extern "C"
/** @brief Append a path to some existing environment name.
*
- * @param name The prefix path to use, must not be \b NULL
- * @param path A format string used to generate the path to append. Must not be \b NULL
+ * @param name The prefix path to use, must not be \b nullptr
+ * @param path A format string used to generate the path to append. Must not be \b nullptr
*
- * @return A string of combined \b basePath and \b path or \b NULL in case of an error.
+ * @return A string of combined \b basePath and \b path or \b nullptr in case of an error.
* @version since 3.23.0
*/
WINPR_ATTR_MALLOC(free, 1)
@@ -417,11 +417,12 @@ extern "C"
/** @brief Append a path to some existing environment name.
*
- * @param name The prefix path to use, must not be \b NULL
- * @param path A format string used to generate the path to append. Must not be \b NULL
+ * @param name The prefix path to use, must not be \b nullptr
+ * @param path A format string used to generate the path to append. Must not be \b nullptr
* @param ap a va_list containing the format string arguments
*
- * @return A string of combined \b basePath and \b path or \b NULL in case of an error.
+ * @return A string of combined \b basePath and \b path or \b nullptr in case of an
+ * error.
* * @version since 3.23.0
*/
WINPR_ATTR_MALLOC(free, 1)
@@ -439,10 +440,12 @@ extern "C"
*
* @bug before version 3.23.0 the function did not allow subPath to be a format string.
*
- * @param basePath The prefix path to use, must not be \b NULL
- * @param subPathFmt A format string used to generate the path to append. Must not be \b NULL
+ * @param basePath The prefix path to use, must not be \b nullptr
+ * @param subPathFmt A format string used to generate the path to append. Must not be \b
+ * nullptr
*
- * @return A string of combined \b basePath and \b subPathFmt or \b NULL in case of an error.
+ * @return A string of combined \b basePath and \b subPathFmt or \b nullptr in case of an
+ * error.
*/
WINPR_ATTR_MALLOC(free, 1)
WINPR_ATTR_NODISCARD
@@ -453,11 +456,13 @@ extern "C"
/** @brief Append a path to some existing path. A system dependent path separator will be added
* automatically.
*
- * @param basePath The prefix path to use, must not be \b NULL
- * @param subPathFmt A format string used to generate the path to append. Must not be \b NULL
+ * @param basePath The prefix path to use, must not be \b nullptr
+ * @param subPathFmt A format string used to generate the path to append. Must not be \b
+ * nullptr
* @param ap a va_list containing the format string arguments
*
- * @return A string of combined \b basePath and \b subPathFmt or \b NULL in case of an error.
+ * @return A string of combined \b basePath and \b subPathFmt or \b nullptr in case of an
+ * error.
* @version since 3.23.0
*/
WINPR_ATTR_MALLOC(free, 1)
diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h
index b6833ad69..17294076f 100644
--- a/winpr/include/winpr/stream.h
+++ b/winpr/include/winpr/stream.h
@@ -58,7 +58,7 @@ extern "C"
*/
static inline wStream Stream_Init(void)
{
- const wStream empty = { NULL, NULL, 0, 0, 0, NULL, FALSE, FALSE };
+ const wStream empty = { nullptr, nullptr, 0, 0, 0, nullptr, FALSE, FALSE };
return empty;
}
@@ -820,7 +820,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_INT8 instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_INT8_unchecked(wStream* _s, INT8 _v)
@@ -845,7 +845,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_UINT8 instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_UINT8_unchecked(wStream* _s, UINT8 _v)
@@ -871,7 +871,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_INT16 instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_INT16_unchecked(wStream* _s, INT16 _v)
@@ -897,7 +897,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_UINT16 instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_UINT16_unchecked(wStream* _s, UINT16 _v)
@@ -923,7 +923,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_UINT16_BE instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_UINT16_BE_unchecked(wStream* _s, UINT16 _v)
@@ -949,7 +949,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_UINT16_BE instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*
* @since version 3.10.0
@@ -977,7 +977,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_UINT24_BE instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_UINT24_BE_unchecked(wStream* _s, UINT32 _v)
@@ -1005,7 +1005,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_INT32 instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_INT32_unchecked(wStream* _s, INT32 _v)
@@ -1031,7 +1031,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_INT32 instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*
* @since version 3.10.0
@@ -1059,7 +1059,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_UINT32 instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_UINT32_unchecked(wStream* _s, UINT32 _v)
@@ -1085,7 +1085,7 @@ extern "C"
*
* Do not use directly, use the define @ref Stream_Write_UINT32_BE instead
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_UINT32_BE_unchecked(wStream* _s, UINT32 _v)
@@ -1099,7 +1099,7 @@ extern "C"
/** @brief writes a \b UINT64 as \b little endian to a \b wStream. The stream must be large
* enough to hold the data.
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_UINT64(wStream* _s, UINT64 _v)
@@ -1115,7 +1115,7 @@ extern "C"
/** @brief writes a \b UINT64 as \b big endian to a \b wStream. The stream must be large enough
* to hold the data.
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
*/
static inline void Stream_Write_UINT64_BE(wStream* _s, UINT64 _v)
@@ -1131,7 +1131,7 @@ extern "C"
/** @brief writes a \b INT64 as \b little endian to a \b wStream. The stream must be large
* enough to hold the data.
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
* \since version 3.10.0
*/
@@ -1148,7 +1148,7 @@ extern "C"
/** @brief writes a \b INT64 as \b big endian to a \b wStream. The stream must be large enough
* to hold the data.
*
- * \param _s The stream to write to, must not be \b NULL
+ * \param _s The stream to write to, must not be \b nullptr
* \param _v The value to write
* \since version 3.10.0
*/
@@ -1341,9 +1341,9 @@ extern "C"
*
* \param s The stream to read data from
* \param wcharLength The number of WCHAR characters to read (NOT the size in bytes!)
- * \param pUtfCharLength Ignored if \b NULL, otherwise will be set to the number of
+ * \param pUtfCharLength Ignored if \b nullptr, otherwise will be set to the number of
* characters in the resulting UTF-8 string
- * \return A '\0' terminated UTF-8 encoded string or NULL for any failure.
+ * \return A '\0' terminated UTF-8 encoded string or nullptr for any failure.
*/
WINPR_API char* Stream_Read_UTF16_String_As_UTF8(wStream* s, size_t wcharLength,
size_t* pUtfCharLength);
@@ -1404,7 +1404,7 @@ extern "C"
/** Return the number of streams still not returned to the pool
*
- * @param pool The pool to query, must not be \b NULL
+ * @param pool The pool to query, must not be \b nullptr
*
* @return the number of streams still in use
*
@@ -1415,7 +1415,7 @@ extern "C"
/** Wait up to \b timeoutMS milliseconds for streams to be returned to the pool.
* Use \b INFINITE for an infinite timeout
*
- * @param pool The pool to query, must not be \b NULL
+ * @param pool The pool to query, must not be \b nullptr
* @param timeoutMS Milliseconds to wait at most, use \b INFINITE for no timeout.
*
* @return \b TRUE in case all streams were returned, \b FALSE otherwise.
diff --git a/winpr/include/winpr/string.h b/winpr/include/winpr/string.h
index d246ef224..85ea2918b 100644
--- a/winpr/include/winpr/string.h
+++ b/winpr/include/winpr/string.h
@@ -180,9 +180,9 @@ extern "C"
#define sprintf_s snprintf
#define _snprintf snprintf
-#define _scprintf(...) snprintf(NULL, 0, __VA_ARGS__)
+#define _scprintf(...) snprintf(nullptr, 0, __VA_ARGS__)
-#define _scprintf(...) snprintf(NULL, 0, __VA_ARGS__)
+#define _scprintf(...) snprintf(nullptr, 0, __VA_ARGS__)
/* Unicode Conversion */
@@ -212,7 +212,7 @@ extern "C"
* \warning Supplying a buffer length smaller than required will result in
* platform dependent (=undefined) behaviour!
*
- * \param wstr A '\0' terminated WCHAR string, may be NULL
+ * \param wstr A '\0' terminated WCHAR string, may be nullptr
* \param str A pointer to the result string
* \param len The length in characters of the result buffer
*
@@ -268,7 +268,7 @@ extern "C"
* \warning Supplying a buffer length smaller than required will result in
* platform dependent (=undefined) behaviour!
*
- * \param str A '\0' terminated CHAR string, may be NULL
+ * \param str A '\0' terminated CHAR string, may be nullptr
* \param wstr A pointer to the result WCHAR string
* \param wlen The length in WCHAR characters of the result buffer
*
@@ -319,11 +319,11 @@ extern "C"
*
* The function does string conversions of any '\0' terminated input string
*
- * \param wstr A '\0' terminated WCHAR string, may be NULL
- * \param pUtfCharLength Ignored if NULL, otherwise receives the length of the result string in
- * characters (strlen)
+ * \param wstr A '\0' terminated WCHAR string, may be nullptr
+ * \param pUtfCharLength Ignored if nullptr, otherwise receives the length of the result string
+ * in characters (strlen)
*
- * \return An allocated zero terminated UTF-8 string or NULL in case of failure.
+ * \return An allocated zero terminated UTF-8 string or nullptr in case of failure.
*/
WINPR_API char* ConvertWCharToUtf8Alloc(const WCHAR* wstr, size_t* pUtfCharLength);
@@ -334,10 +334,10 @@ extern "C"
*
* \param wstr A WCHAR string of \b wlen length
* \param wlen The (buffer) length in characters of \b wstr
- * \param pUtfCharLength Ignored if NULL, otherwise receives the length of the result string in
- * characters (strlen)
+ * \param pUtfCharLength Ignored if nullptr, otherwise receives the length of the result string
+ * in characters (strlen)
*
- * \return An allocated zero terminated UTF-8 string or NULL in case of failure.
+ * \return An allocated zero terminated UTF-8 string or nullptr in case of failure.
*/
WINPR_API char* ConvertWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen,
size_t* pUtfCharLength);
@@ -349,10 +349,10 @@ extern "C"
*
* \param wstr A WCHAR string of \b len character length
* \param wlen The (buffer) length in characters of \b str
- * \param pUtfCharLength Ignored if NULL, otherwise receives the length of the result string in
- * characters (including any '\0' character)
+ * \param pUtfCharLength Ignored if nullptr, otherwise receives the length of the result string
+ * in characters (including any '\0' character)
*
- * \return An allocated double zero terminated UTF-8 string or NULL in case of failure.
+ * \return An allocated double zero terminated UTF-8 string or nullptr in case of failure.
*/
WINPR_API char* ConvertMszWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen,
size_t* pUtfCharLength);
@@ -361,11 +361,11 @@ extern "C"
*
* The function does string conversions of any '\0' terminated input string
*
- * \param str A '\0' terminated CHAR string, may be NULL
- * \param pSize Ignored if NULL, otherwise receives the length of the result string in
+ * \param str A '\0' terminated CHAR string, may be nullptr
+ * \param pSize Ignored if nullptr, otherwise receives the length of the result string in
* characters (wcslen)
*
- * \return An allocated zero terminated UTF-16 string or NULL in case of failure.
+ * \return An allocated zero terminated UTF-16 string or nullptr in case of failure.
*/
WINPR_API WCHAR* ConvertUtf8ToWCharAlloc(const char* str, size_t* pSize);
@@ -376,10 +376,10 @@ extern "C"
*
* \param str A CHAR string of \b len length
* \param len The (buffer) length in characters of \b str
- * \param pSize Ignored if NULL, otherwise receives the length of the result string in
+ * \param pSize Ignored if nullptr, otherwise receives the length of the result string in
* characters (wcslen)
*
- * \return An allocated zero terminated UTF-16 string or NULL in case of failure.
+ * \return An allocated zero terminated UTF-16 string or nullptr in case of failure.
*/
WINPR_API WCHAR* ConvertUtf8NToWCharAlloc(const char* str, size_t len, size_t* pSize);
@@ -390,10 +390,10 @@ extern "C"
*
* \param str A CHAR string of \b len byte length
* \param len The (buffer) length in characters of \b str
- * \param pSize Ignored if NULL, otherwise receives the length of the result string in
+ * \param pSize Ignored if nullptr, otherwise receives the length of the result string in
* characters (including any '\0' character)
*
- * \return An allocated double zero terminated UTF-16 string or NULL in case of failure.
+ * \return An allocated double zero terminated UTF-16 string or nullptr in case of failure.
*/
WINPR_API WCHAR* ConvertMszUtf8NToWCharAlloc(const char* str, size_t len, size_t* pSize);
diff --git a/winpr/include/winpr/winpr.h b/winpr/include/winpr/winpr.h
index 4bd20e046..e936a2ad0 100644
--- a/winpr/include/winpr/winpr.h
+++ b/winpr/include/winpr/winpr.h
@@ -42,9 +42,9 @@ WINPR_API const char* winpr_get_build_config(void);
* is ignored and the config path will always have the format 'vendor/product' or 'vendor/product1'
* (1 for the actual version set)
*
- * @param vendor A vendor name to use. Must not be \b NULL. Must not contain forbidden
+ * @param vendor A vendor name to use. Must not be \b nullptr. Must not contain forbidden
* filesystem symbols for any os. Must be less than \b MAX_PATH bytes.
- * @param product A product name to use. Must not be \b NULL. Must not contain forbidden
+ * @param product A product name to use. Must not be \b nullptr. Must not contain forbidden
* filesystem symbols for any os. Must be less than \b MAX_PATH bytes.
* @param version An optional versioning value to append to paths to settings. Use \b -1 to
* disable.
diff --git a/winpr/include/winpr/wlog.h b/winpr/include/winpr/wlog.h
index 35d2e5016..fed813ce8 100644
--- a/winpr/include/winpr/wlog.h
+++ b/winpr/include/winpr/wlog.h
@@ -184,7 +184,7 @@ extern "C"
/** @brief Set a custom context for a dynamic logger.
* This can be used to print a customized prefix, e.g. some session id for a specific context
*
- * @param log The logger to ste the context for. Must not be \b NULL
+ * @param log The logger to ste the context for. Must not be \b nullptr
* @param fkt A function pointer that is called to get the custimized string.
* @param context A context \b fkt is called with. Caller must ensure it is still allocated
* when \b log is used
@@ -211,7 +211,7 @@ extern "C"
#define WLog_Print_tag(_tag, _log_level, ...) \
do \
{ \
- static wLog* _log_cached_ptr = NULL; \
+ static wLog* _log_cached_ptr = nullptr; \
if (!_log_cached_ptr) \
_log_cached_ptr = WLog_Get(_tag); \
WLog_Print(_log_cached_ptr, _log_level, __VA_ARGS__); \
@@ -267,7 +267,7 @@ extern "C"
size_t line, const char* file, const char* fkt,
WINPR_FORMAT_ARG const char* fmt, ...)
{
- static wLog* log_cached_ptr = NULL;
+ static wLog* log_cached_ptr = nullptr;
if (!log_cached_ptr)
log_cached_ptr = WLog_Get(tag);
diff --git a/winpr/include/winpr/wtsapi.h b/winpr/include/winpr/wtsapi.h
index 6917157e5..720118321 100644
--- a/winpr/include/winpr/wtsapi.h
+++ b/winpr/include/winpr/wtsapi.h
@@ -262,9 +262,9 @@ typedef HRESULT(VCAPITYPE* PFNVCAPIGETINSTANCE)(REFIID refiid, PULONG pNumObjs,
* Windows Terminal Services API (wtsapi32.h)
*/
-#define WTS_CURRENT_SERVER ((HANDLE)NULL)
-#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL)
-#define WTS_CURRENT_SERVER_NAME (NULL)
+#define WTS_CURRENT_SERVER ((HANDLE) nullptr)
+#define WTS_CURRENT_SERVER_HANDLE ((HANDLE) nullptr)
+#define WTS_CURRENT_SERVER_NAME (nullptr)
#define WTS_CURRENT_SESSION ((DWORD)-1)
diff --git a/winpr/libwinpr/clipboard/clipboard.c b/winpr/libwinpr/clipboard/clipboard.c
index 51a7823ec..c2e8c7057 100644
--- a/winpr/libwinpr/clipboard/clipboard.c
+++ b/winpr/libwinpr/clipboard/clipboard.c
@@ -73,10 +73,10 @@ const char* ClipboardGetFormatIdString(UINT32 formatId)
static wClipboardFormat* ClipboardFindFormat(wClipboard* clipboard, UINT32 formatId,
const char* name)
{
- wClipboardFormat* format = NULL;
+ wClipboardFormat* format = nullptr;
if (!clipboard)
- return NULL;
+ return nullptr;
if (formatId)
{
@@ -113,7 +113,7 @@ static wClipboardFormat* ClipboardFindFormat(wClipboard* clipboard, UINT32 forma
format = &clipboard->formats[0];
if (format->formatId)
- return NULL;
+ return nullptr;
if (!format->formatName || (strcmp(format->formatName, CF_STANDARD_STRINGS[0]) == 0))
return format;
@@ -126,7 +126,7 @@ static wClipboardFormat* ClipboardFindFormat(wClipboard* clipboard, UINT32 forma
static wClipboardSynthesizer* ClipboardFindSynthesizer(wClipboardFormat* format, UINT32 formatId)
{
if (!format)
- return NULL;
+ return nullptr;
for (UINT32 index = 0; index < format->numSynthesizers; index++)
{
@@ -136,7 +136,7 @@ static wClipboardSynthesizer* ClipboardFindSynthesizer(wClipboardFormat* format,
return synthesizer;
}
- return NULL;
+ return nullptr;
}
void ClipboardLock(wClipboard* clipboard)
@@ -163,7 +163,7 @@ BOOL ClipboardEmpty(wClipboard* clipboard)
if (clipboard->data)
{
free(clipboard->data);
- clipboard->data = NULL;
+ clipboard->data = nullptr;
}
clipboard->size = 0;
@@ -182,8 +182,8 @@ UINT32 ClipboardCountRegisteredFormats(wClipboard* clipboard)
UINT32 ClipboardGetRegisteredFormatIds(wClipboard* clipboard, UINT32** ppFormatIds)
{
- UINT32* pFormatIds = NULL;
- wClipboardFormat* format = NULL;
+ UINT32* pFormatIds = nullptr;
+ wClipboardFormat* format = nullptr;
if (!clipboard)
return 0;
@@ -214,7 +214,7 @@ UINT32 ClipboardGetRegisteredFormatIds(wClipboard* clipboard, UINT32** ppFormatI
UINT32 ClipboardRegisterFormat(wClipboard* clipboard, const char* name)
{
- wClipboardFormat* format = NULL;
+ wClipboardFormat* format = nullptr;
if (!clipboard)
return 0;
@@ -227,7 +227,7 @@ UINT32 ClipboardRegisterFormat(wClipboard* clipboard, const char* name)
if ((clipboard->numFormats + 1) >= clipboard->maxFormats)
{
UINT32 numFormats = clipboard->maxFormats * 2;
- wClipboardFormat* tmpFormat = NULL;
+ wClipboardFormat* tmpFormat = nullptr;
tmpFormat =
(wClipboardFormat*)realloc(clipboard->formats, numFormats * sizeof(wClipboardFormat));
@@ -258,13 +258,13 @@ BOOL ClipboardRegisterSynthesizer(wClipboard* clipboard, UINT32 formatId, UINT32
CLIPBOARD_SYNTHESIZE_FN pfnSynthesize)
{
UINT32 index = 0;
- wClipboardFormat* format = NULL;
- wClipboardSynthesizer* synthesizer = NULL;
+ wClipboardFormat* format = nullptr;
+ wClipboardSynthesizer* synthesizer = nullptr;
if (!clipboard)
return FALSE;
- format = ClipboardFindFormat(clipboard, formatId, NULL);
+ format = ClipboardFindFormat(clipboard, formatId, nullptr);
if (!format)
return FALSE;
@@ -276,7 +276,7 @@ BOOL ClipboardRegisterSynthesizer(wClipboard* clipboard, UINT32 formatId, UINT32
if (!synthesizer)
{
- wClipboardSynthesizer* tmpSynthesizer = NULL;
+ wClipboardSynthesizer* tmpSynthesizer = nullptr;
UINT32 numSynthesizers = format->numSynthesizers + 1;
tmpSynthesizer = (wClipboardSynthesizer*)realloc(
format->synthesizers, numSynthesizers * sizeof(wClipboardSynthesizer));
@@ -298,12 +298,12 @@ BOOL ClipboardRegisterSynthesizer(wClipboard* clipboard, UINT32 formatId, UINT32
UINT32 ClipboardCountFormats(wClipboard* clipboard)
{
UINT32 count = 0;
- wClipboardFormat* format = NULL;
+ wClipboardFormat* format = nullptr;
if (!clipboard)
return 0;
- format = ClipboardFindFormat(clipboard, clipboard->formatId, NULL);
+ format = ClipboardFindFormat(clipboard, clipboard->formatId, nullptr);
if (!format)
return 0;
@@ -315,14 +315,14 @@ UINT32 ClipboardCountFormats(wClipboard* clipboard)
UINT32 ClipboardGetFormatIds(wClipboard* clipboard, UINT32** ppFormatIds)
{
UINT32 count = 0;
- UINT32* pFormatIds = NULL;
- wClipboardFormat* format = NULL;
- wClipboardSynthesizer* synthesizer = NULL;
+ UINT32* pFormatIds = nullptr;
+ wClipboardFormat* format = nullptr;
+ wClipboardSynthesizer* synthesizer = nullptr;
if (!clipboard)
return 0;
- format = ClipboardFindFormat(clipboard, clipboard->formatId, NULL);
+ format = ClipboardFindFormat(clipboard, clipboard->formatId, nullptr);
if (!format)
return 0;
@@ -363,15 +363,15 @@ static void ClipboardUninitFormats(wClipboard* clipboard)
wClipboardFormat* format = &clipboard->formats[formatId];
free(format->formatName);
free(format->synthesizers);
- format->formatName = NULL;
- format->synthesizers = NULL;
+ format->formatName = nullptr;
+ format->synthesizers = nullptr;
}
}
static BOOL ClipboardInitFormats(wClipboard* clipboard)
{
UINT32 formatId = 0;
- wClipboardFormat* format = NULL;
+ wClipboardFormat* format = nullptr;
if (!clipboard)
return FALSE;
@@ -399,7 +399,7 @@ error:
UINT32 ClipboardGetFormatId(wClipboard* clipboard, const char* name)
{
- wClipboardFormat* format = NULL;
+ wClipboardFormat* format = nullptr;
if (!clipboard)
return 0;
@@ -414,15 +414,15 @@ UINT32 ClipboardGetFormatId(wClipboard* clipboard, const char* name)
const char* ClipboardGetFormatName(wClipboard* clipboard, UINT32 formatId)
{
- wClipboardFormat* format = NULL;
+ wClipboardFormat* format = nullptr;
if (!clipboard)
- return NULL;
+ return nullptr;
- format = ClipboardFindFormat(clipboard, formatId, NULL);
+ format = ClipboardFindFormat(clipboard, formatId, nullptr);
if (!format)
- return NULL;
+ return nullptr;
return format->formatName;
}
@@ -431,26 +431,26 @@ void* ClipboardGetData(wClipboard* clipboard, UINT32 formatId, UINT32* pSize)
{
UINT32 SrcSize = 0;
UINT32 DstSize = 0;
- void* pSrcData = NULL;
- void* pDstData = NULL;
- wClipboardFormat* format = NULL;
- wClipboardSynthesizer* synthesizer = NULL;
+ void* pSrcData = nullptr;
+ void* pDstData = nullptr;
+ wClipboardFormat* format = nullptr;
+ wClipboardSynthesizer* synthesizer = nullptr;
if (!clipboard || !pSize)
{
WLog_ERR(TAG, "Invalid parameters clipboard=%p, pSize=%p",
WINPR_CXX_COMPAT_CAST(const void*, clipboard),
WINPR_CXX_COMPAT_CAST(const void*, pSize));
- return NULL;
+ return nullptr;
}
*pSize = 0;
- format = ClipboardFindFormat(clipboard, clipboard->formatId, NULL);
+ format = ClipboardFindFormat(clipboard, clipboard->formatId, nullptr);
if (!format)
{
WLog_ERR(TAG, "Format [0x%08" PRIx32 "] not found", clipboard->formatId);
- return NULL;
+ return nullptr;
}
SrcSize = clipboard->size;
@@ -462,7 +462,7 @@ void* ClipboardGetData(wClipboard* clipboard, UINT32 formatId, UINT32* pSize)
pDstData = malloc(DstSize);
if (!pDstData)
- return NULL;
+ return nullptr;
CopyMemory(pDstData, pSrcData, SrcSize);
*pSize = DstSize;
@@ -476,7 +476,7 @@ void* ClipboardGetData(wClipboard* clipboard, UINT32 formatId, UINT32* pSize)
WLog_ERR(TAG, "No synthesizer for format %s [0x%08" PRIx32 "] --> %s [0x%08" PRIx32 "]",
ClipboardGetFormatName(clipboard, clipboard->formatId), clipboard->formatId,
ClipboardGetFormatName(clipboard, formatId), formatId);
- return NULL;
+ return nullptr;
}
DstSize = SrcSize;
@@ -492,14 +492,14 @@ void* ClipboardGetData(wClipboard* clipboard, UINT32 formatId, UINT32* pSize)
BOOL ClipboardSetData(wClipboard* clipboard, UINT32 formatId, const void* data, UINT32 size)
{
- wClipboardFormat* format = NULL;
+ wClipboardFormat* format = nullptr;
WLog_DBG(TAG, "setting formatId=%s [0x%08" PRIx32 "], size=%" PRIu32,
ClipboardGetFormatName(clipboard, formatId), formatId, size);
if (!clipboard)
return FALSE;
- format = ClipboardFindFormat(clipboard, formatId, NULL);
+ format = ClipboardFindFormat(clipboard, formatId, nullptr);
if (!format)
return FALSE;
@@ -555,7 +555,7 @@ void ClipboardSetOwner(wClipboard* clipboard, UINT64 ownerId)
wClipboardDelegate* ClipboardGetDelegate(wClipboard* clipboard)
{
if (!clipboard)
- return NULL;
+ return nullptr;
return &clipboard->delegate;
}
@@ -584,7 +584,7 @@ wClipboard* ClipboardCreate(void)
wClipboard* clipboard = (wClipboard*)calloc(1, sizeof(wClipboard));
if (!clipboard)
- return NULL;
+ return nullptr;
clipboard->nextFormatId = 0xC000;
clipboard->sequenceNumber = 0;
@@ -607,7 +607,7 @@ wClipboard* ClipboardCreate(void)
return clipboard;
fail:
ClipboardDestroy(clipboard);
- return NULL;
+ return nullptr;
}
void ClipboardDestroy(wClipboard* clipboard)
@@ -616,12 +616,12 @@ void ClipboardDestroy(wClipboard* clipboard)
return;
ArrayList_Free(clipboard->localFiles);
- clipboard->localFiles = NULL;
+ clipboard->localFiles = nullptr;
ClipboardUninitFormats(clipboard);
free(clipboard->data);
- clipboard->data = NULL;
+ clipboard->data = nullptr;
clipboard->size = 0;
clipboard->numFormats = 0;
free(clipboard->formats);
@@ -648,9 +648,9 @@ char* parse_uri_to_local_file(const char* uri, size_t uri_len)
// URI is specified by RFC 8089: https://datatracker.ietf.org/doc/html/rfc8089
const char prefix[] = "file:";
const char prefixTraditional[] = "file://";
- const char* localName = NULL;
+ const char* localName = nullptr;
size_t localLen = 0;
- char* buffer = NULL;
+ char* buffer = nullptr;
const size_t prefixLen = strnlen(prefix, sizeof(prefix));
const size_t prefixTraditionalLen = strnlen(prefixTraditional, sizeof(prefixTraditional));
@@ -661,7 +661,7 @@ char* parse_uri_to_local_file(const char* uri, size_t uri_len)
if ((uri_len <= prefixLen) || strncmp(uri, prefix, prefixLen) != 0)
{
WLog_ERR(TAG, "non-'file:' URI schemes are not supported");
- return NULL;
+ return nullptr;
}
do
@@ -692,7 +692,7 @@ char* parse_uri_to_local_file(const char* uri, size_t uri_len)
else
{
WLog_ERR(TAG, "URI format are not supported: %s", uri);
- return NULL;
+ return nullptr;
}
}
@@ -728,7 +728,7 @@ char* parse_uri_to_local_file(const char* uri, size_t uri_len)
strncmp(uri, prefixTraditional, prefixTraditionalLen) != 0)
{
WLog_ERR(TAG, "non-'file:' URI schemes are not supported");
- return NULL;
+ return nullptr;
}
localName = &uri[prefixTraditionalLen];
@@ -737,7 +737,7 @@ char* parse_uri_to_local_file(const char* uri, size_t uri_len)
if (localLen < 1)
{
WLog_ERR(TAG, "empty 'file:' URI schemes are not supported");
- return NULL;
+ return nullptr;
}
/*
@@ -747,7 +747,7 @@ char* parse_uri_to_local_file(const char* uri, size_t uri_len)
if (localName[0] != '/')
{
WLog_ERR(TAG, "URI format are not supported: %s", uri);
- return NULL;
+ return nullptr;
}
if (is_dos_drive(&localName[1], localLen - 1))
@@ -767,5 +767,5 @@ char* parse_uri_to_local_file(const char* uri, size_t uri_len)
return buffer;
}
- return NULL;
+ return nullptr;
}
diff --git a/winpr/libwinpr/clipboard/synthetic.c b/winpr/libwinpr/clipboard/synthetic.c
index f95ce5f02..d72599848 100644
--- a/winpr/libwinpr/clipboard/synthetic.c
+++ b/winpr/libwinpr/clipboard/synthetic.c
@@ -56,7 +56,7 @@ static inline char* b64_encode(const BYTE* WINPR_RESTRICT data, size_t length, s
const size_t alen = outLen + extra + 1ull;
BYTE* p = malloc(alen);
if (!p)
- return NULL;
+ return nullptr;
BYTE* ret = p;
@@ -125,7 +125,7 @@ static void* clipboard_synthesize_cf_text(wClipboard* clipboard, UINT32 formatId
UINT32* pSize)
{
size_t size = 0;
- char* pDstData = NULL;
+ char* pDstData = nullptr;
if (formatId == CF_UNICODETEXT)
{
@@ -134,7 +134,7 @@ static void* clipboard_synthesize_cf_text(wClipboard* clipboard, UINT32 formatId
if (!str || (size > UINT32_MAX))
{
free(str);
- return NULL;
+ return nullptr;
}
pDstData = ConvertLineEndingToCRLF(str, &size);
@@ -151,14 +151,14 @@ static void* clipboard_synthesize_cf_text(wClipboard* clipboard, UINT32 formatId
if (!pDstData || (size > *pSize))
{
free(pDstData);
- return NULL;
+ return nullptr;
}
*pSize = (UINT32)size;
return pDstData;
}
- return NULL;
+ return nullptr;
}
/**
@@ -184,11 +184,11 @@ static void* clipboard_synthesize_cf_locale(WINPR_ATTR_UNUSED wClipboard* clipbo
WINPR_ATTR_UNUSED const void* data,
WINPR_ATTR_UNUSED UINT32* pSize)
{
- UINT32* pDstData = NULL;
+ UINT32* pDstData = nullptr;
pDstData = (UINT32*)malloc(sizeof(UINT32));
if (!pDstData)
- return NULL;
+ return nullptr;
*pDstData = 0x0409; /* English - United States */
return (void*)pDstData;
@@ -204,21 +204,21 @@ static void* clipboard_synthesize_cf_unicodetext(wClipboard* clipboard, UINT32 f
const void* data, UINT32* pSize)
{
size_t size = 0;
- char* crlfStr = NULL;
- WCHAR* pDstData = NULL;
+ char* crlfStr = nullptr;
+ WCHAR* pDstData = nullptr;
if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) ||
(formatId == ClipboardGetFormatId(clipboard, mime_text_plain)))
{
size_t len = 0;
if (!pSize || (*pSize > INT32_MAX))
- return NULL;
+ return nullptr;
size = *pSize;
crlfStr = ConvertLineEndingToCRLF((const char*)data, &size);
if (!crlfStr)
- return NULL;
+ return nullptr;
pDstData = ConvertUtf8NToWCharAlloc(crlfStr, size, &len);
free(crlfStr);
@@ -226,7 +226,7 @@ static void* clipboard_synthesize_cf_unicodetext(wClipboard* clipboard, UINT32 f
if ((len < 1) || ((len + 1) > UINT32_MAX / sizeof(WCHAR)))
{
free(pDstData);
- return NULL;
+ return nullptr;
}
const size_t slen = (len + 1) * sizeof(WCHAR);
@@ -251,7 +251,7 @@ static void* clipboard_synthesize_utf8_string(wClipboard* clipboard, UINT32 form
char* pDstData = ConvertWCharNToUtf8Alloc(data, *pSize / sizeof(WCHAR), &size);
if (!pDstData)
- return NULL;
+ return nullptr;
const size_t rc = ConvertLineEndingToLF(pDstData, size);
WINPR_ASSERT(rc <= UINT32_MAX);
@@ -265,7 +265,7 @@ static void* clipboard_synthesize_utf8_string(wClipboard* clipboard, UINT32 form
char* pDstData = calloc(size + 1, sizeof(char));
if (!pDstData)
- return NULL;
+ return nullptr;
CopyMemory(pDstData, data, size);
const size_t rc = ConvertLineEndingToLF(pDstData, size);
@@ -274,7 +274,7 @@ static void* clipboard_synthesize_utf8_string(wClipboard* clipboard, UINT32 form
return pDstData;
}
- return NULL;
+ return nullptr;
}
static BOOL is_format_bitmap(wClipboard* clipboard, UINT32 formatId)
@@ -301,7 +301,7 @@ static void* clipboard_synthesize_cf_dib(wClipboard* clipboard, UINT32 formatId,
{
UINT32 SrcSize = 0;
UINT32 DstSize = 0;
- BYTE* pDstData = NULL;
+ BYTE* pDstData = nullptr;
SrcSize = *pSize;
#if defined(WINPR_UTILS_IMAGE_DIBv5)
@@ -318,13 +318,13 @@ static void* clipboard_synthesize_cf_dib(wClipboard* clipboard, UINT32 formatId,
wStream sbuffer = WINPR_C_ARRAY_INIT;
wStream* s = Stream_StaticConstInit(&sbuffer, data, SrcSize);
if (!readBitmapFileHeader(s, &pFileHeader))
- return NULL;
+ return nullptr;
DstSize = SrcSize - sizeof(BITMAPFILEHEADER);
pDstData = (BYTE*)malloc(DstSize);
if (!pDstData)
- return NULL;
+ return nullptr;
data = (const void*)&((const BYTE*)data)[sizeof(BITMAPFILEHEADER)];
CopyMemory(pDstData, data, DstSize);
@@ -337,7 +337,7 @@ static void* clipboard_synthesize_cf_dib(wClipboard* clipboard, UINT32 formatId,
ClipboardGetFormatName(clipboard, formatId));
}
- return NULL;
+ return nullptr;
}
/**
@@ -386,7 +386,7 @@ static void* clipboard_synthesize_cf_dibv5(wClipboard* clipboard, UINT32 formatI
}
}
- return NULL;
+ return nullptr;
}
#endif
@@ -398,15 +398,15 @@ static void* clipboard_prepend_bmp_header(const WINPR_BITMAP_INFO_HEADER* pInfoH
*pSize = 0;
if ((pInfoHeader->biBitCount < 1) || (pInfoHeader->biBitCount > 32))
- return NULL;
+ return nullptr;
const size_t DstSize = sizeof(WINPR_BITMAP_FILE_HEADER) + size;
if (DstSize > UINT32_MAX)
- return NULL;
+ return nullptr;
- wStream* s = Stream_New(NULL, DstSize);
+ wStream* s = Stream_New(nullptr, DstSize);
if (!s)
- return NULL;
+ return nullptr;
WINPR_BITMAP_FILE_HEADER fileHeader = WINPR_C_ARRAY_INIT;
fileHeader.bfType[0] = 'B';
@@ -436,7 +436,7 @@ static void* clipboard_prepend_bmp_header(const WINPR_BITMAP_INFO_HEADER* pInfoH
fail:
Stream_Free(s, TRUE);
- return NULL;
+ return nullptr;
}
/**
@@ -453,14 +453,14 @@ static void* clipboard_synthesize_image_bmp(WINPR_ATTR_UNUSED wClipboard* clipbo
if (formatId == CF_DIB)
{
if (SrcSize < sizeof(BITMAPINFOHEADER))
- return NULL;
+ return nullptr;
wStream sbuffer = WINPR_C_ARRAY_INIT;
size_t offset = 0;
WINPR_BITMAP_INFO_HEADER header = WINPR_C_ARRAY_INIT;
wStream* s = Stream_StaticConstInit(&sbuffer, data, SrcSize);
if (!readBitmapInfoHeader(s, &header, &offset))
- return NULL;
+ return nullptr;
return clipboard_prepend_bmp_header(&header, data, SrcSize, pSize);
}
@@ -477,7 +477,7 @@ static void* clipboard_synthesize_image_bmp(WINPR_ATTR_UNUSED wClipboard* clipbo
ClipboardGetFormatName(clipboard, formatId));
}
- return NULL;
+ return nullptr;
}
#if defined(WINPR_UTILS_IMAGE_PNG) || defined(WINPR_UTILS_IMAGE_WEBP) || \
@@ -491,7 +491,7 @@ static void* clipboard_synthesize_image_bmp_to_format(wClipboard* clipboard, UIN
WINPR_ASSERT(pSize);
size_t dsize = 0;
- void* result = NULL;
+ void* result = nullptr;
wImage* img = winpr_image_new();
void* bmp = clipboard_synthesize_image_bmp(clipboard, formatId, data, pSize);
@@ -512,7 +512,7 @@ static void* clipboard_synthesize_image_bmp_to_format(wClipboard* clipboard, UIN
else
{
free(result);
- result = NULL;
+ result = nullptr;
}
}
@@ -542,7 +542,7 @@ static void* clipboard_synthesize_image_format_to_bmp(WINPR_ATTR_UNUSED wClipboa
WINPR_ASSERT(data);
WINPR_ASSERT(pSize);
- BYTE* dst = NULL;
+ BYTE* dst = nullptr;
const UINT32 SrcSize = *pSize;
size_t size = 0;
wImage* image = winpr_image_new();
@@ -557,7 +557,7 @@ static void* clipboard_synthesize_image_format_to_bmp(WINPR_ATTR_UNUSED wClipboa
if ((size < sizeof(WINPR_BITMAP_FILE_HEADER)) || (size > UINT32_MAX))
{
free(dst);
- dst = NULL;
+ dst = nullptr;
goto fail;
}
*pSize = (UINT32)size;
@@ -626,9 +626,9 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form
const BYTE* cpb;
WCHAR* pv;
} pSrcData;
- char* pDstData = NULL;
+ char* pDstData = nullptr;
- pSrcData.cpv = NULL;
+ pSrcData.cpv = nullptr;
WINPR_ASSERT(clipboard);
WINPR_ASSERT(pSize);
@@ -637,7 +637,7 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form
{
const size_t SrcSize = (size_t)*pSize;
const size_t DstSize = SrcSize + 200;
- char* body = NULL;
+ char* body = nullptr;
char num[20] = WINPR_C_ARRAY_INIT;
/* Create a copy, we modify the input data */
@@ -659,7 +659,7 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form
if ((pSrcData.cpb[0] == 0xFF) && (pSrcData.cpb[1] == 0xFE))
{
char* utfString =
- ConvertWCharNToUtf8Alloc(&pSrcData.pv[1], SrcSize / sizeof(WCHAR), NULL);
+ ConvertWCharNToUtf8Alloc(&pSrcData.pv[1], SrcSize / sizeof(WCHAR), nullptr);
free(pSrcData.pv);
pSrcData.cpc = utfString;
if (!utfString)
@@ -689,30 +689,30 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form
if (!body)
{
- if (!winpr_str_append("
", pDstData, DstSize, NULL))
+ if (!winpr_str_append("", pDstData, DstSize, nullptr))
goto fail;
}
- if (!winpr_str_append("", pDstData, DstSize, NULL))
+ if (!winpr_str_append("", pDstData, DstSize, nullptr))
goto fail;
/* StartFragment */
(void)sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, SrcSize + 200));
CopyMemory(&pDstData[69], num, 10);
- if (!winpr_str_append(pSrcData.cpc, pDstData, DstSize, NULL))
+ if (!winpr_str_append(pSrcData.cpc, pDstData, DstSize, nullptr))
goto fail;
/* EndFragment */
(void)sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, SrcSize + 200));
CopyMemory(&pDstData[93], num, 10);
- if (!winpr_str_append("", pDstData, DstSize, NULL))
+ if (!winpr_str_append("", pDstData, DstSize, nullptr))
goto fail;
if (!body)
{
- if (!winpr_str_append("", pDstData, DstSize, NULL))
+ if (!winpr_str_append("", pDstData, DstSize, nullptr))
goto fail;
}
@@ -755,14 +755,14 @@ static void* clipboard_wrap_html(const char* mime, const char* idata, size_t ile
size_t b64len = 0;
char* b64 = b64_encode((const BYTE*)idata, ilength, &b64len);
if (!b64)
- return NULL;
+ return nullptr;
const size_t mimelen = strlen(mime);
- wStream* s = Stream_New(NULL, b64len + 225 + mimelen);
+ wStream* s = Stream_New(nullptr, b64len + 225 + mimelen);
if (!s)
{
free(b64);
- return NULL;
+ return nullptr;
}
char* startHTML = html_pre_write(s, "Version:0.9\r\nStartHTML:");
@@ -805,7 +805,7 @@ static void* clipboard_wrap_html(const char* mime, const char* idata, size_t ile
static void* clipboard_wrap_format_to_html(uint32_t bmpFormat, const char* idata, size_t ilength,
uint32_t* plen)
{
- void* res = NULL;
+ void* res = nullptr;
wImage* img = winpr_image_new();
if (!img)
goto fail;
@@ -864,7 +864,7 @@ static void* clipboard_synthesize_image_html(WINPR_ATTR_UNUSED wClipboard* clipb
WLog_WARN(TAG, "failed to convert formatId 0x%08" PRIx32 " [%s]", formatId,
ClipboardGetFormatName(clipboard, formatId));
*pSize = 0;
- return NULL;
+ return nullptr;
}
void* res = clipboard_wrap_bmp_to_html(bmp, bmplen, pSize);
@@ -908,7 +908,7 @@ static void* clipboard_synthesize_image_html(WINPR_ATTR_UNUSED wClipboard* clipb
WLog_WARN(TAG, "Unsupported image format id 0x%08" PRIx32 " [%s]", formatId,
ClipboardGetFormatName(clipboard, formatId));
*pSize = 0;
- return NULL;
+ return nullptr;
}
}
}
@@ -922,7 +922,7 @@ static void* clipboard_synthesize_image_html(WINPR_ATTR_UNUSED wClipboard* clipb
static void* clipboard_synthesize_text_html(wClipboard* clipboard, UINT32 formatId,
const void* data, UINT32* pSize)
{
- char* pDstData = NULL;
+ char* pDstData = nullptr;
if (formatId == ClipboardGetFormatId(clipboard, mime_ms_html))
{
@@ -932,25 +932,25 @@ static void* clipboard_synthesize_text_html(wClipboard* clipboard, UINT32 format
const char* endStr = strstr(str, "EndHTML:");
if (!begStr || !endStr)
- return NULL;
+ return nullptr;
errno = 0;
- const long beg = strtol(&begStr[10], NULL, 10);
+ const long beg = strtol(&begStr[10], nullptr, 10);
if (errno != 0)
- return NULL;
+ return nullptr;
- const long end = strtol(&endStr[8], NULL, 10);
+ const long end = strtol(&endStr[8], nullptr, 10);
if ((beg < 0) || (end < 0) || ((size_t)beg > SrcSize) || ((size_t)end > SrcSize) ||
(beg >= end) || (errno != 0))
- return NULL;
+ return nullptr;
const size_t DstSize = (size_t)(end - beg);
pDstData = calloc(DstSize + 1, sizeof(char));
if (!pDstData)
- return NULL;
+ return nullptr;
CopyMemory(pDstData, &str[beg], DstSize);
const size_t rc = ConvertLineEndingToLF(pDstData, DstSize);
diff --git a/winpr/libwinpr/clipboard/synthetic_file.c b/winpr/libwinpr/clipboard/synthetic_file.c
index 04165457f..a9214f749 100644
--- a/winpr/libwinpr/clipboard/synthetic_file.c
+++ b/winpr/libwinpr/clipboard/synthetic_file.c
@@ -73,9 +73,9 @@ void free_synthetic_file(struct synthetic_file* file);
static struct synthetic_file* make_synthetic_file(const WCHAR* local_name, const WCHAR* remote_name)
{
- struct synthetic_file* file = NULL;
+ struct synthetic_file* file = nullptr;
WIN32_FIND_DATAW fd = WINPR_C_ARRAY_INIT;
- HANDLE hFind = NULL;
+ HANDLE hFind = nullptr;
WINPR_ASSERT(local_name);
WINPR_ASSERT(remote_name);
@@ -84,13 +84,13 @@ static struct synthetic_file* make_synthetic_file(const WCHAR* local_name, const
if (INVALID_HANDLE_VALUE == hFind)
{
WLog_ERR(TAG, "FindFirstFile failed (%" PRIu32 ")", GetLastError());
- return NULL;
+ return nullptr;
}
FindClose(hFind);
file = calloc(1, sizeof(*file));
if (!file)
- return NULL;
+ return nullptr;
file->fd = INVALID_HANDLE_VALUE;
file->offset = 0;
@@ -117,7 +117,7 @@ static struct synthetic_file* make_synthetic_file(const WCHAR* local_name, const
return file;
fail:
free_synthetic_file(file);
- return NULL;
+ return nullptr;
}
static UINT synthetic_file_read_close(struct synthetic_file* file, BOOL force);
@@ -141,7 +141,7 @@ void free_synthetic_file(struct synthetic_file* file)
static WCHAR* convert_local_name_component_to_remote(wClipboard* clipboard, const WCHAR* local_name)
{
wClipboardDelegate* delegate = ClipboardGetDelegate(clipboard);
- WCHAR* remote_name = NULL;
+ WCHAR* remote_name = nullptr;
WINPR_ASSERT(delegate);
@@ -167,7 +167,7 @@ static WCHAR* convert_local_name_component_to_remote(wClipboard* clipboard, cons
return remote_name;
error:
free(remote_name);
- return NULL;
+ return nullptr;
}
static WCHAR* concat_file_name(const WCHAR* dir, const WCHAR* file)
@@ -175,7 +175,7 @@ static WCHAR* concat_file_name(const WCHAR* dir, const WCHAR* file)
size_t len_dir = 0;
size_t len_file = 0;
const WCHAR slash = '/';
- WCHAR* buffer = NULL;
+ WCHAR* buffer = nullptr;
WINPR_ASSERT(dir);
WINPR_ASSERT(file);
@@ -185,7 +185,7 @@ static WCHAR* concat_file_name(const WCHAR* dir, const WCHAR* file)
buffer = calloc(len_dir + 1 + len_file + 2, sizeof(WCHAR));
if (!buffer)
- return NULL;
+ return nullptr;
memcpy(buffer, dir, len_dir * sizeof(WCHAR));
buffer[len_dir] = slash;
@@ -201,9 +201,9 @@ static BOOL add_directory_entry_to_list(wClipboard* clipboard, const WCHAR* loca
const LPWIN32_FIND_DATAW pFileData, wArrayList* files)
{
BOOL result = FALSE;
- WCHAR* local_name = NULL;
- WCHAR* remote_name = NULL;
- WCHAR* remote_base_name = NULL;
+ WCHAR* local_name = nullptr;
+ WCHAR* remote_name = nullptr;
+ WCHAR* remote_base_name = nullptr;
WCHAR dotbuffer[6] = WINPR_C_ARRAY_INIT;
WCHAR dotdotbuffer[6] = WINPR_C_ARRAY_INIT;
@@ -312,7 +312,7 @@ static BOOL add_directory_contents_to_list(wClipboard* clipboard, const WCHAR* l
static BOOL add_file_to_list(wClipboard* clipboard, const WCHAR* local_name,
const WCHAR* remote_name, wArrayList* files)
{
- struct synthetic_file* file = NULL;
+ struct synthetic_file* file = nullptr;
WINPR_ASSERT(clipboard);
WINPR_ASSERT(local_name);
@@ -363,8 +363,8 @@ static const WCHAR* get_basename(const WCHAR* name)
static BOOL process_file_name(wClipboard* clipboard, const WCHAR* local_name, wArrayList* files)
{
BOOL result = FALSE;
- const WCHAR* base_name = NULL;
- WCHAR* remote_name = NULL;
+ const WCHAR* base_name = nullptr;
+ WCHAR* remote_name = nullptr;
WINPR_ASSERT(clipboard);
WINPR_ASSERT(local_name);
@@ -390,14 +390,14 @@ static BOOL process_uri(wClipboard* clipboard, const char* uri, size_t uri_len)
{
// URI is specified by RFC 8089: https://datatracker.ietf.org/doc/html/rfc8089
BOOL result = FALSE;
- char* name = NULL;
+ char* name = nullptr;
WINPR_ASSERT(clipboard);
name = parse_uri_to_local_file(uri, uri_len);
if (name)
{
- WCHAR* wname = NULL;
+ WCHAR* wname = nullptr;
/*
* Note that local file names are not actually guaranteed to be
* encoded in UTF-8. Filesystems and users can use whatever they
@@ -405,7 +405,7 @@ static BOOL process_uri(wClipboard* clipboard, const char* uri, size_t uri_len)
* '\0' and '/' bytes. But we need to make some decision here.
* Assuming UTF-8 is currently the most sane thing.
*/
- wname = ConvertUtf8ToWCharAlloc(name, NULL);
+ wname = ConvertUtf8ToWCharAlloc(name, nullptr);
if (wname)
result = process_file_name(clipboard, wname, clipboard->localFiles);
@@ -517,7 +517,7 @@ static BOOL convert_local_file_to_filedescriptor(const struct synthetic_file* fi
static FILEDESCRIPTORW* convert_local_file_list_to_filedescriptors(wArrayList* files)
{
size_t count = 0;
- FILEDESCRIPTORW* descriptors = NULL;
+ FILEDESCRIPTORW* descriptors = nullptr;
count = ArrayList_Count(files);
@@ -537,14 +537,14 @@ static FILEDESCRIPTORW* convert_local_file_list_to_filedescriptors(wArrayList* f
return descriptors;
error:
free(descriptors);
- return NULL;
+ return nullptr;
}
static void* convert_any_uri_list_to_filedescriptors(wClipboard* clipboard,
WINPR_ATTR_UNUSED UINT32 formatId,
UINT32* pSize)
{
- FILEDESCRIPTORW* descriptors = NULL;
+ FILEDESCRIPTORW* descriptors = nullptr;
WINPR_ASSERT(clipboard);
WINPR_ASSERT(pSize);
@@ -552,7 +552,7 @@ static void* convert_any_uri_list_to_filedescriptors(wClipboard* clipboard,
descriptors = convert_local_file_list_to_filedescriptors(clipboard->localFiles);
*pSize = 0;
if (!descriptors)
- return NULL;
+ return nullptr;
*pSize = (UINT32)ArrayList_Count(clipboard->localFiles) * sizeof(FILEDESCRIPTORW);
clipboard->fileListSequenceNumber = clipboard->sequenceNumber;
@@ -564,9 +564,9 @@ static void* convert_uri_list_to_filedescriptors(wClipboard* clipboard, UINT32 f
{
const UINT32 expected = ClipboardGetFormatId(clipboard, mime_uri_list);
if (formatId != expected)
- return NULL;
+ return nullptr;
if (!process_uri_list(clipboard, (const char*)data, *pSize))
- return NULL;
+ return nullptr;
return convert_any_uri_list_to_filedescriptors(clipboard, formatId, pSize);
}
@@ -595,7 +595,7 @@ static BOOL process_files(wClipboard* clipboard, const char* data, UINT32 pSize,
goto fail;
{
- char* endptr = NULL;
+ char* endptr = nullptr;
char* tok = strtok_s(copy, "\n", &endptr);
while (tok)
{
@@ -605,7 +605,7 @@ static BOOL process_files(wClipboard* clipboard, const char* data, UINT32 pSize,
if (pSize < tok_len)
goto fail;
pSize -= WINPR_ASSERTING_INT_CAST(uint32_t, tok_len);
- tok = strtok_s(NULL, "\n", &endptr);
+ tok = strtok_s(nullptr, "\n", &endptr);
}
}
@@ -631,9 +631,9 @@ static void* convert_gnome_copied_files_to_filedescriptors(wClipboard* clipboard
{
const UINT32 expected = ClipboardGetFormatId(clipboard, mime_gnome_copied_files);
if (formatId != expected)
- return NULL;
+ return nullptr;
if (!process_gnome_copied_files(clipboard, (const char*)data, *pSize))
- return NULL;
+ return nullptr;
return convert_any_uri_list_to_filedescriptors(clipboard, formatId, pSize);
}
@@ -642,10 +642,10 @@ static void* convert_mate_copied_files_to_filedescriptors(wClipboard* clipboard,
{
const UINT32 expected = ClipboardGetFormatId(clipboard, mime_mate_copied_files);
if (formatId != expected)
- return NULL;
+ return nullptr;
if (!process_mate_copied_files(clipboard, (const char*)data, *pSize))
- return NULL;
+ return nullptr;
return convert_any_uri_list_to_filedescriptors(clipboard, formatId, pSize);
}
@@ -687,7 +687,7 @@ static const char* stop_at_special_chars(const char* str)
}
start++;
}
- return NULL;
+ return nullptr;
}
/* The universal converter from filedescriptors to different file lists */
@@ -704,46 +704,46 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
backslash.c[0] = '\\';
backslash.c[1] = '\0';
- const FILEDESCRIPTORW* descriptors = NULL;
+ const FILEDESCRIPTORW* descriptors = nullptr;
UINT32 nrDescriptors = 0;
size_t count = 0;
size_t alloc = 0;
size_t pos = 0;
size_t baseLength = 0;
- char* dst = NULL;
+ char* dst = nullptr;
size_t header_len = strlen(header);
size_t lineprefix_len = strlen(lineprefix);
size_t lineending_len = strlen(lineending);
size_t decoration_len = 0;
if (!clipboard || !data || !pSize)
- return NULL;
+ return nullptr;
if (*pSize < sizeof(UINT32))
- return NULL;
+ return nullptr;
if (clipboard->delegate.basePath)
baseLength = strnlen(clipboard->delegate.basePath, MAX_PATH);
if (baseLength < 1)
- return NULL;
+ return nullptr;
wStream sbuffer = WINPR_C_ARRAY_INIT;
wStream* s = Stream_StaticConstInit(&sbuffer, data, *pSize);
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
- return NULL;
+ return nullptr;
Stream_Read_UINT32(s, nrDescriptors);
count = (*pSize - 4) / sizeof(FILEDESCRIPTORW);
if ((count < 1) || (count != nrDescriptors))
- return NULL;
+ return nullptr;
descriptors = Stream_ConstPointer(s);
if (formatId != ClipboardGetFormatId(clipboard, mime_FileGroupDescriptorW))
- return NULL;
+ return nullptr;
/* Plus 1 for '/' between basepath and filename*/
decoration_len = lineprefix_len + lineending_len + baseLength + 1;
@@ -754,7 +754,7 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
{
const FILEDESCRIPTORW* dsc = &descriptors[x];
- if (_wcschr(dsc->cFileName, backslash.w) == NULL)
+ if (_wcschr(dsc->cFileName, backslash.w) == nullptr)
{
alloc += ARRAYSIZE(dsc->cFileName) *
8; /* Overallocate, just take the biggest value the result path can have */
@@ -770,7 +770,7 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
dst = calloc(alloc, sizeof(char));
if (!dst)
- return NULL;
+ return nullptr;
(void)_snprintf(&dst[0], alloc, "%s", header);
@@ -780,14 +780,14 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
{
const FILEDESCRIPTORW* dsc = &descriptors[x];
BOOL fail = TRUE;
- if (_wcschr(dsc->cFileName, backslash.w) != NULL)
+ if (_wcschr(dsc->cFileName, backslash.w) != nullptr)
{
continue;
}
int rc = -1;
char curName[520] = WINPR_C_ARRAY_INIT;
- const char* stop_at = NULL;
- const char* previous_at = NULL;
+ const char* stop_at = nullptr;
+ const char* previous_at = nullptr;
if (ConvertWCharNToUtf8(dsc->cFileName, ARRAYSIZE(dsc->cFileName), curName,
ARRAYSIZE(curName)) < 0)
@@ -801,7 +801,7 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
pos += (size_t)rc;
previous_at = curName;
- while ((stop_at = stop_at_special_chars(previous_at)) != NULL)
+ while ((stop_at = stop_at_special_chars(previous_at)) != nullptr)
{
const intptr_t diff = stop_at - previous_at;
if (diff < 0)
@@ -831,7 +831,7 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
if ((rc < 0) || fail)
{
free(dst);
- return NULL;
+ return nullptr;
}
pos += (size_t)rc;
@@ -846,7 +846,7 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
if (len < endlen)
{
free(dst);
- return NULL;
+ return nullptr;
}
if (memcmp(&dst[len - endlen], lineending, endlen) == 0)
@@ -912,7 +912,7 @@ static void array_free_synthetic_file(void* the_file)
static BOOL register_file_formats_and_synthesizers(wClipboard* clipboard)
{
- wObject* obj = NULL;
+ wObject* obj = nullptr;
/*
1. Gnome Nautilus based file manager (Nautilus only with version >= 3.30 AND < 40):
@@ -982,7 +982,7 @@ static BOOL register_file_formats_and_synthesizers(wClipboard* clipboard)
return TRUE;
error_free_local_files:
ArrayList_Free(clipboard->localFiles);
- clipboard->localFiles = NULL;
+ clipboard->localFiles = nullptr;
error:
return FALSE;
}
@@ -1069,8 +1069,8 @@ static UINT file_get_range(struct synthetic_file* file, UINT64 offset, UINT32 si
{
BY_HANDLE_FILE_INFORMATION FileInfo = WINPR_C_ARRAY_INIT;
- file->fd = CreateFileW(file->local_name, GENERIC_READ, 0, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ file->fd = CreateFileW(file->local_name, GENERIC_READ, 0, nullptr, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, nullptr);
if (INVALID_HANDLE_VALUE == file->fd)
{
char name[MAX_PATH] = WINPR_C_ARRAY_INIT;
@@ -1141,7 +1141,7 @@ static UINT file_get_range(struct synthetic_file* file, UINT64 offset, UINT32 si
error = ERROR_NOT_ENOUGH_MEMORY;
break;
}
- if (!ReadFile(file->fd, buffer, size, (LPDWORD)actual_size, NULL))
+ if (!ReadFile(file->fd, buffer, size, (LPDWORD)actual_size, nullptr))
{
free(buffer);
error = GetLastError();
@@ -1162,10 +1162,10 @@ static UINT delegate_file_request_range(wClipboardDelegate* delegate,
const wClipboardFileRangeRequest* request)
{
UINT error = 0;
- BYTE* data = NULL;
+ BYTE* data = nullptr;
UINT32 size = 0;
UINT64 offset = 0;
- struct synthetic_file* file = NULL;
+ struct synthetic_file* file = nullptr;
if (!delegate || !delegate->clipboard || !request)
return ERROR_BAD_ARGUMENTS;
diff --git a/winpr/libwinpr/clipboard/test/TestClipboardFormats.c b/winpr/libwinpr/clipboard/test/TestClipboardFormats.c
index d8569ee48..6c6e88082 100644
--- a/winpr/libwinpr/clipboard/test/TestClipboardFormats.c
+++ b/winpr/libwinpr/clipboard/test/TestClipboardFormats.c
@@ -8,9 +8,9 @@ int TestClipboardFormats(int argc, char* argv[])
{
int rc = -1;
UINT32 count = 0;
- UINT32* pFormatIds = NULL;
- const char* formatName = NULL;
- wClipboard* clipboard = NULL;
+ UINT32* pFormatIds = nullptr;
+ const char* formatName = nullptr;
+ wClipboard* clipboard = nullptr;
UINT32 utf8StringFormatId = 0;
WINPR_UNUSED(argc);
@@ -32,7 +32,7 @@ int TestClipboardFormats(int argc, char* argv[])
}
utf8StringFormatId = ClipboardRegisterFormat(clipboard, "UTF8_STRING");
- pFormatIds = NULL;
+ pFormatIds = nullptr;
count = ClipboardGetRegisteredFormatIds(clipboard, &pFormatIds);
for (UINT32 index = 0; index < count; index++)
@@ -50,7 +50,7 @@ int TestClipboardFormats(int argc, char* argv[])
UINT32 SrcSize = 0;
UINT32 DstSize = 0;
const char pSrcData[] = "this is a test string";
- char* pDstData = NULL;
+ char* pDstData = nullptr;
SrcSize = (UINT32)(strnlen(pSrcData, ARRAYSIZE(pSrcData)) + 1);
bSuccess = ClipboardSetData(clipboard, utf8StringFormatId, pSrcData, SrcSize);
@@ -64,18 +64,18 @@ int TestClipboardFormats(int argc, char* argv[])
if (1)
{
UINT32 DstSize = 0;
- char* pSrcData = NULL;
- WCHAR* pDstData = NULL;
+ char* pSrcData = nullptr;
+ WCHAR* pDstData = nullptr;
DstSize = 0;
pDstData = (WCHAR*)ClipboardGetData(clipboard, CF_UNICODETEXT, &DstSize);
- pSrcData = ConvertWCharNToUtf8Alloc(pDstData, DstSize / sizeof(WCHAR), NULL);
+ pSrcData = ConvertWCharNToUtf8Alloc(pDstData, DstSize / sizeof(WCHAR), nullptr);
(void)fprintf(stderr, "ClipboardGetData (synthetic): %s\n", pSrcData);
free(pDstData);
free(pSrcData);
}
- pFormatIds = NULL;
+ pFormatIds = nullptr;
count = ClipboardGetFormatIds(clipboard, &pFormatIds);
for (UINT32 index = 0; index < count; index++)
diff --git a/winpr/libwinpr/clipboard/test/TestUri.c b/winpr/libwinpr/clipboard/test/TestUri.c
index 3f78f2e6f..d63184d87 100644
--- a/winpr/libwinpr/clipboard/test/TestUri.c
+++ b/winpr/libwinpr/clipboard/test/TestUri.c
@@ -14,11 +14,11 @@
int TestUri(int argc, char* argv[])
{
int nRet = 0;
- const char* input[] = { /*uri, file or NULL*/
+ const char* input[] = { /*uri, file or nullptr*/
"file://root/a.txt",
- NULL,
+ nullptr,
"file:a.txt",
- NULL,
+ nullptr,
"file:///c:/windows/a.txt",
"c:/windows/a.txt",
"file:c:/windows/a.txt",
diff --git a/winpr/libwinpr/comm/comm.c b/winpr/libwinpr/comm/comm.c
index bef73aff3..9d6fe7729 100644
--- a/winpr/libwinpr/comm/comm.c
+++ b/winpr/libwinpr/comm/comm.c
@@ -54,7 +54,7 @@
#include "comm.h"
-static wLog* sLog = NULL;
+static wLog* sLog = nullptr;
struct comm_device
{
@@ -65,9 +65,9 @@ struct comm_device
typedef struct comm_device COMM_DEVICE;
/* FIXME: get a clever data structure, see also io.h functions */
-/* _CommDevices is a NULL-terminated array with a maximum of COMM_DEVICE_MAX COMM_DEVICE */
+/* _CommDevices is a nullptr-terminated array with a maximum of COMM_DEVICE_MAX COMM_DEVICE */
#define COMM_DEVICE_MAX 128
-static COMM_DEVICE** sCommDevices = NULL;
+static COMM_DEVICE** sCommDevices = nullptr;
static CRITICAL_SECTION sCommDevicesLock = WINPR_C_ARRAY_INIT;
static pthread_once_t sCommInitialized = PTHREAD_ONCE_INIT;
@@ -156,15 +156,15 @@ const HANDLE_CREATOR* GetCommHandleCreator(void)
.CreateFileA = CommCreateFileA };
return &sCommHandleCreator;
#else
- return NULL;
+ return nullptr;
#endif
}
static void CommInit(void)
{
/* NB: error management to be done outside of this function */
- WINPR_ASSERT(sLog == NULL);
- WINPR_ASSERT(sCommDevices == NULL);
+ WINPR_ASSERT(sLog == nullptr);
+ WINPR_ASSERT(sCommDevices == nullptr);
sCommDevices = (COMM_DEVICE**)calloc(COMM_DEVICE_MAX + 1, sizeof(COMM_DEVICE*));
if (!sCommDevices)
@@ -173,12 +173,12 @@ static void CommInit(void)
if (!InitializeCriticalSectionEx(&sCommDevicesLock, 0, 0))
{
free((void*)sCommDevices);
- sCommDevices = NULL;
+ sCommDevices = nullptr;
return;
}
sLog = WLog_Get(TAG);
- WINPR_ASSERT(sLog != NULL);
+ WINPR_ASSERT(sLog != nullptr);
}
/**
@@ -381,8 +381,8 @@ BOOL GetCommProperties(HANDLE hFile, LPCOMMPROP lpCommProp)
if (!CommIsHandleValid(hFile))
return FALSE;
- if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_PROPERTIES, NULL, 0, lpCommProp,
- sizeof(COMMPROP), &bytesReturned, NULL))
+ if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_PROPERTIES, nullptr, 0, lpCommProp,
+ sizeof(COMMPROP), &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "GetCommProperties failure.");
return FALSE;
@@ -402,7 +402,7 @@ BOOL GetCommProperties(HANDLE hFile, LPCOMMPROP lpCommProp)
*/
BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
{
- DCB* lpLocalDcb = NULL;
+ DCB* lpLocalDcb = nullptr;
struct termios currentState;
WINPR_COMM* pComm = (WINPR_COMM*)hFile;
DWORD bytesReturned = 0;
@@ -430,7 +430,7 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
lpLocalDcb = (DCB*)calloc(1, lpDCB->DCBlength);
- if (lpLocalDcb == NULL)
+ if (lpLocalDcb == nullptr)
{
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
@@ -440,8 +440,8 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
lpLocalDcb->DCBlength = lpDCB->DCBlength;
SERIAL_BAUD_RATE baudRate;
- if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_BAUD_RATE, NULL, 0, &baudRate,
- sizeof(SERIAL_BAUD_RATE), &bytesReturned, NULL))
+ if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_BAUD_RATE, nullptr, 0, &baudRate,
+ sizeof(SERIAL_BAUD_RATE), &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the baud rate.");
goto error_handle;
@@ -458,8 +458,8 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
lpLocalDcb->fParity = (currentState.c_iflag & INPCK) != 0;
SERIAL_HANDFLOW handflow;
- if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_HANDFLOW, NULL, 0, &handflow,
- sizeof(SERIAL_HANDFLOW), &bytesReturned, NULL))
+ if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_HANDFLOW, nullptr, 0, &handflow,
+ sizeof(SERIAL_HANDFLOW), &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the handflow settings.");
goto error_handle;
@@ -512,8 +512,8 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
{
SERIAL_LINE_CONTROL lineControl = WINPR_C_ARRAY_INIT;
- if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_LINE_CONTROL, NULL, 0, &lineControl,
- sizeof(SERIAL_LINE_CONTROL), &bytesReturned, NULL))
+ if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_LINE_CONTROL, nullptr, 0, &lineControl,
+ sizeof(SERIAL_LINE_CONTROL), &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the control settings.");
goto error_handle;
@@ -527,8 +527,8 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB)
{
SERIAL_CHARS serialChars = WINPR_C_ARRAY_INIT;
- if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_CHARS, NULL, 0, &serialChars,
- sizeof(SERIAL_CHARS), &bytesReturned, NULL))
+ if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_CHARS, nullptr, 0, &serialChars,
+ sizeof(SERIAL_CHARS), &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "GetCommState failure: could not get the serial chars.");
goto error_handle;
@@ -583,7 +583,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
baudRate.BaudRate = lpDCB->BaudRate;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_BAUD_RATE, &baudRate, sizeof(SERIAL_BAUD_RATE),
- NULL, 0, &bytesReturned, NULL))
+ nullptr, 0, &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the baud rate.");
return FALSE;
@@ -591,9 +591,9 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
SERIAL_CHARS serialChars;
- if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_CHARS, NULL, 0, &serialChars,
+ if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_CHARS, nullptr, 0, &serialChars,
sizeof(SERIAL_CHARS), &bytesReturned,
- NULL)) /* as of today, required for BreakChar */
+ nullptr)) /* as of today, required for BreakChar */
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not get the initial serial chars.");
return FALSE;
@@ -606,7 +606,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
serialChars.EventChar = lpDCB->EvtChar;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_CHARS, &serialChars, sizeof(SERIAL_CHARS),
- NULL, 0, &bytesReturned, NULL))
+ nullptr, 0, &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the serial chars.");
return FALSE;
@@ -618,7 +618,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
lineControl.WordLength = lpDCB->ByteSize;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_LINE_CONTROL, &lineControl,
- sizeof(SERIAL_LINE_CONTROL), NULL, 0, &bytesReturned, NULL))
+ sizeof(SERIAL_LINE_CONTROL), nullptr, 0, &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the control settings.");
return FALSE;
@@ -722,7 +722,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
handflow.XoffLimit = lpDCB->XoffLim;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_HANDFLOW, &handflow, sizeof(SERIAL_HANDFLOW),
- NULL, 0, &bytesReturned, NULL))
+ nullptr, 0, &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "SetCommState failure: could not set the handflow settings.");
return FALSE;
@@ -790,8 +790,8 @@ BOOL GetCommTimeouts(HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts)
/* as of today, SERIAL_TIMEOUTS and COMMTIMEOUTS structures are identical */
- if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_TIMEOUTS, NULL, 0, lpCommTimeouts,
- sizeof(COMMTIMEOUTS), &bytesReturned, NULL))
+ if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_GET_TIMEOUTS, nullptr, 0, lpCommTimeouts,
+ sizeof(COMMTIMEOUTS), &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "GetCommTimeouts failure.");
return FALSE;
@@ -815,7 +815,7 @@ BOOL SetCommTimeouts(HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts)
/* as of today, SERIAL_TIMEOUTS and COMMTIMEOUTS structures are identical */
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_TIMEOUTS, lpCommTimeouts, sizeof(COMMTIMEOUTS),
- NULL, 0, &bytesReturned, NULL))
+ nullptr, 0, &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "SetCommTimeouts failure.");
return FALSE;
@@ -932,8 +932,8 @@ BOOL PurgeComm(HANDLE hFile, DWORD dwFlags)
if (!CommIsHandleValid(hFile))
return FALSE;
- if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_PURGE, &dwFlags, sizeof(DWORD), NULL, 0,
- &bytesReturned, NULL))
+ if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_PURGE, &dwFlags, sizeof(DWORD), nullptr, 0,
+ &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "PurgeComm failure.");
return FALSE;
@@ -955,7 +955,7 @@ BOOL SetupComm(HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue)
queueSize.OutSize = dwOutQueue;
if (!CommDeviceIoControl(pComm, IOCTL_SERIAL_SET_QUEUE_SIZE, &queueSize,
- sizeof(SERIAL_QUEUE_SIZE), NULL, 0, &bytesReturned, NULL))
+ sizeof(SERIAL_QUEUE_SIZE), nullptr, 0, &bytesReturned, nullptr))
{
CommLog_Print(WLOG_WARN, "SetCommTimeouts failure.");
return FALSE;
@@ -1027,15 +1027,15 @@ BOOL WaitCommEvent(HANDLE hFile, WINPR_ATTR_UNUSED PDWORD lpEvtMask,
*/
BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTargetPath)
{
- LPTSTR storedDeviceName = NULL;
- LPTSTR storedTargetPath = NULL;
+ LPTSTR storedDeviceName = nullptr;
+ LPTSTR storedTargetPath = nullptr;
if (!CommInitialized())
return FALSE;
EnterCriticalSection(&sCommDevicesLock);
- if (sCommDevices == NULL)
+ if (sCommDevices == nullptr)
{
SetLastError(ERROR_DLL_INIT_FAILED);
goto error_handle;
@@ -1043,7 +1043,7 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
storedDeviceName = _tcsdup(lpDeviceName);
- if (storedDeviceName == NULL)
+ if (storedDeviceName == nullptr)
{
SetLastError(ERROR_OUTOFMEMORY);
goto error_handle;
@@ -1051,7 +1051,7 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
storedTargetPath = _tcsdup(lpTargetPath);
- if (storedTargetPath == NULL)
+ if (storedTargetPath == nullptr)
{
SetLastError(ERROR_OUTOFMEMORY);
goto error_handle;
@@ -1061,7 +1061,7 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
int i = 0;
for (; i < COMM_DEVICE_MAX; i++)
{
- if (sCommDevices[i] != NULL)
+ if (sCommDevices[i] != nullptr)
{
if (_tcscmp(sCommDevices[i]->name, storedDeviceName) == 0)
{
@@ -1078,7 +1078,7 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget
/* new emplacement */
sCommDevices[i] = (COMM_DEVICE*)calloc(1, sizeof(COMM_DEVICE));
- if (sCommDevices[i] == NULL)
+ if (sCommDevices[i] == nullptr)
{
SetLastError(ERROR_OUTOFMEMORY);
goto error_handle;
@@ -1111,7 +1111,7 @@ error_handle:
* lpTargetPath.
*
* The current implementation returns in any case 0 and 1 target
- * path. A NULL lpDeviceName is not supported yet to get all the
+ * path. A nullptr lpDeviceName is not supported yet to get all the
* paths.
*
* ERRORS:
@@ -1124,30 +1124,30 @@ error_handle:
*/
DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
{
- LPTSTR storedTargetPath = NULL;
+ LPTSTR storedTargetPath = nullptr;
SetLastError(ERROR_SUCCESS);
if (!CommInitialized())
return 0;
- if (sCommDevices == NULL)
+ if (sCommDevices == nullptr)
{
SetLastError(ERROR_DLL_INIT_FAILED);
return 0;
}
- if (lpDeviceName == NULL || lpTargetPath == NULL)
+ if (lpDeviceName == nullptr || lpTargetPath == nullptr)
{
SetLastError(ERROR_NOT_SUPPORTED);
return 0;
}
EnterCriticalSection(&sCommDevicesLock);
- storedTargetPath = NULL;
+ storedTargetPath = nullptr;
for (int i = 0; i < COMM_DEVICE_MAX; i++)
{
- if (sCommDevices[i] != NULL)
+ if (sCommDevices[i] != nullptr)
{
if (_tcscmp(sCommDevices[i]->name, lpDeviceName) == 0)
{
@@ -1163,7 +1163,7 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
LeaveCriticalSection(&sCommDevicesLock);
- if (storedTargetPath == NULL)
+ if (storedTargetPath == nullptr)
{
SetLastError(ERROR_INVALID_DATA);
return 0;
@@ -1205,8 +1205,8 @@ BOOL IsCommDevice(LPCTSTR lpDeviceName)
void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID driverId)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_COMM* pComm = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_COMM* pComm = nullptr;
if (!CommInitialized())
return;
@@ -1221,17 +1221,10 @@ void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID driverId)
pComm->serverSerialDriverId = driverId;
}
-static HANDLE_OPS ops = { CommIsHandled, CommCloseHandle,
- CommGetFd, NULL, /* CleanupHandle */
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL,
- NULL };
+static HANDLE_OPS ops = { CommIsHandled, CommCloseHandle, CommGetFd, nullptr, /* CleanupHandle */
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr };
/**
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa363198%28v=vs.85%29.aspx
@@ -1244,7 +1237,7 @@ static HANDLE_OPS ops = { CommIsHandled, CommCloseHandle,
* @param dwShareMode must be zero, INVALID_HANDLE_VALUE is returned
* otherwise and GetLastError() should return ERROR_SHARING_VIOLATION.
*
- * @param lpSecurityAttributes NULL expected, a warning message is printed
+ * @param lpSecurityAttributes nullptr expected, a warning message is printed
* otherwise. TODO: better support.
*
* @param dwCreationDisposition must be OPEN_EXISTING. If the
@@ -1254,7 +1247,7 @@ static HANDLE_OPS ops = { CommIsHandled, CommCloseHandle,
* @param dwFlagsAndAttributes zero expected, a warning message is
* printed otherwise.
*
- * @param hTemplateFile must be NULL.
+ * @param hTemplateFile must be nullptr.
*
* @return INVALID_HANDLE_VALUE on error.
*/
@@ -1264,7 +1257,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
{
CHAR devicePath[MAX_PATH] = WINPR_C_ARRAY_INIT;
struct stat deviceStat = WINPR_C_ARRAY_INIT;
- WINPR_COMM* pComm = NULL;
+ WINPR_COMM* pComm = nullptr;
struct termios upcomingTermios = WINPR_C_ARRAY_INIT;
if (!CommInitialized())
@@ -1285,7 +1278,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
/* TODO: Prevents other processes from opening a file or
* device if they request delete, read, or write access. */
- if (lpSecurityAttributes != NULL)
+ if (lpSecurityAttributes != nullptr)
{
CommLog_Print(WLOG_WARN, "unexpected security attributes, nLength=%" PRIu32 "",
lpSecurityAttributes->nLength);
@@ -1323,7 +1316,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
dwFlagsAndAttributes);
}
- if (hTemplateFile != NULL)
+ if (hTemplateFile != nullptr)
{
SetLastError(ERROR_NOT_SUPPORTED); /* FIXME: other proper error? */
return INVALID_HANDLE_VALUE;
@@ -1331,7 +1324,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
pComm = (WINPR_COMM*)calloc(1, sizeof(WINPR_COMM));
- if (pComm == NULL)
+ if (pComm == nullptr)
{
SetLastError(ERROR_OUTOFMEMORY);
return INVALID_HANDLE_VALUE;
diff --git a/winpr/libwinpr/comm/comm_io.c b/winpr/libwinpr/comm/comm_io.c
index b8a68b74d..04cc7cda3 100644
--- a/winpr/libwinpr/comm/comm_io.c
+++ b/winpr/libwinpr/comm/comm_io.c
@@ -72,27 +72,28 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
int biggestFd = -1;
fd_set read_set;
int nbFds = 0;
- COMMTIMEOUTS* pTimeouts = NULL;
+ COMMTIMEOUTS* pTimeouts = nullptr;
UCHAR vmin = 0;
UCHAR vtime = 0;
LONGLONG Tmax = 0;
struct timeval tmaxTimeout;
- struct timeval* pTmaxTimeout = NULL;
+ struct timeval* pTmaxTimeout = nullptr;
struct termios currentTermios;
EnterCriticalSection(&pComm->ReadLock); /* KISSer by the function's beginning */
if (!CommIsHandled(hDevice))
goto return_false;
- if (lpOverlapped != NULL)
+ if (lpOverlapped != nullptr)
{
SetLastError(ERROR_NOT_SUPPORTED);
goto return_false;
}
- if (lpNumberOfBytesRead == NULL)
+ if (lpNumberOfBytesRead == nullptr)
{
- SetLastError(ERROR_INVALID_PARAMETER); /* since we doesn't support lpOverlapped != NULL */
+ SetLastError(
+ ERROR_INVALID_PARAMETER); /* since we doesn't support lpOverlapped != nullptr */
goto return_false;
}
@@ -190,7 +191,7 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
/* INDEFinitely */
if ((Tmax == 0) && (pTimeouts->ReadIntervalTimeout < MAXULONG) &&
(pTimeouts->ReadTotalTimeoutMultiplier == 0))
- pTmaxTimeout = NULL;
+ pTmaxTimeout = nullptr;
}
if ((currentTermios.c_cc[VMIN] != vmin) || (currentTermios.c_cc[VTIME] != vtime))
@@ -209,9 +210,9 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
}
}
- /* wait indefinitely if pTmaxTimeout is NULL */
+ /* wait indefinitely if pTmaxTimeout is nullptr */
- if (pTmaxTimeout != NULL)
+ if (pTmaxTimeout != nullptr)
{
ZeroMemory(pTmaxTimeout, sizeof(struct timeval));
@@ -241,7 +242,7 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
WINPR_ASSERT(pComm->fd_read < FD_SETSIZE);
FD_SET(pComm->fd_read_event, &read_set);
FD_SET(pComm->fd_read, &read_set);
- nbFds = select(biggestFd + 1, &read_set, NULL, NULL, pTmaxTimeout);
+ nbFds = select(biggestFd + 1, &read_set, nullptr, nullptr, pTmaxTimeout);
if (nbFds < 0)
{
@@ -373,21 +374,22 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
{
WINPR_COMM* pComm = (WINPR_COMM*)hDevice;
struct timeval tmaxTimeout;
- struct timeval* pTmaxTimeout = NULL;
+ struct timeval* pTmaxTimeout = nullptr;
EnterCriticalSection(&pComm->WriteLock); /* KISSer by the function's beginning */
if (!CommIsHandled(hDevice))
goto return_false;
- if (lpOverlapped != NULL)
+ if (lpOverlapped != nullptr)
{
SetLastError(ERROR_NOT_SUPPORTED);
goto return_false;
}
- if (lpNumberOfBytesWritten == NULL)
+ if (lpNumberOfBytesWritten == nullptr)
{
- SetLastError(ERROR_INVALID_PARAMETER); /* since we doesn't support lpOverlapped != NULL */
+ SetLastError(
+ ERROR_INVALID_PARAMETER); /* since we doesn't support lpOverlapped != nullptr */
goto return_false;
}
@@ -428,7 +430,7 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
else if ((pComm->timeouts.WriteTotalTimeoutMultiplier == 0) &&
(pComm->timeouts.WriteTotalTimeoutConstant == 0))
{
- pTmaxTimeout = NULL;
+ pTmaxTimeout = nullptr;
}
}
@@ -451,7 +453,7 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
WINPR_ASSERT(pComm->fd_write < FD_SETSIZE);
FD_SET(pComm->fd_write_event, &event_set);
FD_SET(pComm->fd_write, &write_set);
- nbFds = select(biggestFd + 1, &event_set, &write_set, NULL, pTmaxTimeout);
+ nbFds = select(biggestFd + 1, &event_set, &write_set, nullptr, pTmaxTimeout);
if (nbFds < 0)
{
diff --git a/winpr/libwinpr/comm/comm_ioctl.c b/winpr/libwinpr/comm/comm_ioctl.c
index 89ae87eb3..9b207ca54 100644
--- a/winpr/libwinpr/comm/comm_ioctl.c
+++ b/winpr/libwinpr/comm/comm_ioctl.c
@@ -56,7 +56,7 @@ static BOOL s_CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID
{
char buffer[128] = WINPR_C_ARRAY_INIT;
WINPR_COMM* pComm = (WINPR_COMM*)hDevice;
- const SERIAL_DRIVER* pServerSerialDriver = NULL;
+ const SERIAL_DRIVER* pServerSerialDriver = nullptr;
if (!CommIsHandleValid(hDevice))
return FALSE;
@@ -67,9 +67,10 @@ static BOOL s_CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID
return FALSE;
}
- if (lpBytesReturned == NULL)
+ if (lpBytesReturned == nullptr)
{
- SetLastError(ERROR_INVALID_PARAMETER); /* since we doesn't support lpOverlapped != NULL */
+ SetLastError(
+ ERROR_INVALID_PARAMETER); /* since we doesn't support lpOverlapped != nullptr */
return FALSE;
}
@@ -107,7 +108,7 @@ static BOOL s_CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID
break;
}
- WINPR_ASSERT(pServerSerialDriver != NULL);
+ WINPR_ASSERT(pServerSerialDriver != nullptr);
switch (dwIoControlCode)
{
diff --git a/winpr/libwinpr/comm/comm_ioctl.h b/winpr/libwinpr/comm/comm_ioctl.h
index 4349174e2..9d59ad477 100644
--- a/winpr/libwinpr/comm/comm_ioctl.h
+++ b/winpr/libwinpr/comm/comm_ioctl.h
@@ -182,7 +182,7 @@ extern "C"
#define SERIAL_DCD_STATE ((ULONG)0x00000080)
/**
- * A function might be NULL if not supported by the underlying driver.
+ * A function might be nullptr if not supported by the underlying driver.
*
* FIXME: better have to use input and output buffers for all functions?
*/
diff --git a/winpr/libwinpr/comm/comm_sercx2_sys.c b/winpr/libwinpr/comm/comm_sercx2_sys.c
index e79a2402e..07d8427de 100644
--- a/winpr/libwinpr/comm/comm_sercx2_sys.c
+++ b/winpr/libwinpr/comm/comm_sercx2_sys.c
@@ -128,36 +128,36 @@ static BOOL purge(WINPR_COMM* pComm, const ULONG* pPurgeMask)
static SERIAL_DRIVER SerCx2Sys = {
.id = SerialDriverSerCx2Sys,
.name = _T("SerCx2.sys"),
- .set_baud_rate = NULL,
- .get_baud_rate = NULL,
- .get_properties = NULL,
+ .set_baud_rate = nullptr,
+ .get_baud_rate = nullptr,
+ .get_properties = nullptr,
.set_serial_chars = set_serial_chars,
.get_serial_chars = get_serial_chars,
- .set_line_control = NULL,
- .get_line_control = NULL,
- .set_handflow = NULL,
- .get_handflow = NULL,
- .set_timeouts = NULL,
- .get_timeouts = NULL,
- .set_dtr = NULL,
- .clear_dtr = NULL,
- .set_rts = NULL,
- .clear_rts = NULL,
- .get_modemstatus = NULL,
+ .set_line_control = nullptr,
+ .get_line_control = nullptr,
+ .set_handflow = nullptr,
+ .get_handflow = nullptr,
+ .set_timeouts = nullptr,
+ .get_timeouts = nullptr,
+ .set_dtr = nullptr,
+ .clear_dtr = nullptr,
+ .set_rts = nullptr,
+ .clear_rts = nullptr,
+ .get_modemstatus = nullptr,
.set_wait_mask = set_wait_mask,
- .get_wait_mask = NULL,
- .wait_on_mask = NULL,
- .set_queue_size = NULL,
+ .get_wait_mask = nullptr,
+ .wait_on_mask = nullptr,
+ .set_queue_size = nullptr,
.purge = purge,
- .get_commstatus = NULL,
- .set_break_on = NULL,
- .set_break_off = NULL,
- .set_xoff = NULL, /* not supported by SerCx2.sys */
- .set_xon = NULL, /* not supported by SerCx2.sys */
- .get_dtrrts = NULL,
- .config_size = NULL, /* not supported by SerCx2.sys */
- .immediate_char = NULL, /* not supported by SerCx2.sys */
- .reset_device = NULL, /* not supported by SerCx2.sys */
+ .get_commstatus = nullptr,
+ .set_break_on = nullptr,
+ .set_break_off = nullptr,
+ .set_xoff = nullptr, /* not supported by SerCx2.sys */
+ .set_xon = nullptr, /* not supported by SerCx2.sys */
+ .get_dtrrts = nullptr,
+ .config_size = nullptr, /* not supported by SerCx2.sys */
+ .immediate_char = nullptr, /* not supported by SerCx2.sys */
+ .reset_device = nullptr, /* not supported by SerCx2.sys */
};
const SERIAL_DRIVER* SerCx2Sys_s(void)
@@ -166,7 +166,7 @@ const SERIAL_DRIVER* SerCx2Sys_s(void)
const SERIAL_DRIVER* pSerialSys = SerialSys_s();
const SERIAL_DRIVER* pSerCxSys = SerCxSys_s();
if (!pSerialSys || !pSerCxSys)
- return NULL;
+ return nullptr;
SerCx2Sys.set_baud_rate = pSerialSys->set_baud_rate;
SerCx2Sys.get_baud_rate = pSerialSys->get_baud_rate;
diff --git a/winpr/libwinpr/comm/comm_sercx_sys.c b/winpr/libwinpr/comm/comm_sercx_sys.c
index 39843c1b3..6c0bcf856 100644
--- a/winpr/libwinpr/comm/comm_sercx_sys.c
+++ b/winpr/libwinpr/comm/comm_sercx_sys.c
@@ -177,36 +177,36 @@ static BOOL set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
static SERIAL_DRIVER SerCxSys = {
.id = SerialDriverSerCxSys,
.name = _T("SerCx.sys"),
- .set_baud_rate = NULL,
- .get_baud_rate = NULL,
- .get_properties = NULL,
- .set_serial_chars = NULL,
- .get_serial_chars = NULL,
- .set_line_control = NULL,
- .get_line_control = NULL,
+ .set_baud_rate = nullptr,
+ .get_baud_rate = nullptr,
+ .get_properties = nullptr,
+ .set_serial_chars = nullptr,
+ .get_serial_chars = nullptr,
+ .set_line_control = nullptr,
+ .get_line_control = nullptr,
.set_handflow = set_handflow,
.get_handflow = get_handflow,
- .set_timeouts = NULL,
- .get_timeouts = NULL,
- .set_dtr = NULL,
- .clear_dtr = NULL,
- .set_rts = NULL,
- .clear_rts = NULL,
- .get_modemstatus = NULL,
+ .set_timeouts = nullptr,
+ .get_timeouts = nullptr,
+ .set_dtr = nullptr,
+ .clear_dtr = nullptr,
+ .set_rts = nullptr,
+ .clear_rts = nullptr,
+ .get_modemstatus = nullptr,
.set_wait_mask = set_wait_mask,
- .get_wait_mask = NULL,
- .wait_on_mask = NULL,
- .set_queue_size = NULL,
- .purge = NULL,
- .get_commstatus = NULL,
- .set_break_on = NULL,
- .set_break_off = NULL,
- .set_xoff = NULL,
- .set_xon = NULL,
- .get_dtrrts = NULL,
- .config_size = NULL, /* not supported by SerCx.sys */
- .immediate_char = NULL,
- .reset_device = NULL, /* not supported by SerCx.sys */
+ .get_wait_mask = nullptr,
+ .wait_on_mask = nullptr,
+ .set_queue_size = nullptr,
+ .purge = nullptr,
+ .get_commstatus = nullptr,
+ .set_break_on = nullptr,
+ .set_break_off = nullptr,
+ .set_xoff = nullptr,
+ .set_xon = nullptr,
+ .get_dtrrts = nullptr,
+ .config_size = nullptr, /* not supported by SerCx.sys */
+ .immediate_char = nullptr,
+ .reset_device = nullptr, /* not supported by SerCx.sys */
};
const SERIAL_DRIVER* SerCxSys_s(void)
@@ -214,7 +214,7 @@ const SERIAL_DRIVER* SerCxSys_s(void)
/* _SerCxSys completed with inherited functions from SerialSys */
const SERIAL_DRIVER* pSerialSys = SerialSys_s();
if (!pSerialSys)
- return NULL;
+ return nullptr;
SerCxSys.set_baud_rate = pSerialSys->set_baud_rate;
SerCxSys.get_baud_rate = pSerialSys->get_baud_rate;
diff --git a/winpr/libwinpr/comm/comm_serial_sys.c b/winpr/libwinpr/comm/comm_serial_sys.c
index 998801a81..e0a498add 100644
--- a/winpr/libwinpr/comm/comm_serial_sys.c
+++ b/winpr/libwinpr/comm/comm_serial_sys.c
@@ -1516,14 +1516,14 @@ static BOOL wait_on_mask(WINPR_COMM* pComm, ULONG* pOutputMask)
static BOOL set_break_on(WINPR_COMM* pComm)
{
WINPR_ASSERT(pComm);
- return CommIoCtl(pComm, TIOCSBRK, NULL);
+ return CommIoCtl(pComm, TIOCSBRK, nullptr);
}
static BOOL set_break_off(WINPR_COMM* pComm)
{
WINPR_ASSERT(pComm);
- return CommIoCtl(pComm, TIOCCBRK, NULL);
+ return CommIoCtl(pComm, TIOCCBRK, nullptr);
}
static BOOL set_xoff(WINPR_COMM* pComm)
@@ -1605,7 +1605,7 @@ static BOOL immediate_char(WINPR_COMM* pComm, const UCHAR* pChar)
* FIXME: see also get_commstatus()'s WaitForImmediate boolean
*/
- result = CommWriteFile(pComm, pChar, 1, &nbBytesWritten, NULL);
+ result = CommWriteFile(pComm, pChar, 1, &nbBytesWritten, nullptr);
WINPR_ASSERT(nbBytesWritten == 1);
diff --git a/winpr/libwinpr/comm/test/TestCommConfig.c b/winpr/libwinpr/comm/test/TestCommConfig.c
index 27c4ccbcd..387400c8d 100644
--- a/winpr/libwinpr/comm/test/TestCommConfig.c
+++ b/winpr/libwinpr/comm/test/TestCommConfig.c
@@ -34,8 +34,8 @@ int TestCommConfig(int argc, char* argv[])
COMMPROP commProp = WINPR_C_ARRAY_INIT;
struct stat statbuf = WINPR_C_ARRAY_INIT;
- HANDLE hComm =
- CreateFileA(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ HANDLE hComm = CreateFileA(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING,
+ 0, nullptr);
if (hComm && (hComm != INVALID_HANDLE_VALUE))
{
@@ -59,9 +59,9 @@ int TestCommConfig(int argc, char* argv[])
}
hComm = CreateFileA(lpFileName, GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_WRITE, /* invalid parameter */
- NULL, CREATE_NEW, /* invalid parameter */
- 0, (HANDLE)1234); /* invalid parameter */
+ FILE_SHARE_WRITE, /* invalid parameter */
+ nullptr, CREATE_NEW, /* invalid parameter */
+ 0, (HANDLE)1234); /* invalid parameter */
if (hComm != INVALID_HANDLE_VALUE)
{
(void)fprintf(
@@ -70,7 +70,8 @@ int TestCommConfig(int argc, char* argv[])
return EXIT_FAILURE;
}
- hComm = CreateFileA(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ hComm = CreateFileA(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0,
+ nullptr);
if (!hComm || (hComm == INVALID_HANDLE_VALUE))
{
diff --git a/winpr/libwinpr/comm/test/TestCommDevice.c b/winpr/libwinpr/comm/test/TestCommDevice.c
index c3113b724..3cf41f5e2 100644
--- a/winpr/libwinpr/comm/test/TestCommDevice.c
+++ b/winpr/libwinpr/comm/test/TestCommDevice.c
@@ -66,9 +66,10 @@ static int test_CommDevice(LPCTSTR lpDeviceName, BOOL expectedResult)
if ((tlen >= (ARRAYSIZE(lpTargetPath) - 1)) || (lpTargetPath[tlen + 1] != 0))
{
- _tprintf(_T("QueryCommDevice failure: device name: %s, the second NULL character is ")
- _T("missing at the end of the buffer\n"),
- lpDeviceName);
+ _tprintf(
+ _T("QueryCommDevice failure: device name: %s, the second nullptr character is ")
+ _T("missing at the end of the buffer\n"),
+ lpDeviceName);
return FALSE;
}
}
diff --git a/winpr/libwinpr/comm/test/TestCommMonitor.c b/winpr/libwinpr/comm/test/TestCommMonitor.c
index be5584c7b..6530f4cd0 100644
--- a/winpr/libwinpr/comm/test/TestCommMonitor.c
+++ b/winpr/libwinpr/comm/test/TestCommMonitor.c
@@ -7,15 +7,15 @@
int TestCommMonitor(int argc, char* argv[])
{
- HANDLE hComm = NULL;
+ HANDLE hComm = nullptr;
DWORD dwError = 0;
BOOL fSuccess = 0;
DWORD dwEvtMask = 0;
OVERLAPPED overlapped = WINPR_C_ARRAY_INIT;
LPCSTR lpFileName = "\\\\.\\COM1";
- hComm = CreateFileA(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
- FILE_FLAG_OVERLAPPED, NULL);
+ hComm = CreateFileA(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING,
+ FILE_FLAG_OVERLAPPED, nullptr);
if (!hComm || (hComm == INVALID_HANDLE_VALUE))
{
@@ -31,7 +31,7 @@ int TestCommMonitor(int argc, char* argv[])
return -1;
}
- if (!(overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(overlapped.hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
printf("CreateEvent failed: GetLastError() = %" PRIu32 "\n", GetLastError());
return -1;
diff --git a/winpr/libwinpr/comm/test/TestControlSettings.c b/winpr/libwinpr/comm/test/TestControlSettings.c
index 8a5ec4555..ed2faa671 100644
--- a/winpr/libwinpr/comm/test/TestControlSettings.c
+++ b/winpr/libwinpr/comm/test/TestControlSettings.c
@@ -30,7 +30,7 @@ int TestControlSettings(int argc, char* argv[])
{
struct stat statbuf = WINPR_C_ARRAY_INIT;
BOOL result = 0;
- HANDLE hComm = NULL;
+ HANDLE hComm = nullptr;
DCB dcb = WINPR_C_ARRAY_INIT;
if (stat("/dev/ttyS0", &statbuf) < 0)
@@ -46,7 +46,7 @@ int TestControlSettings(int argc, char* argv[])
return EXIT_FAILURE;
}
- hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
if (hComm == INVALID_HANDLE_VALUE)
{
(void)fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());
diff --git a/winpr/libwinpr/comm/test/TestGetCommState.c b/winpr/libwinpr/comm/test/TestGetCommState.c
index b820374b6..cdc318a3d 100644
--- a/winpr/libwinpr/comm/test/TestGetCommState.c
+++ b/winpr/libwinpr/comm/test/TestGetCommState.c
@@ -28,7 +28,7 @@
static BOOL test_generic(HANDLE hComm)
{
DCB dcb = WINPR_C_ARRAY_INIT;
- DCB* pDcb = NULL;
+ DCB* pDcb = nullptr;
BOOL result = 0;
ZeroMemory(&dcb, sizeof(DCB));
@@ -79,7 +79,7 @@ int TestGetCommState(int argc, char* argv[])
{
struct stat statbuf = WINPR_C_ARRAY_INIT;
BOOL result = 0;
- HANDLE hComm = NULL;
+ HANDLE hComm = nullptr;
if (stat("/dev/ttyS0", &statbuf) < 0)
{
@@ -94,7 +94,8 @@ int TestGetCommState(int argc, char* argv[])
return EXIT_FAILURE;
}
- hComm = CreateFileA("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ hComm =
+ CreateFileA("COM1", GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
if (hComm == INVALID_HANDLE_VALUE)
{
diff --git a/winpr/libwinpr/comm/test/TestHandflow.c b/winpr/libwinpr/comm/test/TestHandflow.c
index 531ef0ed9..27834fb73 100644
--- a/winpr/libwinpr/comm/test/TestHandflow.c
+++ b/winpr/libwinpr/comm/test/TestHandflow.c
@@ -39,7 +39,7 @@ int TestHandflow(int argc, char* argv[])
{
struct stat statbuf = WINPR_C_ARRAY_INIT;
BOOL result = 0;
- HANDLE hComm = NULL;
+ HANDLE hComm = nullptr;
if (stat("/dev/ttyS0", &statbuf) < 0)
{
@@ -54,7 +54,7 @@ int TestHandflow(int argc, char* argv[])
return EXIT_FAILURE;
}
- hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
if (hComm == INVALID_HANDLE_VALUE)
{
(void)fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());
diff --git a/winpr/libwinpr/comm/test/TestSerialChars.c b/winpr/libwinpr/comm/test/TestSerialChars.c
index 9d024aee5..4626ae900 100644
--- a/winpr/libwinpr/comm/test/TestSerialChars.c
+++ b/winpr/libwinpr/comm/test/TestSerialChars.c
@@ -134,7 +134,7 @@ int TestSerialChars(int argc, char* argv[])
{
struct stat statbuf = WINPR_C_ARRAY_INIT;
BOOL result = 0;
- HANDLE hComm = NULL;
+ HANDLE hComm = nullptr;
if (stat("/dev/ttyS0", &statbuf) < 0)
{
@@ -149,7 +149,7 @@ int TestSerialChars(int argc, char* argv[])
return EXIT_FAILURE;
}
- hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
if (hComm == INVALID_HANDLE_VALUE)
{
(void)fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());
diff --git a/winpr/libwinpr/comm/test/TestSetCommState.c b/winpr/libwinpr/comm/test/TestSetCommState.c
index aafdd083a..4e2fc8416 100644
--- a/winpr/libwinpr/comm/test/TestSetCommState.c
+++ b/winpr/libwinpr/comm/test/TestSetCommState.c
@@ -261,7 +261,7 @@ int TestSetCommState(int argc, char* argv[])
{
struct stat statbuf = WINPR_C_ARRAY_INIT;
BOOL result = 0;
- HANDLE hComm = NULL;
+ HANDLE hComm = nullptr;
if (stat("/dev/ttyS0", &statbuf) < 0)
{
@@ -276,7 +276,7 @@ int TestSetCommState(int argc, char* argv[])
return EXIT_FAILURE;
}
- hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
if (hComm == INVALID_HANDLE_VALUE)
{
(void)fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());
diff --git a/winpr/libwinpr/comm/test/TestTimeouts.c b/winpr/libwinpr/comm/test/TestTimeouts.c
index d4aa0329e..6a157bd79 100644
--- a/winpr/libwinpr/comm/test/TestTimeouts.c
+++ b/winpr/libwinpr/comm/test/TestTimeouts.c
@@ -88,7 +88,7 @@ int TestTimeouts(int argc, char* argv[])
{
struct stat statbuf;
BOOL result = 0;
- HANDLE hComm = NULL;
+ HANDLE hComm = nullptr;
if (stat("/dev/ttyS0", &statbuf) < 0)
{
@@ -103,7 +103,7 @@ int TestTimeouts(int argc, char* argv[])
return EXIT_FAILURE;
}
- hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
if (hComm == INVALID_HANDLE_VALUE)
{
(void)fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());
diff --git a/winpr/libwinpr/credentials/credentials.c b/winpr/libwinpr/credentials/credentials.c
index ec0a23edc..53005416e 100644
--- a/winpr/libwinpr/credentials/credentials.c
+++ b/winpr/libwinpr/credentials/credentials.c
@@ -167,13 +167,13 @@ static size_t cred_encode(const BYTE* bin, size_t len, char* cred, size_t credle
BOOL CredMarshalCredentialW(CRED_MARSHAL_TYPE CredType, PVOID Credential,
LPWSTR* MarshaledCredential)
{
- char* b = NULL;
+ char* b = nullptr;
if (!CredMarshalCredentialA(CredType, Credential, &b) || !b)
return FALSE;
- *MarshaledCredential = ConvertUtf8ToWCharAlloc(b, NULL);
+ *MarshaledCredential = ConvertUtf8ToWCharAlloc(b, nullptr);
free(b);
- return (*MarshaledCredential != NULL);
+ return (*MarshaledCredential != nullptr);
}
BOOL CredMarshalCredentialA(CRED_MARSHAL_TYPE CredType, PVOID Credential,
@@ -211,9 +211,9 @@ BOOL CredMarshalCredentialA(CRED_MARSHAL_TYPE CredType, PVOID Credential,
BOOL CredUnmarshalCredentialW(LPCWSTR cred, PCRED_MARSHAL_TYPE CredType, PVOID* Credential)
{
- char* str = NULL;
+ char* str = nullptr;
if (cred)
- str = ConvertWCharToUtf8Alloc(cred, NULL);
+ str = ConvertWCharToUtf8Alloc(cred, nullptr);
const BOOL rc = CredUnmarshalCredentialA(str, CredType, Credential);
free(str);
return rc;
@@ -275,7 +275,7 @@ BOOL CredUnmarshalCredentialA(LPCSTR cred, PCRED_MARSHAL_TYPE CredType, PVOID* C
BOOL CredIsMarshaledCredentialW(LPCWSTR MarshaledCredential)
{
CRED_MARSHAL_TYPE t = BinaryBlobForSystem;
- void* out = NULL;
+ void* out = nullptr;
BOOL ret = CredUnmarshalCredentialW(MarshaledCredential, &t, &out);
if (out)
@@ -287,7 +287,7 @@ BOOL CredIsMarshaledCredentialW(LPCWSTR MarshaledCredential)
BOOL CredIsMarshaledCredentialA(LPCSTR MarshaledCredential)
{
CRED_MARSHAL_TYPE t = BinaryBlobForSystem;
- void* out = NULL;
+ void* out = nullptr;
BOOL ret = CredUnmarshalCredentialA(MarshaledCredential, &t, &out);
if (out)
CredFree(out);
diff --git a/winpr/libwinpr/credentials/test/TestMarshalUnmarshal.c b/winpr/libwinpr/credentials/test/TestMarshalUnmarshal.c
index aa3ba5ae4..cd36ade49 100644
--- a/winpr/libwinpr/credentials/test/TestMarshalUnmarshal.c
+++ b/winpr/libwinpr/credentials/test/TestMarshalUnmarshal.c
@@ -42,7 +42,7 @@ static int TestUnmarshal(WINPR_ATTR_UNUSED int argc, WINPR_ATTR_UNUSED char** ar
for (size_t i = 0; i < ARRAYSIZE(testValues); i++)
{
CRED_MARSHAL_TYPE t = BinaryBlobForSystem;
- CERT_CREDENTIAL_INFO* certInfo = NULL;
+ CERT_CREDENTIAL_INFO* certInfo = nullptr;
const TestItem* const val = &testValues[i];
if (!CredUnmarshalCredentialA(val->marshalled, &t, (void**)&certInfo) || !certInfo ||
@@ -69,7 +69,7 @@ static int TestMarshal(WINPR_ATTR_UNUSED int argc, WINPR_ATTR_UNUSED char** argv
const TestItem* const val = &testValues[i];
memcpy(certInfo.rgbHashOfCert, val->source, sizeof(certInfo.rgbHashOfCert));
- LPSTR out = NULL;
+ LPSTR out = nullptr;
if (!CredMarshalCredentialA(CertCredential, &certInfo, &out) || !out)
return -1;
diff --git a/winpr/libwinpr/crt/alignment.c b/winpr/libwinpr/crt/alignment.c
index bc3fa6e51..b1c2e1711 100644
--- a/winpr/libwinpr/crt/alignment.c
+++ b/winpr/libwinpr/crt/alignment.c
@@ -54,7 +54,7 @@ void* winpr_aligned_malloc(size_t size, size_t alignment)
void* winpr_aligned_calloc(size_t count, size_t size, size_t alignment)
{
- return winpr_aligned_recalloc(NULL, count, size, alignment);
+ return winpr_aligned_recalloc(nullptr, count, size, alignment);
}
void* winpr_aligned_realloc(void* memblock, size_t size, size_t alignment)
@@ -72,29 +72,29 @@ void* winpr_aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
size_t header = 0;
size_t alignsize = 0;
uintptr_t basesize = 0;
- void* base = NULL;
- void* memblock = NULL;
- WINPR_ALIGNED_MEM* pMem = NULL;
+ void* base = nullptr;
+ void* memblock = nullptr;
+ WINPR_ALIGNED_MEM* pMem = nullptr;
/* alignment must be a power of 2 */
if (alignment % 2 == 1)
- return NULL;
+ return nullptr;
/* offset must be less than size */
if (offset >= size)
- return NULL;
+ return nullptr;
/* minimum alignment is pointer size */
if (alignment < sizeof(void*))
alignment = sizeof(void*);
if (alignment > SIZE_MAX - sizeof(WINPR_ALIGNED_MEM))
- return NULL;
+ return nullptr;
header = sizeof(WINPR_ALIGNED_MEM) + alignment;
if (size > SIZE_MAX - header)
- return NULL;
+ return nullptr;
alignsize = size + header;
/* malloc size + alignment to make sure we can align afterwards */
@@ -102,12 +102,12 @@ void* winpr_aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
base = aligned_alloc(alignment, alignsize);
#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) || (_XOPEN_SOURCE >= 600)
if (posix_memalign(&base, alignment, alignsize) != 0)
- return NULL;
+ return nullptr;
#else
base = malloc(alignsize);
#endif
if (!base)
- return NULL;
+ return nullptr;
basesize = (uintptr_t)base;
@@ -115,7 +115,7 @@ void* winpr_aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
(basesize > UINTPTR_MAX - header - offset))
{
free(base);
- return NULL;
+ return nullptr;
}
memblock = (void*)(((basesize + header + offset) & ~(alignment - 1)) - offset);
@@ -129,9 +129,9 @@ void* winpr_aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
void* winpr_aligned_offset_realloc(void* memblock, size_t size, size_t alignment, size_t offset)
{
size_t copySize = 0;
- void* newMemblock = NULL;
- WINPR_ALIGNED_MEM* pMem = NULL;
- WINPR_ALIGNED_MEM* pNewMem = NULL;
+ void* newMemblock = nullptr;
+ WINPR_ALIGNED_MEM* pMem = nullptr;
+ WINPR_ALIGNED_MEM* pNewMem = nullptr;
if (!memblock)
return winpr_aligned_offset_malloc(size, alignment, offset);
@@ -142,19 +142,19 @@ void* winpr_aligned_offset_realloc(void* memblock, size_t size, size_t alignment
{
WLog_ERR(TAG,
"_aligned_offset_realloc: memory block was not allocated by _aligned_malloc!");
- return NULL;
+ return nullptr;
}
if (size == 0)
{
winpr_aligned_free(memblock);
- return NULL;
+ return nullptr;
}
newMemblock = winpr_aligned_offset_malloc(size, alignment, offset);
if (!newMemblock)
- return NULL;
+ return nullptr;
pNewMem = WINPR_ALIGNED_MEM_STRUCT_FROM_PTR(newMemblock);
copySize = (pNewMem->size < pMem->size) ? pNewMem->size : pMem->size;
@@ -173,9 +173,9 @@ static inline size_t cMIN(size_t a, size_t b)
void* winpr_aligned_offset_recalloc(void* memblock, size_t num, size_t size, size_t alignment,
size_t offset)
{
- char* newMemblock = NULL;
- WINPR_ALIGNED_MEM* pMem = NULL;
- WINPR_ALIGNED_MEM* pNewMem = NULL;
+ char* newMemblock = nullptr;
+ WINPR_ALIGNED_MEM* pMem = nullptr;
+ WINPR_ALIGNED_MEM* pNewMem = nullptr;
if (!memblock)
{
@@ -224,7 +224,7 @@ fail:
size_t winpr_aligned_msize(void* memblock, WINPR_ATTR_UNUSED size_t alignment,
WINPR_ATTR_UNUSED size_t offset)
{
- WINPR_ALIGNED_MEM* pMem = NULL;
+ WINPR_ALIGNED_MEM* pMem = nullptr;
if (!memblock)
return 0;
@@ -242,7 +242,7 @@ size_t winpr_aligned_msize(void* memblock, WINPR_ATTR_UNUSED size_t alignment,
void winpr_aligned_free(void* memblock)
{
- WINPR_ALIGNED_MEM* pMem = NULL;
+ WINPR_ALIGNED_MEM* pMem = nullptr;
if (!memblock)
return;
diff --git a/winpr/libwinpr/crt/conversion.c b/winpr/libwinpr/crt/conversion.c
index bab91dc89..839960bdc 100644
--- a/winpr/libwinpr/crt/conversion.c
+++ b/winpr/libwinpr/crt/conversion.c
@@ -28,7 +28,7 @@
errno_t _itoa_s(int value, char* buffer, size_t sizeInCharacters, WINPR_ATTR_UNUSED int radix)
{
- int length = sprintf_s(NULL, 0, "%d", value);
+ int length = sprintf_s(nullptr, 0, "%d", value);
if (length < 0)
return -1;
diff --git a/winpr/libwinpr/crt/string.c b/winpr/libwinpr/crt/string.c
index 8947ca384..91a611ad7 100644
--- a/winpr/libwinpr/crt/string.c
+++ b/winpr/libwinpr/crt/string.c
@@ -43,12 +43,12 @@ char* winpr_str_url_decode(const char* str, size_t len)
{
char* dst = strndup(str, len);
if (!dst)
- return NULL;
+ return nullptr;
if (!uriUnescapeInPlaceExA(dst, URI_FALSE, URI_BR_DONT_TOUCH))
{
free(dst);
- return NULL;
+ return nullptr;
}
return dst;
@@ -58,12 +58,12 @@ char* winpr_str_url_encode(const char* str, size_t len)
{
char* dst = calloc(len + 1, sizeof(char) * 3);
if (!dst)
- return NULL;
+ return nullptr;
if (!uriEscapeA(str, dst, URI_FALSE, URI_FALSE))
{
free(dst);
- return NULL;
+ return nullptr;
}
return dst;
}
@@ -114,7 +114,7 @@ char* winpr_str_url_decode(const char* str, size_t len)
{
char* dst = calloc(len + 1, sizeof(char));
if (!dst)
- return NULL;
+ return nullptr;
size_t pos = 0;
for (size_t x = 0; x < strnlen(str, len); x++)
@@ -141,7 +141,7 @@ char* winpr_str_url_encode(const char* str, size_t len)
{
char* dst = calloc(len + 1, sizeof(char) * 3);
if (!dst)
- return NULL;
+ return nullptr;
char* ptr = dst;
for (size_t x = 0; x < strnlen(str, len); x++)
@@ -186,11 +186,11 @@ int winpr_vasprintf(char** s, size_t* slen, WINPR_FORMAT_ARG const char* templ,
{
va_list ap = WINPR_C_ARRAY_INIT;
- *s = NULL;
+ *s = nullptr;
*slen = 0;
va_copy(ap, oap);
- const int length = vsnprintf(NULL, 0, templ, ap);
+ const int length = vsnprintf(nullptr, 0, templ, ap);
va_end(ap);
if (length < 0)
return length;
@@ -217,12 +217,12 @@ int winpr_vasprintf(char** s, size_t* slen, WINPR_FORMAT_ARG const char* templ,
char* _strdup(const char* strSource)
{
- if (strSource == NULL)
- return NULL;
+ if (strSource == nullptr)
+ return nullptr;
char* strDestination = strdup(strSource);
- if (strDestination == NULL)
+ if (strDestination == nullptr)
WLog_ERR(TAG, "strdup");
return strDestination;
@@ -231,15 +231,15 @@ char* _strdup(const char* strSource)
WCHAR* _wcsdup(const WCHAR* strSource)
{
if (!strSource)
- return NULL;
+ return nullptr;
size_t len = _wcslen(strSource);
WCHAR* strDestination = calloc(len + 1, sizeof(WCHAR));
- if (strDestination != NULL)
+ if (strDestination != nullptr)
memcpy(strDestination, strSource, len * sizeof(WCHAR));
- if (strDestination == NULL)
+ if (strDestination == nullptr)
WLog_ERR(TAG, "wcsdup");
return strDestination;
@@ -352,7 +352,7 @@ WCHAR* _wcsstr(const WCHAR* str, const WCHAR* strSearch)
return WINPR_CAST_CONST_PTR_AWAY(str, WCHAR*);
str++;
}
- return NULL;
+ return nullptr;
}
/* _wcschr -> wcschr */
@@ -369,7 +369,7 @@ WCHAR* _wcschr(const WCHAR* str, WCHAR c)
while (*p && (*p != c))
p++;
- cnv.cc = (*p == c) ? p : NULL;
+ cnv.cc = (*p == c) ? p : nullptr;
return cnv.c;
}
@@ -382,10 +382,10 @@ WCHAR* _wcsrchr(const WCHAR* str, WCHAR c)
const WCHAR* cc;
WCHAR* c;
} cnv;
- const WCHAR* p = NULL;
+ const WCHAR* p = nullptr;
if (!str)
- return NULL;
+ return nullptr;
for (; *str != '\0'; str++)
{
@@ -405,7 +405,7 @@ char* strtok_s(char* strToken, const char* strDelimit, char** context)
WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context)
{
- WCHAR* nextToken = NULL;
+ WCHAR* nextToken = nullptr;
WCHAR value = 0;
if (!strToken)
@@ -420,7 +420,7 @@ WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context)
}
if (!*strToken)
- return NULL;
+ return nullptr;
nextToken = strToken++;
value = *strToken;
@@ -453,12 +453,12 @@ LPSTR CharUpperA(LPSTR lpsz)
size_t length = 0;
if (!lpsz)
- return NULL;
+ return nullptr;
length = strlen(lpsz);
if (length < 1)
- return (LPSTR)NULL;
+ return (LPSTR) nullptr;
if (length == 1)
{
@@ -485,12 +485,12 @@ LPWSTR CharUpperW(LPWSTR lpsz)
size_t length = 0;
if (!lpsz)
- return NULL;
+ return nullptr;
length = _wcslen(lpsz);
if (length < 1)
- return (LPWSTR)NULL;
+ return (LPWSTR) nullptr;
if (length == 1)
{
@@ -543,12 +543,12 @@ LPSTR CharLowerA(LPSTR lpsz)
size_t length = 0;
if (!lpsz)
- return (LPSTR)NULL;
+ return (LPSTR) nullptr;
length = strlen(lpsz);
if (length < 1)
- return (LPSTR)NULL;
+ return (LPSTR) nullptr;
if (length == 1)
{
@@ -574,7 +574,7 @@ LPWSTR CharLowerW(LPWSTR lpsz)
{
const size_t len = _wcsnlen(lpsz, UINT32_MAX + 1);
if (len > UINT32_MAX)
- return NULL;
+ return nullptr;
CharLowerBuffW(lpsz, (UINT32)len);
return lpsz;
}
@@ -704,7 +704,7 @@ char* ConvertLineEndingToCRLF(const char* str, size_t* size)
*size = 0;
if (s == 0)
- return NULL;
+ return nullptr;
size_t linebreaks = 0;
for (size_t x = 0; x < s - 1; x++)
@@ -722,7 +722,7 @@ char* ConvertLineEndingToCRLF(const char* str, size_t* size)
}
char* cnv = calloc(s + linebreaks * 2ull + 1ull, sizeof(char));
if (!cnv)
- return NULL;
+ return nullptr;
size_t pos = 0;
for (size_t x = 0; x < s; x++)
@@ -754,11 +754,11 @@ char* ConvertLineEndingToCRLF(const char* str, size_t* size)
char* StrSep(char** stringp, const char* delim)
{
char* start = *stringp;
- char* p = NULL;
- p = (start != NULL) ? strpbrk(start, delim) : NULL;
+ char* p = nullptr;
+ p = (start != nullptr) ? strpbrk(start, delim) : nullptr;
if (!p)
- *stringp = NULL;
+ *stringp = nullptr;
else
{
*p = '\0';
@@ -833,11 +833,11 @@ const WCHAR* InitializeConstWCharFromUtf8(const char* str, WCHAR* buffer, size_t
WCHAR* wcsndup(const WCHAR* s, size_t n)
{
if (!s)
- return NULL;
+ return nullptr;
WCHAR* copy = calloc(n + 1, sizeof(WCHAR));
if (!copy)
- return NULL;
+ return nullptr;
memcpy(copy, s, n * sizeof(WCHAR));
return copy;
}
diff --git a/winpr/libwinpr/crt/test/TestAlignment.c b/winpr/libwinpr/crt/test/TestAlignment.c
index 07bac7f8d..456272ec4 100644
--- a/winpr/libwinpr/crt/test/TestAlignment.c
+++ b/winpr/libwinpr/crt/test/TestAlignment.c
@@ -5,7 +5,7 @@
int TestAlignment(int argc, char* argv[])
{
- void* ptr = NULL;
+ void* ptr = nullptr;
size_t alignment = 0;
size_t offset = 0;
@@ -21,7 +21,7 @@ int TestAlignment(int argc, char* argv[])
ptr = winpr_aligned_malloc(100, alignment);
- if (ptr == NULL)
+ if (ptr == nullptr)
{
printf("Error allocating aligned memory.\n");
return -1;
@@ -49,7 +49,7 @@ int TestAlignment(int argc, char* argv[])
ptr = winpr_aligned_offset_malloc(200, alignment, offset);
- if (ptr == NULL)
+ if (ptr == nullptr)
{
printf("Error reallocating aligned offset memory.");
return -1;
@@ -66,7 +66,7 @@ int TestAlignment(int argc, char* argv[])
ptr = winpr_aligned_offset_realloc(ptr, 200, alignment, offset);
- if (ptr == NULL)
+ if (ptr == nullptr)
{
printf("Error reallocating aligned offset memory.");
return -1;
diff --git a/winpr/libwinpr/crt/test/TestString.c b/winpr/libwinpr/crt/test/TestString.c
index b7a979300..0bac59557 100644
--- a/winpr/libwinpr/crt/test/TestString.c
+++ b/winpr/libwinpr/crt/test/TestString.c
@@ -85,7 +85,7 @@ static BOOL test_winpr_asprintf(void)
const char test[] = "test string case";
const size_t len = strnlen(test, sizeof(test));
- char* str = NULL;
+ char* str = nullptr;
size_t slen = 0;
const int res = winpr_asprintf(&str, &slen, "%s", test);
if (!str)
@@ -106,10 +106,10 @@ fail:
int TestString(int argc, char* argv[])
{
- const WCHAR* p = NULL;
+ const WCHAR* p = nullptr;
size_t pos = 0;
size_t length = 0;
- WCHAR* context = NULL;
+ WCHAR* context = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
@@ -163,9 +163,9 @@ int TestString(int argc, char* argv[])
p = _wcschr(&testStringW[pos + 1], search.w);
- if (p != NULL)
+ if (p != nullptr)
{
- printf("_wcschr error: return value mismatch: Actual: %p, Expected: NULL\n",
+ printf("_wcschr error: return value mismatch: Actual: %p, Expected: nullptr\n",
(const void*)p);
return -1;
}
@@ -188,7 +188,7 @@ int TestString(int argc, char* argv[])
return -1;
}
- p = wcstok_s(NULL, testDelimiterW, &context);
+ p = wcstok_s(nullptr, testDelimiterW, &context);
WCHAR testToken2W[ARRAYSIZE(testToken2A)] = WINPR_C_ARRAY_INIT;
(void)ConvertUtf8NToWChar(testToken2A, ARRAYSIZE(testToken2A), testToken2W,
@@ -199,7 +199,7 @@ int TestString(int argc, char* argv[])
return -1;
}
- p = wcstok_s(NULL, testDelimiterW, &context);
+ p = wcstok_s(nullptr, testDelimiterW, &context);
WCHAR testToken3W[ARRAYSIZE(testToken3A)] = WINPR_C_ARRAY_INIT;
(void)ConvertUtf8NToWChar(testToken3A, ARRAYSIZE(testToken3A), testToken3W,
@@ -210,11 +210,11 @@ int TestString(int argc, char* argv[])
return -1;
}
- p = wcstok_s(NULL, testDelimiterW, &context);
+ p = wcstok_s(nullptr, testDelimiterW, &context);
- if (p != NULL)
+ if (p != nullptr)
{
- printf("wcstok_s error: return value is not NULL\n");
+ printf("wcstok_s error: return value is not nullptr\n");
return -1;
}
diff --git a/winpr/libwinpr/crt/test/TestUnicodeConversion.c b/winpr/libwinpr/crt/test/TestUnicodeConversion.c
index bde4476eb..97e7572eb 100644
--- a/winpr/libwinpr/crt/test/TestUnicodeConversion.c
+++ b/winpr/libwinpr/crt/test/TestUnicodeConversion.c
@@ -189,14 +189,14 @@ static BOOL test_convert_to_utf16(const testcase_t* test)
test->utf16len - 1 };
const size_t max = test->utf16len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
- const SSIZE_T rc2 = ConvertUtf8ToWChar(test->utf8, NULL, 0);
+ const SSIZE_T rc2 = ConvertUtf8ToWChar(test->utf8, nullptr, 0);
const size_t wlen = _wcsnlen(test->utf16, test->utf16len);
if ((rc2 < 0) || ((size_t)rc2 != wlen))
{
char prefix[8192] = WINPR_C_ARRAY_INIT;
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __func__, __LINE__);
(void)fprintf(stderr,
- "%s ConvertUtf8ToWChar(%s, NULL, 0) expected %" PRIuz ", got %" PRIdz "\n",
+ "%s ConvertUtf8ToWChar(%s, nullptr, 0) expected %" PRIuz ", got %" PRIdz "\n",
prefix, test->utf8, wlen, rc2);
return FALSE;
}
@@ -217,7 +217,7 @@ static BOOL test_convert_to_utf16_n(const testcase_t* test)
test->utf16len - 1 };
const size_t max = test->utf16len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
- const SSIZE_T rc2 = ConvertUtf8NToWChar(test->utf8, test->utf8len, NULL, 0);
+ const SSIZE_T rc2 = ConvertUtf8NToWChar(test->utf8, test->utf8len, nullptr, 0);
const size_t wlen = _wcsnlen(test->utf16, test->utf16len);
if ((rc2 < 0) || ((size_t)rc2 != wlen))
{
@@ -225,7 +225,7 @@ static BOOL test_convert_to_utf16_n(const testcase_t* test)
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2,
WINPR_ASSERTING_INT_CAST(SSIZE_T, test->utf8len), test, __func__, __LINE__);
(void)fprintf(stderr,
- "%s ConvertUtf8NToWChar(%s, %" PRIuz ", NULL, 0) expected %" PRIuz
+ "%s ConvertUtf8NToWChar(%s, %" PRIuz ", nullptr, 0) expected %" PRIuz
", got %" PRIdz "\n",
prefix, test->utf8, test->utf8len, wlen, rc2);
return FALSE;
@@ -254,14 +254,14 @@ static BOOL test_convert_to_utf8(const testcase_t* test)
test->utf8len - 1 };
const size_t max = test->utf8len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
- const SSIZE_T rc2 = ConvertWCharToUtf8(test->utf16, NULL, 0);
+ const SSIZE_T rc2 = ConvertWCharToUtf8(test->utf16, nullptr, 0);
const size_t wlen = strnlen(test->utf8, test->utf8len);
if ((rc2 < 0) || ((size_t)rc2 != wlen))
{
char prefix[8192] = WINPR_C_ARRAY_INIT;
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __func__, __LINE__);
(void)fprintf(stderr,
- "%s ConvertWCharToUtf8(%s, NULL, 0) expected %" PRIuz ", got %" PRIdz "\n",
+ "%s ConvertWCharToUtf8(%s, nullptr, 0) expected %" PRIuz ", got %" PRIdz "\n",
prefix, test->utf8, wlen, rc2);
return FALSE;
}
@@ -283,7 +283,7 @@ static BOOL test_convert_to_utf8_n(const testcase_t* test)
test->utf8len - 1 };
const size_t max = test->utf8len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
- const SSIZE_T rc2 = ConvertWCharNToUtf8(test->utf16, test->utf16len, NULL, 0);
+ const SSIZE_T rc2 = ConvertWCharNToUtf8(test->utf16, test->utf16len, nullptr, 0);
const size_t wlen = strnlen(test->utf8, test->utf8len);
if ((rc2 < 0) || ((size_t)rc2 != wlen))
{
@@ -291,7 +291,7 @@ static BOOL test_convert_to_utf8_n(const testcase_t* test)
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2,
WINPR_ASSERTING_INT_CAST(SSIZE_T, test->utf16len), test, __func__, __LINE__);
(void)fprintf(stderr,
- "%s ConvertWCharNToUtf8(%s, %" PRIuz ", NULL, 0) expected %" PRIuz
+ "%s ConvertWCharNToUtf8(%s, %" PRIuz ", nullptr, 0) expected %" PRIuz
", got %" PRIdz "\n",
prefix, test->utf8, test->utf16len, wlen, rc2);
return FALSE;
@@ -483,14 +483,14 @@ static BOOL test_win_convert_to_utf16(const testcase_t* test)
test->utf16len - 1 };
const size_t max = test->utf16len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
- const int rc2 = MultiByteToWideChar(CP_UTF8, 0, test->utf8, -1, NULL, 0);
+ const int rc2 = MultiByteToWideChar(CP_UTF8, 0, test->utf8, -1, nullptr, 0);
const size_t wlen = _wcsnlen(test->utf16, test->utf16len);
if (rc2 != wlen + 1)
{
char prefix[8192] = WINPR_C_ARRAY_INIT;
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __func__, __LINE__);
(void)fprintf(stderr,
- "%s MultiByteToWideChar(CP_UTF8, 0, %s, [-1], NULL, 0) expected %" PRIuz
+ "%s MultiByteToWideChar(CP_UTF8, 0, %s, [-1], nullptr, 0) expected %" PRIuz
", got %d\n",
prefix, test->utf8, wlen + 1, rc2);
return FALSE;
@@ -513,7 +513,7 @@ static BOOL test_win_convert_to_utf16_n(const testcase_t* test)
const size_t max = test->utf16len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
BOOL isNullTerminated = strnlen(test->utf8, test->utf8len) < test->utf8len;
- const int rc2 = MultiByteToWideChar(CP_UTF8, 0, test->utf8, test->utf8len, NULL, 0);
+ const int rc2 = MultiByteToWideChar(CP_UTF8, 0, test->utf8, test->utf8len, nullptr, 0);
size_t wlen = _wcsnlen(test->utf16, test->utf16len);
if (isNullTerminated)
wlen++;
@@ -523,8 +523,8 @@ static BOOL test_win_convert_to_utf16_n(const testcase_t* test)
char prefix[8192] = WINPR_C_ARRAY_INIT;
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, test->utf8len, test, __func__, __LINE__);
(void)fprintf(stderr,
- "%s MultiByteToWideChar(CP_UTF8, 0, %s, %" PRIuz ", NULL, 0) expected %" PRIuz
- ", got %d\n",
+ "%s MultiByteToWideChar(CP_UTF8, 0, %s, %" PRIuz
+ ", nullptr, 0) expected %" PRIuz ", got %d\n",
prefix, test->utf8, test->utf8len, wlen, rc2);
return FALSE;
}
@@ -556,24 +556,23 @@ static BOOL test_win_convert_to_utf8(const testcase_t* test)
test->utf8len - 1 };
const size_t max = test->utf8len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
- const int rc2 = WideCharToMultiByte(CP_UTF8, 0, test->utf16, -1, NULL, 0, NULL, NULL);
+ const int rc2 = WideCharToMultiByte(CP_UTF8, 0, test->utf16, -1, nullptr, 0, nullptr, nullptr);
const size_t wlen = strnlen(test->utf8, test->utf8len) + 1;
if (rc2 != wlen)
{
char prefix[8192] = WINPR_C_ARRAY_INIT;
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __func__, __LINE__);
- (void)fprintf(
- stderr,
- "%s WideCharToMultiByte(CP_UTF8, 0, %s, -1, NULL, 0, NULL, NULL) expected %" PRIuz
- ", got %d\n",
- prefix, test->utf8, wlen, rc2);
+ (void)fprintf(stderr,
+ "%s WideCharToMultiByte(CP_UTF8, 0, %s, -1, nullptr, 0, nullptr, nullptr) "
+ "expected %" PRIuz ", got %d\n",
+ prefix, test->utf8, wlen, rc2);
return FALSE;
}
for (size_t x = 0; x < max; x++)
{
char buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
- int rc = WideCharToMultiByte(CP_UTF8, 0, test->utf16, -1, buffer, len[x], NULL, NULL);
+ int rc = WideCharToMultiByte(CP_UTF8, 0, test->utf16, -1, buffer, len[x], nullptr, nullptr);
if (!compare_win_utf8(buffer, len[x], rc, -1, test))
return FALSE;
}
@@ -589,7 +588,7 @@ static BOOL test_win_convert_to_utf8_n(const testcase_t* test)
const BOOL isNullTerminated = _wcsnlen(test->utf16, test->utf16len) < test->utf16len;
const int rc2 =
- WideCharToMultiByte(CP_UTF8, 0, test->utf16, test->utf16len, NULL, 0, NULL, NULL);
+ WideCharToMultiByte(CP_UTF8, 0, test->utf16, test->utf16len, nullptr, 0, nullptr, nullptr);
size_t wlen = strnlen(test->utf8, test->utf8len);
if (isNullTerminated)
wlen++;
@@ -600,7 +599,7 @@ static BOOL test_win_convert_to_utf8_n(const testcase_t* test)
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, test->utf16len, test, __func__, __LINE__);
(void)fprintf(stderr,
"%s WideCharToMultiByte(CP_UTF8, 0, %s, %" PRIuz
- ", NULL, 0, NULL, NULL) expected %" PRIuz ", got %d\n",
+ ", nullptr, 0, nullptr, nullptr) expected %" PRIuz ", got %d\n",
prefix, test->utf8, test->utf16len, wlen, rc2);
return FALSE;
}
@@ -617,7 +616,7 @@ static BOOL test_win_convert_to_utf8_n(const testcase_t* test)
char buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
memcpy(wbuffer, test->utf16, test->utf16len * sizeof(WCHAR));
const int rc =
- WideCharToMultiByte(CP_UTF8, 0, wbuffer, ilen[x], buffer, len[x], NULL, NULL);
+ WideCharToMultiByte(CP_UTF8, 0, wbuffer, ilen[x], buffer, len[x], nullptr, nullptr);
if (!compare_win_utf8(buffer, len[x], rc, ilen[x], test))
return FALSE;
}
@@ -762,10 +761,10 @@ static int convert_utf8_to_utf16(BYTE* lpMultiByteStr, BYTE* expected_lpWideChar
int length = 0;
size_t cbMultiByte = 0;
int cchWideChar = 0;
- LPWSTR lpWideCharStr = NULL;
+ LPWSTR lpWideCharStr = nullptr;
cbMultiByte = strlen((char*)lpMultiByteStr);
- cchWideChar = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)lpMultiByteStr, -1, NULL, 0);
+ cchWideChar = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)lpMultiByteStr, -1, nullptr, 0);
printf("MultiByteToWideChar Input UTF8 String:\n");
string_hexdump(lpMultiByteStr, cbMultiByte + 1);
@@ -842,10 +841,11 @@ static int convert_utf16_to_utf8(BYTE* lpWideCharStr, BYTE* expected_lpMultiByte
int length = 0;
int cchWideChar = 0;
int cbMultiByte = 0;
- LPSTR lpMultiByteStr = NULL;
+ LPSTR lpMultiByteStr = nullptr;
cchWideChar = _wcslen((WCHAR*)lpWideCharStr);
- cbMultiByte = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)lpWideCharStr, -1, NULL, 0, NULL, NULL);
+ cbMultiByte =
+ WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)lpWideCharStr, -1, nullptr, 0, nullptr, nullptr);
printf("WideCharToMultiByte Input UTF16 String:\n");
string_hexdump(lpWideCharStr, (cchWideChar + 1) * sizeof(WCHAR));
@@ -868,7 +868,7 @@ static int convert_utf16_to_utf8(BYTE* lpWideCharStr, BYTE* expected_lpMultiByte
lpMultiByteStr[cbMultiByte - 1] =
(CHAR)0xFF; /* should be overwritten if null terminator is inserted properly */
length = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)lpWideCharStr, cchWideChar + 1,
- lpMultiByteStr, cbMultiByte, NULL, NULL);
+ lpMultiByteStr, cbMultiByte, nullptr, nullptr);
printf("WideCharToMultiByte converted length (BYTE): %d\n", length);
@@ -917,9 +917,9 @@ fail:
#if defined(WITH_WINPR_DEPRECATED)
static BOOL test_unicode_uppercasing(BYTE* lower, BYTE* upper)
{
- WCHAR* lowerW = NULL;
+ WCHAR* lowerW = nullptr;
int lowerLength = 0;
- WCHAR* upperW = NULL;
+ WCHAR* upperW = nullptr;
int upperLength = 0;
lowerLength = ConvertToUnicode(CP_UTF8, 0, (LPSTR)lower, -1, &lowerW, 0);
@@ -957,7 +957,7 @@ static BOOL test_ConvertFromUnicode_wrapper(void)
/* 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 */
const CHAR cmp0[] = { 'R', 'I', 'C', 'H', ' ', 'T', 'E', 'X', 'T',
' ', 'F', 'O', 'R', 'M', 'A', 'T', 0 };
- CHAR* dst = NULL;
+ CHAR* dst = nullptr;
int i = 0;
/* Test unterminated unicode string:
@@ -967,16 +967,16 @@ static BOOL test_ConvertFromUnicode_wrapper(void)
printf("Input UTF16 String:\n");
string_hexdump((const BYTE*)src1, 19 * sizeof(WCHAR));
- i = ConvertFromUnicode(CP_UTF8, 0, (const WCHAR*)src1, 16, &dst, 0, NULL, NULL);
+ i = ConvertFromUnicode(CP_UTF8, 0, (const WCHAR*)src1, 16, &dst, 0, nullptr, nullptr);
if (i != 16)
{
(void)fprintf(stderr,
"ConvertFromUnicode failure A1: unexpectedly returned %d instead of 16\n", i);
goto fail;
}
- if (dst == NULL)
+ if (dst == nullptr)
{
- (void)fprintf(stderr, "ConvertFromUnicode failure A2: destination is NULL\n");
+ (void)fprintf(stderr, "ConvertFromUnicode failure A2: destination is nullptr\n");
goto fail;
}
if ((i = strlen(dst)) != 16)
@@ -993,23 +993,23 @@ static BOOL test_ConvertFromUnicode_wrapper(void)
string_hexdump((BYTE*)dst, i + 1);
free(dst);
- dst = NULL;
+ dst = nullptr;
/* Test null-terminated string */
printf("Input UTF16 String:\n");
string_hexdump((const BYTE*)src2, (_wcslen((const WCHAR*)src2) + 1) * sizeof(WCHAR));
- i = ConvertFromUnicode(CP_UTF8, 0, (const WCHAR*)src2, -1, &dst, 0, NULL, NULL);
+ i = ConvertFromUnicode(CP_UTF8, 0, (const WCHAR*)src2, -1, &dst, 0, nullptr, nullptr);
if (i != 17)
{
(void)fprintf(stderr,
"ConvertFromUnicode failure B1: unexpectedly returned %d instead of 17\n", i);
goto fail;
}
- if (dst == NULL)
+ if (dst == nullptr)
{
- (void)fprintf(stderr, "ConvertFromUnicode failure B2: destination is NULL\n");
+ (void)fprintf(stderr, "ConvertFromUnicode failure B2: destination is nullptr\n");
goto fail;
}
if ((i = strlen(dst)) != 16)
@@ -1026,7 +1026,7 @@ static BOOL test_ConvertFromUnicode_wrapper(void)
string_hexdump((BYTE*)dst, i + 1);
free(dst);
- dst = NULL;
+ dst = nullptr;
printf("success\n\n");
@@ -1046,7 +1046,7 @@ static BOOL test_ConvertToUnicode_wrapper(void)
' ', 'F', 'O', 'R', 'M', 'A', 'T', 0 };
const BYTE cmp0[] = "\x52\x00\x49\x00\x43\x00\x48\x00\x20\x00\x54\x00\x45\x00\x58\x00\x54\x00"
"\x20\x00\x46\x00\x4f\x00\x52\x00\x4d\x00\x41\x00\x54\x00\x00\x00";
- WCHAR* dst = NULL;
+ WCHAR* dst = nullptr;
int ii = 0;
size_t i = 0;
@@ -1056,7 +1056,7 @@ static BOOL test_ConvertToUnicode_wrapper(void)
const BYTE cmp[] = { 's', 0, 'o', 0, 'm', 0, 'e', 0, 't', 0, 'e', 0, 's', 0, 't', 0,
's', 0, 't', 0, 'r', 0, 'i', 0, 'n', 0, 'g', 0, 0, 0 };
WCHAR xname[128] = WINPR_C_ARRAY_INIT;
- LPWSTR aname = NULL;
+ LPWSTR aname = nullptr;
LPWSTR wname = &xname[0];
const size_t len = strnlen(name, ARRAYSIZE(name) - 1);
ii = ConvertToUnicode(CP_UTF8, 0, name, len, &wname, ARRAYSIZE(xname));
@@ -1090,9 +1090,9 @@ static BOOL test_ConvertToUnicode_wrapper(void)
goto fail;
}
i = (size_t)ii;
- if (dst == NULL)
+ if (dst == nullptr)
{
- (void)fprintf(stderr, "ConvertToUnicode failure A2: destination is NULL\n");
+ (void)fprintf(stderr, "ConvertToUnicode failure A2: destination is nullptr\n");
goto fail;
}
if ((i = _wcslen(dst)) != 16)
@@ -1110,7 +1110,7 @@ static BOOL test_ConvertToUnicode_wrapper(void)
string_hexdump((const BYTE*)dst, (i + 1) * sizeof(WCHAR));
free(dst);
- dst = NULL;
+ dst = nullptr;
/* Test null-terminated string */
@@ -1125,9 +1125,9 @@ static BOOL test_ConvertToUnicode_wrapper(void)
i);
goto fail;
}
- if (dst == NULL)
+ if (dst == nullptr)
{
- (void)fprintf(stderr, "ConvertToUnicode failure B2: destination is NULL\n");
+ (void)fprintf(stderr, "ConvertToUnicode failure B2: destination is nullptr\n");
goto fail;
}
if ((i = _wcslen(dst)) != 16)
@@ -1145,7 +1145,7 @@ static BOOL test_ConvertToUnicode_wrapper(void)
string_hexdump((BYTE*)dst, (i + 1) * 2);
free(dst);
- dst = NULL;
+ dst = nullptr;
printf("success\n\n");
@@ -1284,15 +1284,15 @@ int TestUnicodeConversion(int argc, char* argv[])
//BYTE src[] = { 'R',0,'I',0,'C',0,'H',0,' ',0, 0,0, 'T',0,'E',0,'X',0,'T',0,'
',0,'F',0,'O',0,'R',0,'M',0,'A',0,'T',0,'@',0,'@',0 };
//BYTE src[] = { 0,0,'R',0,'I',0,'C',0,'H',0,' ',0, 'T',0,'E',0,'X',0,'T',0,'
- ',0,'F',0,'O',0,'R',0,'M',0,'A',0,'T',0,'@',0,'@',0 }; char* dst = NULL; int num; num =
- ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) src, 16, &dst, 0, NULL, NULL);
+ ',0,'F',0,'O',0,'R',0,'M',0,'A',0,'T',0,'@',0,'@',0 }; char* dst = nullptr; int num; num =
+ ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) src, 16, &dst, 0, nullptr, nullptr);
printf("ConvertFromUnicode returned %d dst=[%s]\n", num, dst);
string_hexdump((BYTE*)dst, num+1);
}
if (1)
{
char src[] = "RICH TEXT FORMAT@@@@@@";
- WCHAR *dst = NULL;
+ WCHAR *dst = nullptr;
int num;
num = ConvertToUnicode(CP_UTF8, 0, src, 16, &dst, 0);
printf("ConvertToUnicode returned %d dst=%p\n", num, (void*) dst);
diff --git a/winpr/libwinpr/crt/unicode.c b/winpr/libwinpr/crt/unicode.c
index f674eb6e3..4850560d0 100644
--- a/winpr/libwinpr/crt/unicode.c
+++ b/winpr/libwinpr/crt/unicode.c
@@ -119,7 +119,7 @@
* cchWideChar *cannot* be assumed to be cbMultiByte since UTF-8 is variable-width!
*
* Instead, obtain the required cchWideChar output size like this:
- * cchWideChar = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR) lpMultiByteStr, -1, NULL, 0);
+ * cchWideChar = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR) lpMultiByteStr, -1, nullptr, 0);
*
* A value of -1 for cbMultiByte indicates that the input string is null-terminated,
* and the null terminator *will* be processed. The size returned by MultiByteToWideChar
@@ -171,7 +171,8 @@ static
* cbMultiByte *cannot* be assumed to be cchWideChar since UTF-8 is variable-width!
*
* Instead, obtain the required cbMultiByte output size like this:
- * cbMultiByte = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) lpWideCharStr, -1, NULL, 0, NULL, NULL);
+ * cbMultiByte = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) lpWideCharStr, -1, nullptr, 0, nullptr,
+ * nullptr);
*
* A value of -1 for cbMultiByte indicates that the input string is null-terminated,
* and the null terminator *will* be processed. The size returned by WideCharToMultiByte
@@ -188,7 +189,7 @@ static
* Finally, perform the conversion:
*
* cbMultiByte = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) lpWideCharStr, -1, lpMultiByteStr,
- * cbMultiByte, NULL, NULL);
+ * cbMultiByte, nullptr, nullptr);
*
* The value returned by WideCharToMultiByte corresponds to the number of bytes written
* to the output buffer, and should match the value obtained on the first call to
@@ -213,7 +214,7 @@ static
/**
* ConvertToUnicode is a convenience wrapper for MultiByteToWideChar:
*
- * If the lpWideCharStr parameter for the converted string points to NULL
+ * If the lpWideCharStr parameter for the converted string points to nullptr
* or if the cchWideChar parameter is set to 0 this function will automatically
* allocate the required memory which is guaranteed to be null-terminated
* after the conversion, even if the source c string isn't.
@@ -245,7 +246,8 @@ int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cb
if (cchWideChar == 0)
{
- cchWideChar = MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
+ cchWideChar =
+ MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, nullptr, 0);
allocate = TRUE;
}
else if (!(*lpWideCharStr))
@@ -273,7 +275,7 @@ int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cb
if (allocate)
{
free(*lpWideCharStr);
- *lpWideCharStr = NULL;
+ *lpWideCharStr = nullptr;
status = 0;
}
}
@@ -285,7 +287,7 @@ int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cb
/**
* ConvertFromUnicode is a convenience wrapper for WideCharToMultiByte:
*
- * If the lpMultiByteStr parameter for the converted string points to NULL
+ * If the lpMultiByteStr parameter for the converted string points to nullptr
* or if the cbMultiByte parameter is set to 0 this function will automatically
* allocate the required memory which is guaranteed to be null-terminated
* after the conversion, even if the source unicode string isn't.
@@ -313,8 +315,8 @@ int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int
if (cbMultiByte == 0)
{
- cbMultiByte =
- WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, NULL, NULL);
+ cbMultiByte = WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, nullptr, 0,
+ nullptr, nullptr);
allocate = TRUE;
}
else if (!(*lpMultiByteStr))
@@ -345,7 +347,7 @@ int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int
if ((status <= 0) && allocate)
{
free(*lpMultiByteStr);
- *lpMultiByteStr = NULL;
+ *lpMultiByteStr = nullptr;
}
return status;
@@ -398,7 +400,8 @@ SSIZE_T ConvertWCharNToUtf8(const WCHAR* wstr, size_t wlen, char* str, size_t le
isNullTerminated = TRUE;
iwlen++;
}
- const int rc = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)iwlen, str, (int)len, NULL, NULL);
+ const int rc =
+ WideCharToMultiByte(CP_UTF8, 0, wstr, (int)iwlen, str, (int)len, nullptr, nullptr);
if ((rc <= 0) || ((len > 0) && ((size_t)rc > len)))
return -1;
else if (!isNullTerminated)
@@ -429,7 +432,7 @@ SSIZE_T ConvertMszWCharNToUtf8(const WCHAR* wstr, size_t wlen, char* str, size_t
}
const int iwlen = (int)len;
- const int rc = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)wlen, str, iwlen, NULL, NULL);
+ const int rc = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)wlen, str, iwlen, nullptr, nullptr);
if ((rc <= 0) || ((len > 0) && (rc > iwlen)))
return -1;
@@ -510,20 +513,20 @@ SSIZE_T ConvertMszUtf8NToWChar(const char* str, size_t len, WCHAR* wstr, size_t
char* ConvertWCharToUtf8Alloc(const WCHAR* wstr, size_t* pUtfCharLength)
{
- char* tmp = NULL;
- const SSIZE_T rc = ConvertWCharToUtf8(wstr, NULL, 0);
+ char* tmp = nullptr;
+ const SSIZE_T rc = ConvertWCharToUtf8(wstr, nullptr, 0);
if (pUtfCharLength)
*pUtfCharLength = 0;
if (rc < 0)
- return NULL;
+ return nullptr;
tmp = calloc((size_t)rc + 1ull, sizeof(char));
if (!tmp)
- return NULL;
+ return nullptr;
const SSIZE_T rc2 = ConvertWCharToUtf8(wstr, tmp, (size_t)rc + 1ull);
if (rc2 < 0)
{
free(tmp);
- return NULL;
+ return nullptr;
}
WINPR_ASSERT(rc == rc2);
if (pUtfCharLength)
@@ -533,21 +536,21 @@ char* ConvertWCharToUtf8Alloc(const WCHAR* wstr, size_t* pUtfCharLength)
char* ConvertWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen, size_t* pUtfCharLength)
{
- char* tmp = NULL;
- const SSIZE_T rc = ConvertWCharNToUtf8(wstr, wlen, NULL, 0);
+ char* tmp = nullptr;
+ const SSIZE_T rc = ConvertWCharNToUtf8(wstr, wlen, nullptr, 0);
if (pUtfCharLength)
*pUtfCharLength = 0;
if (rc < 0)
- return NULL;
+ return nullptr;
tmp = calloc((size_t)rc + 1ull, sizeof(char));
if (!tmp)
- return NULL;
+ return nullptr;
const SSIZE_T rc2 = ConvertWCharNToUtf8(wstr, wlen, tmp, (size_t)rc + 1ull);
if (rc2 < 0)
{
free(tmp);
- return NULL;
+ return nullptr;
}
WINPR_ASSERT(rc == rc2);
if (pUtfCharLength)
@@ -557,21 +560,21 @@ char* ConvertWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen, size_t* pUtfCharL
char* ConvertMszWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen, size_t* pUtfCharLength)
{
- char* tmp = NULL;
- const SSIZE_T rc = ConvertMszWCharNToUtf8(wstr, wlen, NULL, 0);
+ char* tmp = nullptr;
+ const SSIZE_T rc = ConvertMszWCharNToUtf8(wstr, wlen, nullptr, 0);
if (pUtfCharLength)
*pUtfCharLength = 0;
if (rc < 0)
- return NULL;
+ return nullptr;
tmp = calloc((size_t)rc + 1ull, sizeof(char));
if (!tmp)
- return NULL;
+ return nullptr;
const SSIZE_T rc2 = ConvertMszWCharNToUtf8(wstr, wlen, tmp, (size_t)rc + 1ull);
if (rc2 < 0)
{
free(tmp);
- return NULL;
+ return nullptr;
}
WINPR_ASSERT(rc == rc2);
if (pUtfCharLength)
@@ -581,20 +584,20 @@ char* ConvertMszWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen, size_t* pUtfCh
WCHAR* ConvertUtf8ToWCharAlloc(const char* str, size_t* pSize)
{
- WCHAR* tmp = NULL;
- const SSIZE_T rc = ConvertUtf8ToWChar(str, NULL, 0);
+ WCHAR* tmp = nullptr;
+ const SSIZE_T rc = ConvertUtf8ToWChar(str, nullptr, 0);
if (pSize)
*pSize = 0;
if (rc < 0)
- return NULL;
+ return nullptr;
tmp = calloc((size_t)rc + 1ull, sizeof(WCHAR));
if (!tmp)
- return NULL;
+ return nullptr;
const SSIZE_T rc2 = ConvertUtf8ToWChar(str, tmp, (size_t)rc + 1ull);
if (rc2 < 0)
{
free(tmp);
- return NULL;
+ return nullptr;
}
WINPR_ASSERT(rc == rc2);
if (pSize)
@@ -604,20 +607,20 @@ WCHAR* ConvertUtf8ToWCharAlloc(const char* str, size_t* pSize)
WCHAR* ConvertUtf8NToWCharAlloc(const char* str, size_t len, size_t* pSize)
{
- WCHAR* tmp = NULL;
- const SSIZE_T rc = ConvertUtf8NToWChar(str, len, NULL, 0);
+ WCHAR* tmp = nullptr;
+ const SSIZE_T rc = ConvertUtf8NToWChar(str, len, nullptr, 0);
if (pSize)
*pSize = 0;
if (rc < 0)
- return NULL;
+ return nullptr;
tmp = calloc((size_t)rc + 1ull, sizeof(WCHAR));
if (!tmp)
- return NULL;
+ return nullptr;
const SSIZE_T rc2 = ConvertUtf8NToWChar(str, len, tmp, (size_t)rc + 1ull);
if (rc2 < 0)
{
free(tmp);
- return NULL;
+ return nullptr;
}
WINPR_ASSERT(rc == rc2);
if (pSize)
@@ -627,20 +630,20 @@ WCHAR* ConvertUtf8NToWCharAlloc(const char* str, size_t len, size_t* pSize)
WCHAR* ConvertMszUtf8NToWCharAlloc(const char* str, size_t len, size_t* pSize)
{
- WCHAR* tmp = NULL;
- const SSIZE_T rc = ConvertMszUtf8NToWChar(str, len, NULL, 0);
+ WCHAR* tmp = nullptr;
+ const SSIZE_T rc = ConvertMszUtf8NToWChar(str, len, nullptr, 0);
if (pSize)
*pSize = 0;
if (rc < 0)
- return NULL;
+ return nullptr;
tmp = calloc((size_t)rc + 1ull, sizeof(WCHAR));
if (!tmp)
- return NULL;
+ return nullptr;
const SSIZE_T rc2 = ConvertMszUtf8NToWChar(str, len, tmp, (size_t)rc + 1ull);
if (rc2 < 0)
{
free(tmp);
- return NULL;
+ return nullptr;
}
WINPR_ASSERT(rc == rc2);
if (pSize)
diff --git a/winpr/libwinpr/crt/unicode_android.c b/winpr/libwinpr/crt/unicode_android.c
index 9fa16f6d4..1ce123020 100644
--- a/winpr/libwinpr/crt/unicode_android.c
+++ b/winpr/libwinpr/crt/unicode_android.c
@@ -103,7 +103,7 @@ static int convert_int(JNIEnv* env, const void* data, size_t size, void* buffer,
static int convert(const void* data, size_t size, void* buffer, size_t buffersize, BOOL toUTF16)
{
int rc;
- JNIEnv* env = NULL;
+ JNIEnv* env = nullptr;
jboolean attached = winpr_jni_attach_thread(&env);
rc = convert_int(env, data, size, buffer, buffersize, toUTF16);
if (attached)
diff --git a/winpr/libwinpr/crt/unicode_builtin.c b/winpr/libwinpr/crt/unicode_builtin.c
index bbb65f427..1461df47b 100644
--- a/winpr/libwinpr/crt/unicode_builtin.c
+++ b/winpr/libwinpr/crt/unicode_builtin.c
@@ -568,10 +568,10 @@ static ConversionResult winpr_ConvertUTF8toUTF16_Internal(const uint8_t** source
static int winpr_ConvertUTF8toUTF16(const uint8_t* src, int cchSrc, uint16_t* dst, int cchDst)
{
size_t length = 0;
- uint16_t* dstBeg = NULL;
- uint16_t* dstEnd = NULL;
- const uint8_t* srcBeg = NULL;
- const uint8_t* srcEnd = NULL;
+ uint16_t* dstBeg = nullptr;
+ uint16_t* dstEnd = nullptr;
+ const uint8_t* srcBeg = nullptr;
+ const uint8_t* srcEnd = nullptr;
ConversionResult result = sourceIllegal;
if (cchSrc == -1)
@@ -585,7 +585,7 @@ static int winpr_ConvertUTF8toUTF16(const uint8_t* src, int cchSrc, uint16_t* ds
result =
winpr_ConvertUTF8toUTF16_Internal(&srcBeg, srcEnd, &dstBeg, dstEnd, strictConversion);
- length = dstBeg - (uint16_t*)NULL;
+ length = dstBeg - (uint16_t*)nullptr;
}
else
{
@@ -610,10 +610,10 @@ static int winpr_ConvertUTF8toUTF16(const uint8_t* src, int cchSrc, uint16_t* ds
static int winpr_ConvertUTF16toUTF8(const uint16_t* src, int cchSrc, uint8_t* dst, int cchDst)
{
size_t length = 0;
- uint8_t* dstBeg = NULL;
- uint8_t* dstEnd = NULL;
- const uint16_t* srcBeg = NULL;
- const uint16_t* srcEnd = NULL;
+ uint8_t* dstBeg = nullptr;
+ uint8_t* dstEnd = nullptr;
+ const uint16_t* srcBeg = nullptr;
+ const uint16_t* srcEnd = nullptr;
ConversionResult result = sourceIllegal;
if (cchSrc == -1)
@@ -627,7 +627,7 @@ static int winpr_ConvertUTF16toUTF8(const uint16_t* src, int cchSrc, uint8_t* ds
result =
winpr_ConvertUTF16toUTF8_Internal(&srcBeg, srcEnd, &dstBeg, dstEnd, strictConversion);
- length = dstBeg - ((uint8_t*)NULL);
+ length = dstBeg - ((uint8_t*)nullptr);
}
else
{
diff --git a/winpr/libwinpr/crypto/cert.c b/winpr/libwinpr/crypto/cert.c
index c485b4967..71de52dcc 100644
--- a/winpr/libwinpr/crypto/cert.c
+++ b/winpr/libwinpr/crypto/cert.c
@@ -160,7 +160,7 @@ HCERTSTORE CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingTyp
WINPR_ATTR_UNUSED HCRYPTPROV_LEGACY hCryptProv,
WINPR_ATTR_UNUSED DWORD dwFlags, WINPR_ATTR_UNUSED const void* pvPara)
{
- WINPR_CERTSTORE* certstore = NULL;
+ WINPR_CERTSTORE* certstore = nullptr;
certstore = (WINPR_CERTSTORE*)calloc(1, sizeof(WINPR_CERTSTORE));
@@ -176,9 +176,9 @@ HCERTSTORE CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingTyp
HCERTSTORE CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv,
WINPR_ATTR_UNUSED LPCWSTR szSubsystemProtocol)
{
- HCERTSTORE hCertStore = NULL;
+ HCERTSTORE hCertStore = nullptr;
- hCertStore = CertOpenStore(CERT_STORE_PROV_FILE, X509_ASN_ENCODING, hProv, 0, NULL);
+ hCertStore = CertOpenStore(CERT_STORE_PROV_FILE, X509_ASN_ENCODING, hProv, 0, nullptr);
return hCertStore;
}
@@ -186,12 +186,12 @@ HCERTSTORE CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv,
HCERTSTORE CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv,
WINPR_ATTR_UNUSED LPCSTR szSubsystemProtocol)
{
- return CertOpenSystemStoreW(hProv, NULL);
+ return CertOpenSystemStoreW(hProv, nullptr);
}
BOOL CertCloseStore(HCERTSTORE hCertStore, WINPR_ATTR_UNUSED DWORD dwFlags)
{
- WINPR_CERTSTORE* certstore = NULL;
+ WINPR_CERTSTORE* certstore = nullptr;
certstore = (WINPR_CERTSTORE*)hCertStore;
@@ -215,7 +215,7 @@ PCCERT_CONTEXT CertEnumCertificatesInStore(WINPR_ATTR_UNUSED HCERTSTORE hCertSto
WINPR_ATTR_UNUSED PCCERT_CONTEXT pPrevCertContext)
{
WLog_ERR("TODO", "TODO: Implement");
- return (PCCERT_CONTEXT)NULL;
+ return (PCCERT_CONTEXT) nullptr;
}
DWORD CertGetNameStringW(WINPR_ATTR_UNUSED PCCERT_CONTEXT pCertContext,
diff --git a/winpr/libwinpr/crypto/cipher.c b/winpr/libwinpr/crypto/cipher.c
index f6113abb0..9cc0974ec 100644
--- a/winpr/libwinpr/crypto/cipher.c
+++ b/winpr/libwinpr/crypto/cipher.c
@@ -78,11 +78,11 @@ struct winpr_rc4_ctx_private_st
static WINPR_RC4_CTX* winpr_RC4_New_Internal(const BYTE* key, size_t keylen, BOOL override_fips)
{
if (!key || (keylen == 0))
- return NULL;
+ return nullptr;
WINPR_RC4_CTX* ctx = (WINPR_RC4_CTX*)calloc(1, sizeof(WINPR_RC4_CTX));
if (!ctx)
- return NULL;
+ return nullptr;
#if defined(WITH_INTERNAL_RC4)
WINPR_UNUSED(override_fips);
@@ -90,7 +90,7 @@ static WINPR_RC4_CTX* winpr_RC4_New_Internal(const BYTE* key, size_t keylen, BOO
if (!ctx->ictx)
goto fail;
#elif defined(WITH_OPENSSL)
- const EVP_CIPHER* evp = NULL;
+ const EVP_CIPHER* evp = nullptr;
if (keylen > INT_MAX)
goto fail;
@@ -105,7 +105,7 @@ static WINPR_RC4_CTX* winpr_RC4_New_Internal(const BYTE* key, size_t keylen, BOO
goto fail;
EVP_CIPHER_CTX_reset(ctx->ctx);
- if (EVP_EncryptInit_ex(ctx->ctx, evp, NULL, NULL, NULL) != 1)
+ if (EVP_EncryptInit_ex(ctx->ctx, evp, nullptr, nullptr, nullptr) != 1)
goto fail;
/* EVP_CIPH_FLAG_NON_FIPS_ALLOW does not exist before openssl 1.0.1 */
@@ -116,7 +116,7 @@ static WINPR_RC4_CTX* winpr_RC4_New_Internal(const BYTE* key, size_t keylen, BOO
#endif
EVP_CIPHER_CTX_set_key_length(ctx->ctx, (int)keylen);
- if (EVP_EncryptInit_ex(ctx->ctx, NULL, NULL, key, NULL) != 1)
+ if (EVP_EncryptInit_ex(ctx->ctx, nullptr, nullptr, key, nullptr) != 1)
goto fail;
#endif
return ctx;
@@ -127,7 +127,7 @@ fail:
winpr_RC4_Free(ctx);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
WINPR_RC4_CTX* winpr_RC4_New_Allow_FIPS(const void* key, size_t keylen)
@@ -280,7 +280,7 @@ WINPR_CIPHER_TYPE winpr_cipher_type_from_string(const char* name)
#if defined(WITH_OPENSSL)
static const EVP_CIPHER* winpr_openssl_get_evp_cipher(WINPR_CIPHER_TYPE cipher)
{
- const EVP_CIPHER* evp = NULL;
+ const EVP_CIPHER* evp = nullptr;
switch (cipher)
{
@@ -590,12 +590,12 @@ WINPR_API WINPR_CIPHER_CTX* winpr_Cipher_NewEx(WINPR_CIPHER_TYPE cipher, WINPR_C
{
WLog_ERR(TAG,
"WINPR_CIPHER_ARC4_128 (RC4) cipher not supported, use winpr_RC4_new instead");
- return NULL;
+ return nullptr;
}
WINPR_CIPHER_CTX* ctx = calloc(1, sizeof(WINPR_CIPHER_CTX));
if (!ctx)
- return NULL;
+ return nullptr;
ctx->cipher = cipher;
ctx->op = op;
@@ -611,7 +611,7 @@ WINPR_API WINPR_CIPHER_CTX* winpr_Cipher_NewEx(WINPR_CIPHER_TYPE cipher, WINPR_C
{
const int operation = (op == WINPR_ENCRYPT) ? 1 : 0;
- if (EVP_CipherInit_ex(ctx->ectx, evp, NULL, key, iv, operation) != 1)
+ if (EVP_CipherInit_ex(ctx->ectx, evp, nullptr, key, iv, operation) != 1)
goto fail;
}
@@ -647,7 +647,7 @@ WINPR_API WINPR_CIPHER_CTX* winpr_Cipher_NewEx(WINPR_CIPHER_TYPE cipher, WINPR_C
fail:
winpr_Cipher_Free(ctx);
- return NULL;
+ return nullptr;
}
BOOL winpr_Cipher_SetPadding(WINPR_CIPHER_CTX* ctx, BOOL enabled)
@@ -757,8 +757,8 @@ int winpr_Cipher_BytesToKey(int cipher, WINPR_MD_TYPE md, const void* salt, cons
* https://www.openssl.org/docs/manmaster/crypto/EVP_BytesToKey.html
*/
#if defined(WITH_OPENSSL)
- const EVP_MD* evp_md = NULL;
- const EVP_CIPHER* evp_cipher = NULL;
+ const EVP_MD* evp_md = nullptr;
+ const EVP_CIPHER* evp_cipher = nullptr;
evp_md = winpr_openssl_get_evp_md(md);
evp_cipher = winpr_openssl_get_evp_cipher(WINPR_ASSERTING_INT_CAST(WINPR_CIPHER_TYPE, cipher));
WINPR_ASSERT(datal <= INT_MAX);
diff --git a/winpr/libwinpr/crypto/crypto.c b/winpr/libwinpr/crypto/crypto.c
index d6210bc8e..9205ddedb 100644
--- a/winpr/libwinpr/crypto/crypto.c
+++ b/winpr/libwinpr/crypto/crypto.c
@@ -141,16 +141,16 @@
#include
#include
-static wListDictionary* g_ProtectedMemoryBlocks = NULL;
+static wListDictionary* g_ProtectedMemoryBlocks = nullptr;
BOOL CryptProtectMemory(LPVOID pData, DWORD cbData, DWORD dwFlags)
{
- BYTE* pCipherText = NULL;
+ BYTE* pCipherText = nullptr;
size_t cbOut = 0;
size_t cbFinal = 0;
- WINPR_CIPHER_CTX* enc = NULL;
+ WINPR_CIPHER_CTX* enc = nullptr;
BYTE randomKey[256] = WINPR_C_ARRAY_INIT;
- WINPR_PROTECTED_MEMORY_BLOCK* pMemBlock = NULL;
+ WINPR_PROTECTED_MEMORY_BLOCK* pMemBlock = nullptr;
if (dwFlags != CRYPTPROTECTMEMORY_SAME_PROCESS)
return FALSE;
@@ -188,7 +188,7 @@ BOOL CryptProtectMemory(LPVOID pData, DWORD cbData, DWORD dwFlags)
if ((enc = winpr_Cipher_NewEx(WINPR_CIPHER_AES_256_CBC, WINPR_ENCRYPT, pMemBlock->key,
sizeof(pMemBlock->key), pMemBlock->iv, sizeof(pMemBlock->iv))) ==
- NULL)
+ nullptr)
goto out;
if (!winpr_Cipher_Update(enc, pMemBlock->pData, pMemBlock->cbData, pCipherText, &cbOut))
goto out;
@@ -210,11 +210,11 @@ out:
BOOL CryptUnprotectMemory(LPVOID pData, WINPR_ATTR_UNUSED DWORD cbData, DWORD dwFlags)
{
- BYTE* pPlainText = NULL;
+ BYTE* pPlainText = nullptr;
size_t cbOut = 0;
size_t cbFinal = 0;
- WINPR_CIPHER_CTX* dec = NULL;
- WINPR_PROTECTED_MEMORY_BLOCK* pMemBlock = NULL;
+ WINPR_CIPHER_CTX* dec = nullptr;
+ WINPR_PROTECTED_MEMORY_BLOCK* pMemBlock = nullptr;
if (dwFlags != CRYPTPROTECTMEMORY_SAME_PROCESS)
return FALSE;
@@ -237,7 +237,7 @@ BOOL CryptUnprotectMemory(LPVOID pData, WINPR_ATTR_UNUSED DWORD cbData, DWORD dw
if ((dec = winpr_Cipher_NewEx(WINPR_CIPHER_AES_256_CBC, WINPR_DECRYPT, pMemBlock->key,
sizeof(pMemBlock->key), pMemBlock->iv, sizeof(pMemBlock->iv))) ==
- NULL)
+ nullptr)
goto out;
if (!winpr_Cipher_Update(dec, pMemBlock->pData, pMemBlock->cbData, pPlainText, &cbOut))
goto out;
diff --git a/winpr/libwinpr/crypto/hash.c b/winpr/libwinpr/crypto/hash.c
index 4c11d740e..5ead3b9c6 100644
--- a/winpr/libwinpr/crypto/hash.c
+++ b/winpr/libwinpr/crypto/hash.c
@@ -69,7 +69,7 @@ const EVP_MD* winpr_openssl_get_evp_md(WINPR_MD_TYPE md)
{
const char* name = winpr_md_type_to_string(md);
if (!name)
- return NULL;
+ return nullptr;
return EVP_get_digestbyname(name);
}
#endif
@@ -115,21 +115,16 @@ struct hash_map
const char* name;
WINPR_MD_TYPE md;
};
-static const struct hash_map hashes[] = { { "md2", WINPR_MD_MD2 },
- { "md4", WINPR_MD_MD4 },
- { "md5", WINPR_MD_MD5 },
- { "sha1", WINPR_MD_SHA1 },
- { "sha224", WINPR_MD_SHA224 },
- { "sha256", WINPR_MD_SHA256 },
- { "sha384", WINPR_MD_SHA384 },
- { "sha512", WINPR_MD_SHA512 },
- { "sha3_224", WINPR_MD_SHA3_224 },
- { "sha3_256", WINPR_MD_SHA3_256 },
- { "sha3_384", WINPR_MD_SHA3_384 },
- { "sha3_512", WINPR_MD_SHA3_512 },
- { "shake128", WINPR_MD_SHAKE128 },
- { "shake256", WINPR_MD_SHAKE256 },
- { NULL, WINPR_MD_NONE } };
+static const struct hash_map hashes[] = {
+ { "md2", WINPR_MD_MD2 }, { "md4", WINPR_MD_MD4 },
+ { "md5", WINPR_MD_MD5 }, { "sha1", WINPR_MD_SHA1 },
+ { "sha224", WINPR_MD_SHA224 }, { "sha256", WINPR_MD_SHA256 },
+ { "sha384", WINPR_MD_SHA384 }, { "sha512", WINPR_MD_SHA512 },
+ { "sha3_224", WINPR_MD_SHA3_224 }, { "sha3_256", WINPR_MD_SHA3_256 },
+ { "sha3_384", WINPR_MD_SHA3_384 }, { "sha3_512", WINPR_MD_SHA3_512 },
+ { "shake128", WINPR_MD_SHAKE128 }, { "shake256", WINPR_MD_SHAKE256 },
+ { nullptr, WINPR_MD_NONE }
+};
WINPR_MD_TYPE winpr_md_type_from_string(const char* name)
{
@@ -152,7 +147,7 @@ const char* winpr_md_type_to_string(WINPR_MD_TYPE md)
return cur->name;
cur++;
}
- return NULL;
+ return nullptr;
}
struct winpr_hmac_ctx_private_st
@@ -178,7 +173,7 @@ WINPR_HMAC_CTX* winpr_HMAC_New(void)
{
WINPR_HMAC_CTX* ctx = (WINPR_HMAC_CTX*)calloc(1, sizeof(WINPR_HMAC_CTX));
if (!ctx)
- return NULL;
+ return nullptr;
#if defined(WITH_OPENSSL)
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
@@ -191,7 +186,7 @@ WINPR_HMAC_CTX* winpr_HMAC_New(void)
if (!(ctx->hmac = HMAC_CTX_new()))
goto fail;
#else
- EVP_MAC* emac = EVP_MAC_fetch(NULL, "HMAC", NULL);
+ EVP_MAC* emac = EVP_MAC_fetch(nullptr, "HMAC", nullptr);
if (!emac)
goto fail;
ctx->xhmac = EVP_MAC_CTX_new(emac);
@@ -209,7 +204,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
winpr_HMAC_Free(ctx);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
BOOL winpr_HMAC_Init(WINPR_HMAC_CTX* ctx, WINPR_MD_TYPE md, const void* key, size_t keylen)
@@ -251,11 +246,11 @@ BOOL winpr_HMAC_Init(WINPR_HMAC_CTX* ctx, WINPR_MD_TYPE md, const void* key, siz
return FALSE;
#if (OPENSSL_VERSION_NUMBER < 0x10000000L) || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
- HMAC_Init_ex(hmac, key, (int)keylen, evp, NULL); /* no return value on OpenSSL 0.9.x */
+ HMAC_Init_ex(hmac, key, (int)keylen, evp, nullptr); /* no return value on OpenSSL 0.9.x */
return TRUE;
#else
- if (HMAC_Init_ex(hmac, key, (int)keylen, evp, NULL) == 1)
+ if (HMAC_Init_ex(hmac, key, (int)keylen, evp, nullptr) == 1)
return TRUE;
#endif
@@ -342,17 +337,17 @@ BOOL winpr_HMAC_Final(WINPR_HMAC_CTX* ctx, void* output, size_t olen)
#if defined(WITH_OPENSSL)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
- const int rc = EVP_MAC_final(ctx->xhmac, output, NULL, olen);
+ const int rc = EVP_MAC_final(ctx->xhmac, output, nullptr, olen);
return (rc == 1);
#else
HMAC_CTX* hmac = ctx->hmac;
#if (OPENSSL_VERSION_NUMBER < 0x10000000L) || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
- HMAC_Final(hmac, output, NULL); /* no return value on OpenSSL 0.9.x */
+ HMAC_Final(hmac, output, nullptr); /* no return value on OpenSSL 0.9.x */
return TRUE;
#else
- if (HMAC_Final(hmac, output, NULL) == 1)
+ if (HMAC_Final(hmac, output, nullptr) == 1)
return TRUE;
#endif
@@ -450,7 +445,7 @@ WINPR_DIGEST_CTX* winpr_Digest_New(void)
{
WINPR_DIGEST_CTX* ctx = calloc(1, sizeof(WINPR_DIGEST_CTX));
if (!ctx)
- return NULL;
+ return nullptr;
#if defined(WITH_OPENSSL)
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
@@ -477,7 +472,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
winpr_Digest_Free(ctx);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
#if defined(WITH_OPENSSL)
@@ -489,7 +484,7 @@ static BOOL winpr_Digest_Init_Internal(WINPR_DIGEST_CTX* ctx, const EVP_MD* evp)
if (!mdctx || !evp)
return FALSE;
- if (EVP_DigestInit_ex(mdctx, evp, NULL) != 1)
+ if (EVP_DigestInit_ex(mdctx, evp, nullptr) != 1)
{
WLog_ERR(TAG, "Failed to initialize digest %s", winpr_md_type_to_string(ctx->md));
return FALSE;
@@ -541,7 +536,7 @@ BOOL winpr_Digest_Init_Allow_FIPS(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE md)
#if !defined(WITH_INTERNAL_MD5)
if (md == WINPR_MD_MD5)
{
- EVP_MD* md5 = EVP_MD_fetch(NULL, "MD5", "fips=no");
+ EVP_MD* md5 = EVP_MD_fetch(nullptr, "MD5", "fips=no");
BOOL rc = winpr_Digest_Init_Internal(ctx, md5);
EVP_MD_free(md5);
return rc;
@@ -653,7 +648,7 @@ BOOL winpr_Digest_Final(WINPR_DIGEST_CTX* ctx, void* output, WINPR_ATTR_UNUSED s
#if defined(WITH_OPENSSL)
EVP_MD_CTX* mdctx = ctx->mdctx;
- return EVP_DigestFinal_ex(mdctx, output, NULL) == 1;
+ return EVP_DigestFinal_ex(mdctx, output, nullptr) == 1;
#elif defined(WITH_MBEDTLS)
mbedtls_md_context_t* mdctx = ctx->mdctx;
@@ -674,7 +669,7 @@ BOOL winpr_DigestSign_Init(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE md, void* key)
if (!evp)
return FALSE;
- const int rdsi = EVP_DigestSignInit(ctx->mdctx, NULL, evp, NULL, key);
+ const int rdsi = EVP_DigestSignInit(ctx->mdctx, nullptr, evp, nullptr, key);
return (rdsi > 0);
#else
return FALSE;
diff --git a/winpr/libwinpr/crypto/rand.c b/winpr/libwinpr/crypto/rand.c
index 41fe06f53..070295bf6 100644
--- a/winpr/libwinpr/crypto/rand.c
+++ b/winpr/libwinpr/crypto/rand.c
@@ -62,8 +62,8 @@ int winpr_RAND(void* output, size_t len)
mbedtls_hmac_drbg_init(&hmac_drbg);
md_info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256);
- if ((status = mbedtls_hmac_drbg_seed(&hmac_drbg, md_info, mbedtls_entropy_func, &entropy, NULL,
- 0)) != 0)
+ if ((status = mbedtls_hmac_drbg_seed(&hmac_drbg, md_info, mbedtls_entropy_func, &entropy,
+ nullptr, 0)) != 0)
return -1;
status = mbedtls_hmac_drbg_random(&hmac_drbg, output, len);
diff --git a/winpr/libwinpr/crypto/rc4.c b/winpr/libwinpr/crypto/rc4.c
index c1ea61706..e5e42c4d6 100644
--- a/winpr/libwinpr/crypto/rc4.c
+++ b/winpr/libwinpr/crypto/rc4.c
@@ -43,7 +43,7 @@ winpr_int_RC4_CTX* winpr_int_rc4_new(const BYTE* key, size_t keylength)
{
winpr_int_RC4_CTX* ctx = calloc(1, sizeof(winpr_int_RC4_CTX));
if (!ctx)
- return NULL;
+ return nullptr;
for (size_t i = 0; i < CTX_SIZE; i++)
{
diff --git a/winpr/libwinpr/crypto/test/TestCryptoCertEnumCertificatesInStore.c b/winpr/libwinpr/crypto/test/TestCryptoCertEnumCertificatesInStore.c
index 6b40c8d96..d476a2875 100644
--- a/winpr/libwinpr/crypto/test/TestCryptoCertEnumCertificatesInStore.c
+++ b/winpr/libwinpr/crypto/test/TestCryptoCertEnumCertificatesInStore.c
@@ -16,9 +16,9 @@ int TestCryptoCertEnumCertificatesInStore(int argc, char* argv[])
{
int index = 0;
DWORD status = 0;
- LPTSTR pszNameString = NULL;
- HCERTSTORE hCertStore = NULL;
- PCCERT_CONTEXT pCertContext = NULL;
+ LPTSTR pszNameString = nullptr;
+ HCERTSTORE hCertStore = nullptr;
+ PCCERT_CONTEXT pCertContext = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
@@ -30,12 +30,12 @@ int TestCryptoCertEnumCertificatesInStore(int argc, char* argv[])
/**
* Requires elevated rights:
- * hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, (HCRYPTPROV_LEGACY) NULL,
+ * hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0,
* CERT_SYSTEM_STORE_LOCAL_MACHINE, _T("Remote Desktop"));
*/
- hCertStore = CertOpenSystemStore((HCRYPTPROV_LEGACY)NULL, _T("MY"));
- // hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, (HCRYPTPROV_LEGACY) NULL,
+ hCertStore = CertOpenSystemStore(0, _T("MY"));
+ // hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0,
// CERT_SYSTEM_STORE_CURRENT_USER, _T("MY"));
if (!hCertStore)
@@ -48,7 +48,8 @@ int TestCryptoCertEnumCertificatesInStore(int argc, char* argv[])
while ((pCertContext = CertEnumCertificatesInStore(hCertStore, pCertContext)))
{
- status = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0);
+ status =
+ CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, nullptr, nullptr, 0);
if (status == 0)
return -1;
@@ -59,7 +60,7 @@ int TestCryptoCertEnumCertificatesInStore(int argc, char* argv[])
return -1;
}
- status = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL,
+ status = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, nullptr,
pszNameString, status);
if (status == 0)
{
@@ -72,7 +73,8 @@ int TestCryptoCertEnumCertificatesInStore(int argc, char* argv[])
free(pszNameString);
#ifdef WITH_CRYPTUI
- CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, pCertContext, NULL, NULL, 0, NULL);
+ CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, pCertContext, nullptr, nullptr, 0,
+ nullptr);
#endif
}
diff --git a/winpr/libwinpr/crypto/test/TestCryptoCipher.c b/winpr/libwinpr/crypto/test/TestCryptoCipher.c
index 38991a8bd..200df7885 100644
--- a/winpr/libwinpr/crypto/test/TestCryptoCipher.c
+++ b/winpr/libwinpr/crypto/test/TestCryptoCipher.c
@@ -19,7 +19,7 @@ static BOOL test_crypto_cipher_aes_128_cbc(BOOL ex)
/* encrypt */
- WINPR_CIPHER_CTX* ctx = NULL;
+ WINPR_CIPHER_CTX* ctx = nullptr;
if (ex)
ctx = winpr_Cipher_NewEx(WINPR_CIPHER_AES_128_CBC, WINPR_ENCRYPT, key, sizeof(key), iv,
sizeof(iv));
@@ -62,7 +62,7 @@ static BOOL test_crypto_cipher_aes_128_cbc(BOOL ex)
}
winpr_Cipher_Free(ctx);
- ctx = NULL;
+ ctx = nullptr;
/* decrypt */
@@ -129,7 +129,7 @@ static const char TEST_RC4_CIPHERTEXT[] = "\xBB\xF3\x16\xE8\xD9\x40\xAF\x0A\xD3"
static BOOL test_crypto_cipher_rc4(void)
{
BOOL rc = FALSE;
- WINPR_RC4_CTX* ctx = NULL;
+ WINPR_RC4_CTX* ctx = nullptr;
const size_t len = strnlen(TEST_RC4_PLAINTEXT, sizeof(TEST_RC4_PLAINTEXT));
BYTE* text = (BYTE*)calloc(1, len);
@@ -140,7 +140,7 @@ static BOOL test_crypto_cipher_rc4(void)
goto out;
}
- if ((ctx = winpr_RC4_New(TEST_RC4_KEY, strnlen(TEST_RC4_KEY, sizeof(TEST_RC4_KEY)))) == NULL)
+ if ((ctx = winpr_RC4_New(TEST_RC4_KEY, strnlen(TEST_RC4_KEY, sizeof(TEST_RC4_KEY)))) == nullptr)
{
(void)fprintf(stderr, "%s: winpr_RC4_New failed\n", __func__);
goto out;
@@ -155,8 +155,8 @@ static BOOL test_crypto_cipher_rc4(void)
if (memcmp(text, TEST_RC4_CIPHERTEXT, len) != 0)
{
- char* actual = NULL;
- char* expected = NULL;
+ char* actual = nullptr;
+ char* expected = nullptr;
actual = winpr_BinToHexString(text, len, FALSE);
expected = winpr_BinToHexString(TEST_RC4_CIPHERTEXT, len, FALSE);
@@ -202,10 +202,10 @@ static BOOL test_crypto_cipher_key(void)
if (status != 32 || memcmp(key, TEST_CIPHER_KEY, 32) != 0 ||
memcmp(iv, TEST_CIPHER_IV, 16) != 0)
{
- char* akstr = NULL;
- char* ekstr = NULL;
- char* aivstr = NULL;
- char* eivstr = NULL;
+ char* akstr = nullptr;
+ char* ekstr = nullptr;
+ char* aivstr = nullptr;
+ char* eivstr = nullptr;
akstr = winpr_BinToHexString(key, 32, 0);
ekstr = winpr_BinToHexString(TEST_CIPHER_KEY, 32, 0);
diff --git a/winpr/libwinpr/crypto/test/TestCryptoHash.c b/winpr/libwinpr/crypto/test/TestCryptoHash.c
index 3e7fe9831..a1aea53fa 100644
--- a/winpr/libwinpr/crypto/test/TestCryptoHash.c
+++ b/winpr/libwinpr/crypto/test/TestCryptoHash.c
@@ -12,7 +12,7 @@ static BOOL test_crypto_hash_md5(void)
{
BOOL result = FALSE;
BYTE hash[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
- WINPR_DIGEST_CTX* ctx = NULL;
+ WINPR_DIGEST_CTX* ctx = nullptr;
if (!(ctx = winpr_Digest_New()))
{
@@ -37,8 +37,8 @@ static BOOL test_crypto_hash_md5(void)
}
if (memcmp(hash, TEST_MD5_HASH, WINPR_MD5_DIGEST_LENGTH) != 0)
{
- char* actual = NULL;
- char* expected = NULL;
+ char* actual = nullptr;
+ char* expected = nullptr;
actual = winpr_BinToHexString(hash, WINPR_MD5_DIGEST_LENGTH, FALSE);
expected = winpr_BinToHexString(TEST_MD5_HASH, WINPR_MD5_DIGEST_LENGTH, FALSE);
@@ -65,7 +65,7 @@ static BOOL test_crypto_hash_md4(void)
{
BOOL result = FALSE;
BYTE hash[WINPR_MD4_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
- WINPR_DIGEST_CTX* ctx = NULL;
+ WINPR_DIGEST_CTX* ctx = nullptr;
if (!(ctx = winpr_Digest_New()))
{
@@ -90,8 +90,8 @@ static BOOL test_crypto_hash_md4(void)
}
if (memcmp(hash, TEST_MD4_HASH, WINPR_MD4_DIGEST_LENGTH) != 0)
{
- char* actual = NULL;
- char* expected = NULL;
+ char* actual = nullptr;
+ char* expected = nullptr;
actual = winpr_BinToHexString(hash, WINPR_MD4_DIGEST_LENGTH, FALSE);
expected = winpr_BinToHexString(TEST_MD4_HASH, WINPR_MD4_DIGEST_LENGTH, FALSE);
@@ -118,7 +118,7 @@ static BOOL test_crypto_hash_sha1(void)
{
BOOL result = FALSE;
BYTE hash[WINPR_SHA1_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
- WINPR_DIGEST_CTX* ctx = NULL;
+ WINPR_DIGEST_CTX* ctx = nullptr;
if (!(ctx = winpr_Digest_New()))
{
@@ -144,8 +144,8 @@ static BOOL test_crypto_hash_sha1(void)
if (memcmp(hash, TEST_SHA1_HASH, WINPR_MD5_DIGEST_LENGTH) != 0)
{
- char* actual = NULL;
- char* expected = NULL;
+ char* actual = nullptr;
+ char* expected = nullptr;
actual = winpr_BinToHexString(hash, WINPR_SHA1_DIGEST_LENGTH, FALSE);
expected = winpr_BinToHexString(TEST_SHA1_HASH, WINPR_SHA1_DIGEST_LENGTH, FALSE);
@@ -173,7 +173,7 @@ static const BYTE TEST_HMAC_MD5_HASH[] =
static BOOL test_crypto_hash_hmac_md5(void)
{
BYTE hash[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
- WINPR_HMAC_CTX* ctx = NULL;
+ WINPR_HMAC_CTX* ctx = nullptr;
BOOL result = FALSE;
if (!(ctx = winpr_HMAC_New()))
@@ -207,8 +207,8 @@ static BOOL test_crypto_hash_hmac_md5(void)
if (memcmp(hash, TEST_HMAC_MD5_HASH, WINPR_MD5_DIGEST_LENGTH) != 0)
{
- char* actual = NULL;
- char* expected = NULL;
+ char* actual = nullptr;
+ char* expected = nullptr;
actual = winpr_BinToHexString(hash, WINPR_MD5_DIGEST_LENGTH, FALSE);
expected = winpr_BinToHexString(TEST_HMAC_MD5_HASH, WINPR_MD5_DIGEST_LENGTH, FALSE);
@@ -237,7 +237,7 @@ static const BYTE TEST_HMAC_SHA1_HASH[] =
static BOOL test_crypto_hash_hmac_sha1(void)
{
BYTE hash[WINPR_SHA1_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
- WINPR_HMAC_CTX* ctx = NULL;
+ WINPR_HMAC_CTX* ctx = nullptr;
BOOL result = FALSE;
if (!(ctx = winpr_HMAC_New()))
@@ -271,8 +271,8 @@ static BOOL test_crypto_hash_hmac_sha1(void)
if (memcmp(hash, TEST_HMAC_SHA1_HASH, WINPR_SHA1_DIGEST_LENGTH) != 0)
{
- char* actual = NULL;
- char* expected = NULL;
+ char* actual = nullptr;
+ char* expected = nullptr;
actual = winpr_BinToHexString(hash, WINPR_SHA1_DIGEST_LENGTH, FALSE);
expected = winpr_BinToHexString(TEST_HMAC_SHA1_HASH, WINPR_SHA1_DIGEST_LENGTH, FALSE);
diff --git a/winpr/libwinpr/crypto/test/TestCryptoProtectMemory.c b/winpr/libwinpr/crypto/test/TestCryptoProtectMemory.c
index d904c7f70..828dfb346 100644
--- a/winpr/libwinpr/crypto/test/TestCryptoProtectMemory.c
+++ b/winpr/libwinpr/crypto/test/TestCryptoProtectMemory.c
@@ -11,8 +11,8 @@ int TestCryptoProtectMemory(int argc, char* argv[])
{
UINT32 cbPlainText = 0;
UINT32 cbCipherText = 0;
- const char* pPlainText = NULL;
- BYTE* pCipherText = NULL;
+ const char* pPlainText = nullptr;
+ BYTE* pCipherText = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
diff --git a/winpr/libwinpr/crypto/test/TestCryptoRand.c b/winpr/libwinpr/crypto/test/TestCryptoRand.c
index 129517127..fced995d3 100644
--- a/winpr/libwinpr/crypto/test/TestCryptoRand.c
+++ b/winpr/libwinpr/crypto/test/TestCryptoRand.c
@@ -5,7 +5,7 @@
int TestCryptoRand(int argc, char* argv[])
{
- char* str = NULL;
+ char* str = nullptr;
BYTE rnd[16] = WINPR_C_ARRAY_INIT;
WINPR_UNUSED(argc);
diff --git a/winpr/libwinpr/dsparse/dsparse.c b/winpr/libwinpr/dsparse/dsparse.c
index fd8bbfb22..258814dce 100644
--- a/winpr/libwinpr/dsparse/dsparse.c
+++ b/winpr/libwinpr/dsparse/dsparse.c
@@ -48,11 +48,11 @@ DWORD DsMakeSpnW(LPCWSTR ServiceClass, LPCWSTR ServiceName, LPCWSTR InstanceName
USHORT InstancePort, LPCWSTR Referrer, DWORD* pcSpnLength, LPWSTR pszSpn)
{
DWORD res = ERROR_OUTOFMEMORY;
- char* ServiceClassA = NULL;
- char* ServiceNameA = NULL;
- char* InstanceNameA = NULL;
- char* ReferrerA = NULL;
- char* pszSpnA = NULL;
+ char* ServiceClassA = nullptr;
+ char* ServiceNameA = nullptr;
+ char* InstanceNameA = nullptr;
+ char* ReferrerA = nullptr;
+ char* pszSpnA = nullptr;
size_t length = 0;
WINPR_ASSERT(ServiceClass);
@@ -65,25 +65,25 @@ DWORD DsMakeSpnW(LPCWSTR ServiceClass, LPCWSTR ServiceName, LPCWSTR InstanceName
if (ServiceClass)
{
- ServiceClassA = ConvertWCharToUtf8Alloc(ServiceClass, NULL);
+ ServiceClassA = ConvertWCharToUtf8Alloc(ServiceClass, nullptr);
if (!ServiceClassA)
goto fail;
}
if (ServiceName)
{
- ServiceNameA = ConvertWCharToUtf8Alloc(ServiceName, NULL);
+ ServiceNameA = ConvertWCharToUtf8Alloc(ServiceName, nullptr);
if (!ServiceNameA)
goto fail;
}
if (InstanceName)
{
- InstanceNameA = ConvertWCharToUtf8Alloc(InstanceName, NULL);
+ InstanceNameA = ConvertWCharToUtf8Alloc(InstanceName, nullptr);
if (!InstanceNameA)
goto fail;
}
if (Referrer)
{
- ReferrerA = ConvertWCharToUtf8Alloc(Referrer, NULL);
+ ReferrerA = ConvertWCharToUtf8Alloc(Referrer, nullptr);
if (!ReferrerA)
goto fail;
}
@@ -120,7 +120,7 @@ DWORD DsMakeSpnA(LPCSTR ServiceClass, LPCSTR ServiceName, LPCSTR InstanceName, U
WINPR_UNUSED(InstancePort);
WINPR_UNUSED(Referrer);
- if ((*pcSpnLength != 0) && (pszSpn == NULL))
+ if ((*pcSpnLength != 0) && (pszSpn == nullptr))
return ERROR_INVALID_PARAMETER;
ServiceClassLength = (DWORD)strlen(ServiceClass);
diff --git a/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c b/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c
index c8d549a27..29b078f37 100644
--- a/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c
+++ b/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c
@@ -15,7 +15,8 @@ static BOOL test_DsMakeSpnA(void)
DWORD status = 0;
DWORD SpnLength = -1;
- status = DsMakeSpnA(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL);
+ status =
+ DsMakeSpnA(testServiceClass, testServiceName, nullptr, 0, nullptr, &SpnLength, nullptr);
if (status != ERROR_INVALID_PARAMETER)
{
@@ -24,7 +25,8 @@ static BOOL test_DsMakeSpnA(void)
}
SpnLength = 0;
- status = DsMakeSpnA(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL);
+ status =
+ DsMakeSpnA(testServiceClass, testServiceName, nullptr, 0, nullptr, &SpnLength, nullptr);
if (status != ERROR_BUFFER_OVERFLOW)
{
@@ -38,7 +40,7 @@ static BOOL test_DsMakeSpnA(void)
goto fail;
}
- status = DsMakeSpnA(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, Spn);
+ status = DsMakeSpnA(testServiceClass, testServiceName, nullptr, 0, nullptr, &SpnLength, Spn);
if (status != ERROR_SUCCESS)
{
@@ -82,7 +84,8 @@ static BOOL test_DsMakeSpnW(void)
ARRAYSIZE(testServiceName));
(void)ConvertUtf8NToWChar(ctestSpn, ARRAYSIZE(ctestSpn), testSpn, ARRAYSIZE(testSpn));
- status = DsMakeSpnW(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL);
+ status =
+ DsMakeSpnW(testServiceClass, testServiceName, nullptr, 0, nullptr, &SpnLength, nullptr);
if (status != ERROR_INVALID_PARAMETER)
{
@@ -91,7 +94,8 @@ static BOOL test_DsMakeSpnW(void)
}
SpnLength = 0;
- status = DsMakeSpnW(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL);
+ status =
+ DsMakeSpnW(testServiceClass, testServiceName, nullptr, 0, nullptr, &SpnLength, nullptr);
if (status != ERROR_BUFFER_OVERFLOW)
{
@@ -105,7 +109,7 @@ static BOOL test_DsMakeSpnW(void)
goto fail;
}
- status = DsMakeSpnW(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, Spn);
+ status = DsMakeSpnW(testServiceClass, testServiceName, nullptr, 0, nullptr, &SpnLength, Spn);
if (status != ERROR_SUCCESS)
{
diff --git a/winpr/libwinpr/environment/environment.c b/winpr/libwinpr/environment/environment.c
index a39b6163d..2a450a767 100644
--- a/winpr/libwinpr/environment/environment.c
+++ b/winpr/libwinpr/environment/environment.c
@@ -52,8 +52,8 @@
DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
{
size_t length = 0;
- char* cwd = NULL;
- char* ccwd = NULL;
+ char* cwd = nullptr;
+ char* ccwd = nullptr;
do
{
@@ -77,14 +77,14 @@ DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
length = strnlen(cwd, length);
- if ((nBufferLength == 0) && (lpBuffer == NULL))
+ if ((nBufferLength == 0) && (lpBuffer == nullptr))
{
free(cwd);
return (DWORD)length;
}
else
{
- if (lpBuffer == NULL)
+ if (lpBuffer == nullptr)
{
free(cwd);
return 0;
@@ -139,13 +139,13 @@ DWORD SearchPathW(WINPR_ATTR_UNUSED LPCWSTR lpPath, WINPR_ATTR_UNUSED LPCWSTR lp
LPSTR GetCommandLineA(VOID)
{
WLog_ERR(TAG, "TODO: not implemented");
- return NULL;
+ return nullptr;
}
LPWSTR GetCommandLineW(VOID)
{
WLog_ERR(TAG, "TODO: not implemented");
- return NULL;
+ return nullptr;
}
BOOL NeedCurrentDirectoryForExePathA(WINPR_ATTR_UNUSED LPCSTR ExeName)
@@ -260,7 +260,7 @@ LPCH GetEnvironmentStringsA(VOID)
LPCH lpszEnvironmentBlock = (LPCH)calloc(cchEnvironmentBlock, sizeof(CHAR));
if (!lpszEnvironmentBlock)
- return NULL;
+ return nullptr;
while (*envp)
{
@@ -271,7 +271,7 @@ LPCH GetEnvironmentStringsA(VOID)
WLog_ERR(TAG, "Environment block too large: %" PRIuz, required);
free(lpszEnvironmentBlock);
- return NULL;
+ return nullptr;
}
if (required > cchEnvironmentBlock)
@@ -285,7 +285,7 @@ LPCH GetEnvironmentStringsA(VOID)
if (!new_blk)
{
free(lpszEnvironmentBlock);
- return NULL;
+ return nullptr;
}
lpszEnvironmentBlock = new_blk;
@@ -305,14 +305,14 @@ LPCH GetEnvironmentStringsA(VOID)
return lpszEnvironmentBlock;
#else
- return NULL;
+ return nullptr;
#endif
}
LPWCH GetEnvironmentStringsW(VOID)
{
WLog_ERR(TAG, "TODO: not implemented");
- return NULL;
+ return nullptr;
}
BOOL SetEnvironmentStringsA(WINPR_ATTR_UNUSED LPCH NewEnvironment)
@@ -359,24 +359,24 @@ BOOL FreeEnvironmentStringsW(LPWCH lpszEnvironmentBlock)
LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
{
- const char* cp = NULL;
- char* p = NULL;
+ const char* cp = nullptr;
+ char* p = nullptr;
size_t offset = 0;
size_t length = 0;
- const char* envp = NULL;
+ const char* envp = nullptr;
DWORD cchEnvironmentBlock = 0;
- LPCH lpszEnvironmentBlock = NULL;
- const char** mergeStrings = NULL;
+ LPCH lpszEnvironmentBlock = nullptr;
+ const char** mergeStrings = nullptr;
size_t mergeStringLength = 0;
size_t mergeArraySize = 128;
size_t mergeLength = 0;
size_t foundMerge = 0;
- char* foundEquals = NULL;
+ char* foundEquals = nullptr;
mergeStrings = (LPCSTR*)calloc(mergeArraySize, sizeof(char*));
if (!mergeStrings)
- return NULL;
+ return nullptr;
mergeStringLength = 0;
@@ -388,7 +388,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
if (mergeStringLength == mergeArraySize)
{
- const char** new_str = NULL;
+ const char** new_str = nullptr;
mergeArraySize += 128;
new_str = (const char**)realloc((void*)mergeStrings, mergeArraySize * sizeof(char*));
@@ -396,7 +396,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
if (!new_str)
{
free((void*)mergeStrings);
- return NULL;
+ return nullptr;
}
mergeStrings = new_str;
}
@@ -414,12 +414,12 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
if (!lpszEnvironmentBlock)
{
free((void*)mergeStrings);
- return NULL;
+ return nullptr;
}
envp = original;
- while ((original != NULL) && (*envp && *(envp + 1)))
+ while ((original != nullptr) && (*envp && *(envp + 1)))
{
size_t old_offset = offset;
length = strlen(envp);
@@ -433,7 +433,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
{
free((void*)lpszEnvironmentBlock);
free((void*)mergeStrings);
- return NULL;
+ return nullptr;
}
lpszEnvironmentBlock = tmp;
}
@@ -474,7 +474,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
{
free((void*)lpszEnvironmentBlock);
free((void*)mergeStrings);
- return NULL;
+ return nullptr;
}
lpszEnvironmentBlock = tmp;
p = &(lpszEnvironmentBlock[old_offset]);
@@ -482,7 +482,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
foundMerge = 1;
CopyMemory(p, mergeStrings[run], mergeLength);
- mergeStrings[run] = NULL;
+ mergeStrings[run] = nullptr;
p[mergeLength] = '\0';
offset += (mergeLength + 1);
}
@@ -516,7 +516,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
{
free((void*)lpszEnvironmentBlock);
free((void*)mergeStrings);
- return NULL;
+ return nullptr;
}
lpszEnvironmentBlock = tmp;
@@ -525,7 +525,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
p = &(lpszEnvironmentBlock[offset]);
CopyMemory(p, mergeStrings[run], mergeLength);
- mergeStrings[run] = NULL;
+ mergeStrings[run] = nullptr;
p[mergeLength] = '\0';
offset += (mergeLength + 1);
}
@@ -540,14 +540,14 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge)
DWORD GetEnvironmentVariableEBA(LPCSTR envBlock, LPCSTR lpName, LPSTR lpBuffer, DWORD nSize)
{
size_t vLength = 0;
- char* env = NULL;
- char* foundEquals = NULL;
+ char* env = nullptr;
+ char* foundEquals = nullptr;
const char* penvb = envBlock;
size_t nLength = 0;
size_t fLength = 0;
size_t lpNameLength = 0;
- if (!lpName || NULL == envBlock)
+ if (!lpName || nullptr == envBlock)
return 0;
lpNameLength = strlen(lpName);
@@ -601,8 +601,8 @@ DWORD GetEnvironmentVariableEBA(LPCSTR envBlock, LPCSTR lpName, LPSTR lpBuffer,
BOOL SetEnvironmentVariableEBA(LPSTR* envBlock, LPCSTR lpName, LPCSTR lpValue)
{
size_t length = 0;
- char* envstr = NULL;
- char* newEB = NULL;
+ char* envstr = nullptr;
+ char* newEB = nullptr;
if (!lpName)
return FALSE;
@@ -642,15 +642,15 @@ BOOL SetEnvironmentVariableEBA(LPSTR* envBlock, LPCSTR lpName, LPCSTR lpValue)
char** EnvironmentBlockToEnvpA(LPCH lpszEnvironmentBlock)
{
- char* p = NULL;
+ char* p = nullptr;
SSIZE_T index = 0;
size_t count = 0;
size_t length = 0;
- char** envp = NULL;
+ char** envp = nullptr;
count = 0;
if (!lpszEnvironmentBlock)
- return NULL;
+ return nullptr;
p = (char*)lpszEnvironmentBlock;
@@ -666,8 +666,8 @@ char** EnvironmentBlockToEnvpA(LPCH lpszEnvironmentBlock)
envp = (char**)calloc(count + 1, sizeof(char*));
if (!envp)
- return NULL;
- envp[count] = NULL;
+ return nullptr;
+ envp[count] = nullptr;
while (p[0] && p[1])
{
@@ -680,7 +680,7 @@ char** EnvironmentBlockToEnvpA(LPCH lpszEnvironmentBlock)
free(envp[index]);
}
free((void*)envp);
- return NULL;
+ return nullptr;
}
p += (length + 1);
index++;
@@ -698,11 +698,11 @@ DWORD GetEnvironmentVariableX(const char* lpName, char* lpBuffer, DWORD nSize)
{
DWORD result = 0;
DWORD nSizeW = 0;
- LPWSTR lpNameW = NULL;
- LPWSTR lpBufferW = NULL;
+ LPWSTR lpNameW = nullptr;
+ LPWSTR lpBufferW = nullptr;
LPSTR lpBufferA = lpBuffer;
- lpNameW = ConvertUtf8ToWCharAlloc(lpName, NULL);
+ lpNameW = ConvertUtf8ToWCharAlloc(lpName, nullptr);
if (!lpNameW)
goto cleanup;
diff --git a/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.c b/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.c
index f7f2435a9..09b6a3f11 100644
--- a/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.c
+++ b/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.c
@@ -19,7 +19,7 @@ int TestEnvironmentGetEnvironmentStrings(int argc, char* argv[])
while (p[0] && p[1])
{
const size_t max = _tcslen(p);
- const int rc = _sntprintf(NULL, 0, _T("%s\n"), p);
+ const int rc = _sntprintf(nullptr, 0, _T("%s\n"), p);
if (rc < 1)
{
_tprintf(_T("test failed: return %d\n"), rc);
diff --git a/winpr/libwinpr/environment/test/TestEnvironmentGetSetEB.c b/winpr/libwinpr/environment/test/TestEnvironmentGetSetEB.c
index 603b4c2f0..613a2302c 100644
--- a/winpr/libwinpr/environment/test/TestEnvironmentGetSetEB.c
+++ b/winpr/libwinpr/environment/test/TestEnvironmentGetSetEB.c
@@ -9,17 +9,17 @@ int TestEnvironmentGetSetEB(int argc, char* argv[])
int rc = 0;
#ifndef _WIN32
char test[1024];
- TCHAR* p = NULL;
+ TCHAR* p = nullptr;
DWORD length = 0;
LPTCH lpszEnvironmentBlock = "SHELL=123\0test=1\0test1=2\0DISPLAY=WINPR_TEST_VALUE\0\0";
- LPTCH lpszEnvironmentBlockNew = NULL;
+ LPTCH lpszEnvironmentBlockNew = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
rc = -1;
/* Get length of an variable */
- length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "DISPLAY", NULL, 0);
+ length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "DISPLAY", nullptr, 0);
if (0 == length)
return -1;
@@ -39,7 +39,7 @@ int TestEnvironmentGetSetEB(int argc, char* argv[])
goto fail;
/* Get length of an non-existing variable */
- length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "BLA", NULL, 0);
+ length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "BLA", nullptr, 0);
if (0 != length)
{
@@ -48,7 +48,7 @@ int TestEnvironmentGetSetEB(int argc, char* argv[])
}
/* Get length of an similar called variables */
- length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "XDISPLAY", NULL, 0);
+ length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "XDISPLAY", nullptr, 0);
if (0 != length)
{
@@ -56,7 +56,7 @@ int TestEnvironmentGetSetEB(int argc, char* argv[])
goto fail;
}
- length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "DISPLAYX", NULL, 0);
+ length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "DISPLAYX", nullptr, 0);
if (0 != length)
{
@@ -64,7 +64,7 @@ int TestEnvironmentGetSetEB(int argc, char* argv[])
goto fail;
}
- length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "DISPLA", NULL, 0);
+ length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "DISPLA", nullptr, 0);
if (0 != length)
{
@@ -72,7 +72,7 @@ int TestEnvironmentGetSetEB(int argc, char* argv[])
goto fail;
}
- length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "ISPLAY", NULL, 0);
+ length = GetEnvironmentVariableEBA(lpszEnvironmentBlock, "ISPLAY", nullptr, 0);
if (0 != length)
{
@@ -93,7 +93,7 @@ int TestEnvironmentGetSetEB(int argc, char* argv[])
}
/* Clear variable */
- if (SetEnvironmentVariableEBA(&lpszEnvironmentBlockNew, "test", NULL))
+ if (SetEnvironmentVariableEBA(&lpszEnvironmentBlockNew, "test", nullptr))
{
if (GetEnvironmentVariableEBA(lpszEnvironmentBlockNew, "test", test, 1023))
goto fail;
diff --git a/winpr/libwinpr/environment/test/TestEnvironmentMergeEnvironmentStrings.c b/winpr/libwinpr/environment/test/TestEnvironmentMergeEnvironmentStrings.c
index 428418d2b..fddddefb8 100644
--- a/winpr/libwinpr/environment/test/TestEnvironmentMergeEnvironmentStrings.c
+++ b/winpr/libwinpr/environment/test/TestEnvironmentMergeEnvironmentStrings.c
@@ -7,11 +7,11 @@
int TestEnvironmentMergeEnvironmentStrings(int argc, char* argv[])
{
#ifndef _WIN32
- TCHAR* p = NULL;
+ TCHAR* p = nullptr;
size_t length = 0;
- LPTCH lpszEnvironmentBlock = NULL;
+ LPTCH lpszEnvironmentBlock = nullptr;
LPTCH lpsz2Merge = "SHELL=123\0test=1\0test1=2\0DISPLAY=:77\0\0";
- LPTCH lpszMergedEnvironmentBlock = NULL;
+ LPTCH lpszMergedEnvironmentBlock = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
diff --git a/winpr/libwinpr/environment/test/TestEnvironmentSetEnvironmentVariable.c b/winpr/libwinpr/environment/test/TestEnvironmentSetEnvironmentVariable.c
index 04b706411..8149899ca 100644
--- a/winpr/libwinpr/environment/test/TestEnvironmentSetEnvironmentVariable.c
+++ b/winpr/libwinpr/environment/test/TestEnvironmentSetEnvironmentVariable.c
@@ -11,14 +11,14 @@ int TestEnvironmentSetEnvironmentVariable(int argc, char* argv[])
{
int rc = -1;
DWORD nSize = 0;
- LPSTR lpBuffer = NULL;
+ LPSTR lpBuffer = nullptr;
DWORD error = 0;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
SetEnvironmentVariableA(TEST_NAME, TEST_VALUE);
- nSize = GetEnvironmentVariableA(TEST_NAME, NULL, 0);
+ nSize = GetEnvironmentVariableA(TEST_NAME, nullptr, 0);
/* check if value returned is len + 1 ) */
if (nSize != strnlen(TEST_VALUE, sizeof(TEST_VALUE)) + 1)
@@ -56,8 +56,8 @@ int TestEnvironmentSetEnvironmentVariable(int argc, char* argv[])
}
/* clear variable */
- SetEnvironmentVariableA(TEST_NAME, NULL);
- nSize = GetEnvironmentVariableA(TEST_VALUE, NULL, 0);
+ SetEnvironmentVariableA(TEST_NAME, nullptr);
+ nSize = GetEnvironmentVariableA(TEST_VALUE, nullptr, 0);
if (0 != nSize)
{
diff --git a/winpr/libwinpr/error/error.c b/winpr/libwinpr/error/error.c
index de7d4f503..1756b6907 100644
--- a/winpr/libwinpr/error/error.c
+++ b/winpr/libwinpr/error/error.c
@@ -83,14 +83,14 @@ SetUnhandledExceptionFilter(
WINPR_ATTR_UNUSED LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
{
WLog_ERR("TODO", "TOdO: implement");
- return NULL;
+ return nullptr;
}
PVOID AddVectoredExceptionHandler(WINPR_ATTR_UNUSED ULONG First,
WINPR_ATTR_UNUSED PVECTORED_EXCEPTION_HANDLER Handler)
{
WLog_ERR("TODO", "TOdO: implement");
- return NULL;
+ return nullptr;
}
ULONG RemoveVectoredExceptionHandler(WINPR_ATTR_UNUSED PVOID Handle)
@@ -103,7 +103,7 @@ PVOID AddVectoredContinueHandler(WINPR_ATTR_UNUSED ULONG First,
WINPR_ATTR_UNUSED PVECTORED_EXCEPTION_HANDLER Handler)
{
WLog_ERR("TODO", "TOdO: implement");
- return NULL;
+ return nullptr;
}
ULONG RemoveVectoredContinueHandler(WINPR_ATTR_UNUSED PVOID Handle)
diff --git a/winpr/libwinpr/error/test/TestErrorSetLastError.c b/winpr/libwinpr/error/test/TestErrorSetLastError.c
index b274addc6..ed62c6a50 100644
--- a/winpr/libwinpr/error/test/TestErrorSetLastError.c
+++ b/winpr/libwinpr/error/test/TestErrorSetLastError.c
@@ -29,7 +29,7 @@
static int status = 0;
-static LONG* pLoopCount = NULL;
+static LONG* pLoopCount = nullptr;
static BOOL bStopTest = FALSE;
static UINT32 prand(UINT32 max)
@@ -102,7 +102,8 @@ int TestErrorSetLastError(int argc, char* argv[])
for (int i = 0; i < 4; i++)
{
- if (!(threads[i] = CreateThread(NULL, 0, test_error_thread, (void*)(size_t)0, 0, NULL)))
+ if (!(threads[i] =
+ CreateThread(nullptr, 0, test_error_thread, (void*)(size_t)0, 0, nullptr)))
{
printf("Failed to create thread #%d\n", i);
return -1;
diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c
index 85bf09d7c..6d01c3aa3 100644
--- a/winpr/libwinpr/file/file.c
+++ b/winpr/libwinpr/file/file.c
@@ -56,7 +56,7 @@
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
-static WINPR_FILE* pStdHandleFile = NULL;
+static WINPR_FILE* pStdHandleFile = nullptr;
static void GetStdHandle_Uninit(void) __attribute__((destructor));
@@ -96,7 +96,7 @@ static BOOL FileCloseHandleInt(HANDLE handle, BOOL force)
if (fileno(file->fp) > 2)
{
(void)fclose(file->fp);
- file->fp = NULL;
+ file->fp = nullptr;
}
}
@@ -122,7 +122,7 @@ static BOOL log_error_(const char* name, const WINPR_FILE* pFile, const char* fi
WINPR_ASSERT(fkt);
const DWORD level = WLOG_ERROR;
- static wLog* log = NULL;
+ static wLog* log = nullptr;
if (!log)
log = WLog_Get(TAG);
@@ -235,7 +235,7 @@ static BOOL FileRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
{
size_t io_status = 0;
- WINPR_FILE* file = NULL;
+ WINPR_FILE* file = nullptr;
BOOL status = TRUE;
if (lpOverlapped)
@@ -276,7 +276,7 @@ static BOOL FileWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrit
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
{
size_t io_status = 0;
- WINPR_FILE* file = NULL;
+ WINPR_FILE* file = nullptr;
if (lpOverlapped)
{
@@ -304,7 +304,7 @@ static BOOL FileWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrit
static DWORD FileGetFileSize(HANDLE Object, LPDWORD lpFileSizeHigh)
{
- WINPR_FILE* file = NULL;
+ WINPR_FILE* file = nullptr;
INT64 cur = 0;
INT64 size = 0;
@@ -379,7 +379,7 @@ static BOOL FileGetFileInformationByHandle(HANDLE hFile,
WINPR_FILE* pFile = (WINPR_FILE*)hFile;
struct stat st;
UINT64 ft = 0;
- const char* lastSep = NULL;
+ const char* lastSep = nullptr;
if (!pFile)
return FALSE;
@@ -719,19 +719,19 @@ static HANDLE_OPS fileOps = {
FileIsHandled,
FileCloseHandle,
FileGetFd,
- NULL, /* CleanupHandle */
+ nullptr, /* CleanupHandle */
FileRead,
- NULL, /* FileReadEx */
- NULL, /* FileReadScatter */
+ nullptr, /* FileReadEx */
+ nullptr, /* FileReadScatter */
FileWrite,
- NULL, /* FileWriteEx */
- NULL, /* FileWriteGather */
+ nullptr, /* FileWriteEx */
+ nullptr, /* FileWriteGather */
FileGetFileSize,
FileFlushFileBuffers,
FileSetEndOfFile,
FileSetFilePointer,
FileSetFilePointerEx,
- NULL, /* FileLockFile */
+ nullptr, /* FileLockFile */
FileLockFileEx,
FileUnlockFile,
FileUnlockFileEx,
@@ -743,23 +743,23 @@ static HANDLE_OPS shmOps = {
FileIsHandled,
FileCloseHandle,
FileGetFd,
- NULL, /* CleanupHandle */
+ nullptr, /* CleanupHandle */
FileRead,
- NULL, /* FileReadEx */
- NULL, /* FileReadScatter */
+ nullptr, /* FileReadEx */
+ nullptr, /* FileReadScatter */
FileWrite,
- NULL, /* FileWriteEx */
- NULL, /* FileWriteGather */
- NULL, /* FileGetFileSize */
- NULL, /* FlushFileBuffers */
- NULL, /* FileSetEndOfFile */
- NULL, /* FileSetFilePointer */
- NULL, /* SetFilePointerEx */
- NULL, /* FileLockFile */
- NULL, /* FileLockFileEx */
- NULL, /* FileUnlockFile */
- NULL, /* FileUnlockFileEx */
- NULL, /* FileSetFileTime */
+ nullptr, /* FileWriteEx */
+ nullptr, /* FileWriteGather */
+ nullptr, /* FileGetFileSize */
+ nullptr, /* FlushFileBuffers */
+ nullptr, /* FileSetEndOfFile */
+ nullptr, /* FileSetFilePointer */
+ nullptr, /* SetFilePointerEx */
+ nullptr, /* FileLockFile */
+ nullptr, /* FileLockFileEx */
+ nullptr, /* FileUnlockFile */
+ nullptr, /* FileUnlockFileEx */
+ nullptr, /* FileSetFileTime */
FileGetFileInformationByHandle,
};
@@ -857,7 +857,7 @@ static HANDLE FileCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dw
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile)
{
- WINPR_FILE* pFile = NULL;
+ WINPR_FILE* pFile = nullptr;
BOOL create = 0;
const char* mode = FileGetMode(dwDesiredAccess, dwCreationDisposition, &create);
#ifdef __sun
@@ -865,7 +865,7 @@ static HANDLE FileCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dw
#else
int lock = 0;
#endif
- FILE* fp = NULL;
+ FILE* fp = nullptr;
struct stat st;
if (dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED)
@@ -946,7 +946,7 @@ static HANDLE FileCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dw
}
}
- if (NULL == fp)
+ if (nullptr == fp)
fp = winpr_fopen(pFile->lpFileName, mode);
pFile->fp = fp;
@@ -960,7 +960,7 @@ static HANDLE FileCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dw
return INVALID_HANDLE_VALUE;
}
- (void)setvbuf(fp, NULL, _IONBF, 0);
+ (void)setvbuf(fp, nullptr, _IONBF, 0);
#ifdef __sun
lock.l_start = 0;
@@ -1029,7 +1029,7 @@ const HANDLE_CREATOR* GetFileHandleCreator(void)
static WINPR_FILE* FileHandle_New(FILE* fp)
{
- WINPR_FILE* pFile = NULL;
+ WINPR_FILE* pFile = nullptr;
char name[MAX_PATH] = WINPR_C_ARRAY_INIT;
(void)_snprintf(name, sizeof(name), "device_%d", fileno(fp));
@@ -1037,7 +1037,7 @@ static WINPR_FILE* FileHandle_New(FILE* fp)
if (!pFile)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
+ return nullptr;
}
pFile->fp = fp;
pFile->common.ops = &shmOps;
@@ -1054,7 +1054,7 @@ void GetStdHandle_Uninit(void)
HANDLE GetStdHandle(DWORD nStdHandle)
{
- FILE* fp = NULL;
+ FILE* fp = nullptr;
switch (nStdHandle)
{
@@ -1116,7 +1116,7 @@ BOOL GetDiskFreeSpaceW(LPCWSTR lpRootPathName, LPDWORD lpSectorsPerCluster,
if (!lpRootPathName)
return FALSE;
- char* rootPathName = ConvertWCharToUtf8Alloc(lpRootPathName, NULL);
+ char* rootPathName = ConvertWCharToUtf8Alloc(lpRootPathName, nullptr);
if (!rootPathName)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@@ -1308,12 +1308,12 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
{
HANDLE hFile;
if (!lpFileName)
- return NULL;
+ return nullptr;
- WCHAR* lpFileNameW = ConvertUtf8ToWCharAlloc(lpFileName, NULL);
+ WCHAR* lpFileNameW = ConvertUtf8ToWCharAlloc(lpFileName, nullptr);
if (!lpFileNameW)
- return NULL;
+ return nullptr;
hFile = CreateFileW(lpFileNameW, dwDesiredAccess, dwShareMode, lpSecurityAttributes,
dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
@@ -1364,27 +1364,27 @@ DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveH
HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
{
return FindFirstFileExA(lpFileName, FindExInfoStandard, lpFindFileData, FindExSearchNameMatch,
- NULL, 0);
+ nullptr, 0);
}
HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData)
{
return FindFirstFileExW(lpFileName, FindExInfoStandard, lpFindFileData, FindExSearchNameMatch,
- NULL, 0);
+ nullptr, 0);
}
DWORD GetFullPathNameA(LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart)
{
DWORD dwStatus;
- WCHAR* lpFileNameW = NULL;
- WCHAR* lpBufferW = NULL;
- WCHAR* lpFilePartW = NULL;
+ WCHAR* lpFileNameW = nullptr;
+ WCHAR* lpBufferW = nullptr;
+ WCHAR* lpFilePartW = nullptr;
DWORD nBufferLengthW = nBufferLength * sizeof(WCHAR);
if (!lpFileName || (nBufferLength < 1))
return 0;
- lpFileNameW = ConvertUtf8ToWCharAlloc(lpFileName, NULL);
+ lpFileNameW = ConvertUtf8ToWCharAlloc(lpFileName, nullptr);
if (!lpFileNameW)
return 0;
@@ -1486,8 +1486,8 @@ HANDLE GetFileHandleForFileDescriptor(int fd)
#ifdef _WIN32
return (HANDLE)_get_osfhandle(fd);
#else /* _WIN32 */
- WINPR_FILE* pFile = NULL;
- FILE* fp = NULL;
+ WINPR_FILE* pFile = nullptr;
+ FILE* fp = nullptr;
int flags = 0;
/* Make sure it's a valid fd */
@@ -1506,7 +1506,7 @@ HANDLE GetFileHandleForFileDescriptor(int fd)
if (!fp)
return INVALID_HANDLE_VALUE;
- (void)setvbuf(fp, NULL, _IONBF, 0);
+ (void)setvbuf(fp, nullptr, _IONBF, 0);
// NOLINTNEXTLINE(clang-analyzer-unix.Stream)
pFile = FileHandle_New(fp);
@@ -1522,18 +1522,18 @@ FILE* winpr_fopen(const char* path, const char* mode)
#ifndef _WIN32
return fopen(path, mode);
#else
- LPWSTR lpPathW = NULL;
- LPWSTR lpModeW = NULL;
- FILE* result = NULL;
+ LPWSTR lpPathW = nullptr;
+ LPWSTR lpModeW = nullptr;
+ FILE* result = nullptr;
if (!path || !mode)
- return NULL;
+ return nullptr;
- lpPathW = ConvertUtf8ToWCharAlloc(path, NULL);
+ lpPathW = ConvertUtf8ToWCharAlloc(path, nullptr);
if (!lpPathW)
goto cleanup;
- lpModeW = ConvertUtf8ToWCharAlloc(mode, NULL);
+ lpModeW = ConvertUtf8ToWCharAlloc(mode, nullptr);
if (!lpModeW)
goto cleanup;
@@ -1549,7 +1549,7 @@ cleanup:
#if !defined(_UWP) && !defined(_WIN32)
DWORD GetLogicalDriveStringsW(DWORD nBufferLength, LPWSTR lpBuffer)
{
- char* buffer = NULL;
+ char* buffer = nullptr;
if (nBufferLength > 0)
{
buffer = calloc(nBufferLength, sizeof(char));
diff --git a/winpr/libwinpr/file/generic.c b/winpr/libwinpr/file/generic.c
index a62592492..750914209 100644
--- a/winpr/libwinpr/file/generic.c
+++ b/winpr/libwinpr/file/generic.c
@@ -188,7 +188,7 @@ static BOOL FindDataFromStat(const char* path, const struct stat* fileStat,
static void HandleCreatorsInit(void)
{
- WINPR_ASSERT(HandleCreators == NULL);
+ WINPR_ASSERT(HandleCreators == nullptr);
HandleCreators = ArrayList_New(TRUE);
if (!HandleCreators)
@@ -222,7 +222,7 @@ int InstallAioSignalHandler()
sigaddset(&action.sa_mask, SIGIO);
action.sa_flags = SA_SIGINFO;
action.sa_sigaction = (void*)&AioSignalHandler;
- sigaction(SIGIO, &action, NULL);
+ sigaction(SIGIO, &action, nullptr);
g_AioSignalHandlerInstalled = TRUE;
}
@@ -252,7 +252,7 @@ HANDLE winpr_CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareM
return INVALID_HANDLE_VALUE;
}
- if (HandleCreators == NULL)
+ if (HandleCreators == nullptr)
{
SetLastError(ERROR_DLL_INIT_FAILED);
return INVALID_HANDLE_VALUE;
@@ -282,10 +282,10 @@ HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
- HANDLE hdl = NULL;
+ HANDLE hdl = nullptr;
if (!lpFileName)
- return NULL;
- char* lpFileNameA = ConvertWCharToUtf8Alloc(lpFileName, NULL);
+ return nullptr;
+ char* lpFileNameA = ConvertWCharToUtf8Alloc(lpFileName, nullptr);
if (!lpFileNameA)
{
@@ -309,7 +309,7 @@ BOOL DeleteFileW(LPCWSTR lpFileName)
{
if (!lpFileName)
return FALSE;
- LPSTR lpFileNameA = ConvertWCharToUtf8Alloc(lpFileName, NULL);
+ LPSTR lpFileNameA = ConvertWCharToUtf8Alloc(lpFileName, nullptr);
BOOL rc = winpr_DeleteFile(lpFileNameA);
free(lpFileNameA);
return rc;
@@ -319,14 +319,14 @@ BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
/*
* from http://msdn.microsoft.com/en-us/library/windows/desktop/aa365467%28v=vs.85%29.aspx
- * lpNumberOfBytesRead can be NULL only when the lpOverlapped parameter is not NULL.
+ * lpNumberOfBytesRead can be nullptr only when the lpOverlapped parameter is not nullptr.
*/
if (!lpNumberOfBytesRead && !lpOverlapped)
@@ -349,7 +349,7 @@ BOOL ReadFileEx(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -371,7 +371,7 @@ BOOL ReadFileScatter(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], DWORD n
LPDWORD lpReserved, LPOVERLAPPED lpOverlapped)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -393,7 +393,7 @@ BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -415,7 +415,7 @@ BOOL WriteFileEx(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -437,7 +437,7 @@ BOOL WriteFileGather(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[],
DWORD nNumberOfBytesToWrite, LPDWORD lpReserved, LPOVERLAPPED lpOverlapped)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -458,7 +458,7 @@ BOOL WriteFileGather(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[],
BOOL FlushFileBuffers(HANDLE hFile)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -506,7 +506,7 @@ BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInf
BOOL ret = 0;
if (!lpFileName)
return FALSE;
- LPSTR lpCFileName = ConvertWCharToUtf8Alloc(lpFileName, NULL);
+ LPSTR lpCFileName = ConvertWCharToUtf8Alloc(lpFileName, nullptr);
if (!lpCFileName)
{
@@ -533,7 +533,7 @@ DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
DWORD ret = 0;
if (!lpFileName)
return FALSE;
- LPSTR lpCFileName = ConvertWCharToUtf8Alloc(lpFileName, NULL);
+ LPSTR lpCFileName = ConvertWCharToUtf8Alloc(lpFileName, nullptr);
if (!lpCFileName)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@@ -548,7 +548,7 @@ DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
BOOL GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -606,7 +606,7 @@ static const char* flagsToStr(char* buffer, size_t size, DWORD flags)
append(buffer, size, "FILE_ATTRIBUTE_VIRTUAL");
(void)_snprintf(strflags, sizeof(strflags), " [0x%08" PRIx32 "]", flags);
- winpr_str_append(strflags, buffer, size, NULL);
+ winpr_str_append(strflags, buffer, size, nullptr);
return buffer;
}
@@ -656,7 +656,7 @@ BOOL SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
if (!lpFileName)
return FALSE;
- char* lpCFileName = ConvertWCharToUtf8Alloc(lpFileName, NULL);
+ char* lpCFileName = ConvertWCharToUtf8Alloc(lpFileName, nullptr);
if (!lpCFileName)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@@ -671,7 +671,7 @@ BOOL SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
BOOL SetEndOfFile(HANDLE hFile)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -691,7 +691,7 @@ BOOL SetEndOfFile(HANDLE hFile)
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -712,7 +712,7 @@ DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveH
DWORD dwMoveMethod)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -734,7 +734,7 @@ BOOL SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEG
DWORD dwMoveMethod)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -756,7 +756,7 @@ BOOL LockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -778,7 +778,7 @@ BOOL LockFileEx(HANDLE hFile, DWORD dwFlags, DWORD dwReserved, DWORD nNumberOfBy
DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -800,7 +800,7 @@ BOOL UnlockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -822,7 +822,7 @@ BOOL UnlockFileEx(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLo
DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -844,7 +844,7 @@ BOOL WINAPI SetFileTime(HANDLE hFile, const FILETIME* lpCreationTime,
const FILETIME* lpLastAccessTime, const FILETIME* lpLastWriteTime)
{
ULONG Type = 0;
- WINPR_HANDLE* handle = NULL;
+ WINPR_HANDLE* handle = nullptr;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
@@ -878,7 +878,7 @@ static WIN32_FILE_SEARCH* file_search_new(const char* name, size_t namelen, cons
{
WIN32_FILE_SEARCH* pFileSearch = (WIN32_FILE_SEARCH*)calloc(1, sizeof(WIN32_FILE_SEARCH));
if (!pFileSearch)
- return NULL;
+ return nullptr;
WINPR_ASSERT(sizeof(file_search_magic) == sizeof(pFileSearch->magic));
memcpy(pFileSearch->magic, file_search_magic, sizeof(pFileSearch->magic));
@@ -909,7 +909,7 @@ static WIN32_FILE_SEARCH* file_search_new(const char* name, size_t namelen, cons
if (!pFileSearch->lpPath || !pFileSearch->lpPattern)
{
closedir(pFileSearch->pDir);
- pFileSearch->pDir = NULL;
+ pFileSearch->pDir = nullptr;
}
}
}
@@ -924,7 +924,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
FindClose(pFileSearch);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
static BOOL is_valid_file_search_handle(HANDLE handle)
@@ -941,7 +941,7 @@ static BOOL is_valid_file_search_handle(HANDLE handle)
static DWORD FileAttributesFromStat(const char* path, const struct stat* fileStat)
{
- char* lastSep = NULL;
+ char* lastSep = nullptr;
DWORD dwFileAttributes = 0;
if (S_ISDIR(fileStat->st_mode))
@@ -1001,7 +1001,7 @@ HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
const WIN32_FIND_DATAA empty = WINPR_C_ARRAY_INIT;
*lpFindFileData = empty;
- WIN32_FILE_SEARCH* pFileSearch = NULL;
+ WIN32_FILE_SEARCH* pFileSearch = nullptr;
size_t patternlen = 0;
const size_t flen = strlen(lpFileName);
const char sep = PathGetSeparatorA(PATH_STYLE_NATIVE);
@@ -1055,8 +1055,8 @@ static BOOL ConvertFindDataAToW(LPWIN32_FIND_DATAA lpFindFileDataA,
HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData)
{
- LPSTR utfFileName = NULL;
- HANDLE h = NULL;
+ LPSTR utfFileName = nullptr;
+ HANDLE h = nullptr;
if (!lpFileName)
return INVALID_HANDLE_VALUE;
@@ -1068,7 +1068,7 @@ HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData)
return INVALID_HANDLE_VALUE;
}
- utfFileName = ConvertWCharToUtf8Alloc(lpFileName, NULL);
+ utfFileName = ConvertWCharToUtf8Alloc(lpFileName, nullptr);
if (!utfFileName)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@@ -1129,9 +1129,9 @@ BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData)
return FALSE;
WIN32_FILE_SEARCH* pFileSearch = (WIN32_FILE_SEARCH*)hFindFile;
- struct dirent* pDirent = NULL;
+ struct dirent* pDirent = nullptr;
// NOLINTNEXTLINE(concurrency-mt-unsafe)
- while ((pDirent = readdir(pFileSearch->pDir)) != NULL)
+ while ((pDirent = readdir(pFileSearch->pDir)) != nullptr)
{
if (FilePatternMatchA(pDirent->d_name, pFileSearch->lpPattern))
{
@@ -1142,7 +1142,7 @@ BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData)
size_t pathlen = strlen(pFileSearch->lpPath);
char* fullpath = (char*)malloc(pathlen + namelen + 2);
- if (fullpath == NULL)
+ if (fullpath == nullptr)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
@@ -1215,7 +1215,7 @@ BOOL FindClose(HANDLE hFindFile)
if (!pFileSearch)
return FALSE;
- /* Since INVALID_HANDLE_VALUE != NULL the analyzer guesses that there
+ /* Since INVALID_HANDLE_VALUE != nullptr the analyzer guesses that there
* is a initialized HANDLE that is not freed properly.
* Disable this return to stop confusing the analyzer. */
#ifndef __clang_analyzer__
@@ -1244,7 +1244,7 @@ BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttrib
{
if (!lpPathName)
return FALSE;
- char* utfPathName = ConvertWCharToUtf8Alloc(lpPathName, NULL);
+ char* utfPathName = ConvertWCharToUtf8Alloc(lpPathName, nullptr);
BOOL ret = FALSE;
if (!utfPathName)
@@ -1268,7 +1268,7 @@ BOOL RemoveDirectoryW(LPCWSTR lpPathName)
{
if (!lpPathName)
return FALSE;
- char* utfPathName = ConvertWCharToUtf8Alloc(lpPathName, NULL);
+ char* utfPathName = ConvertWCharToUtf8Alloc(lpPathName, nullptr);
BOOL ret = FALSE;
if (!utfPathName)
@@ -1293,8 +1293,8 @@ BOOL MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, DWORD dwFlag
if (!lpExistingFileName || !lpNewFileName)
return FALSE;
- LPSTR lpCExistingFileName = ConvertWCharToUtf8Alloc(lpExistingFileName, NULL);
- LPSTR lpCNewFileName = ConvertWCharToUtf8Alloc(lpNewFileName, NULL);
+ LPSTR lpCExistingFileName = ConvertWCharToUtf8Alloc(lpExistingFileName, nullptr);
+ LPSTR lpCNewFileName = ConvertWCharToUtf8Alloc(lpNewFileName, nullptr);
BOOL ret = FALSE;
if (!lpCExistingFileName || !lpCNewFileName)
@@ -1345,7 +1345,7 @@ int UnixChangeFileMode(const char* filename, int flags)
return chmod(filename, fl);
#else
int rc;
- WCHAR* wfl = ConvertUtf8ToWCharAlloc(filename, NULL);
+ WCHAR* wfl = ConvertUtf8ToWCharAlloc(filename, nullptr);
if (!wfl)
return -1;
@@ -1365,9 +1365,9 @@ HANDLE winpr_CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareM
LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
- WCHAR* filename = ConvertUtf8ToWCharAlloc(lpFileName, NULL);
+ WCHAR* filename = ConvertUtf8ToWCharAlloc(lpFileName, nullptr);
if (!filename)
- return NULL;
+ return nullptr;
HANDLE hdl = CreateFileW(filename, dwDesiredAccess, dwShareMode, lpSecurityAttributes,
dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
diff --git a/winpr/libwinpr/file/namedPipeClient.c b/winpr/libwinpr/file/namedPipeClient.c
index 277c002dc..b9b4c2fd0 100644
--- a/winpr/libwinpr/file/namedPipeClient.c
+++ b/winpr/libwinpr/file/namedPipeClient.c
@@ -96,24 +96,24 @@ static HANDLE_OPS ops = {
NamedPipeClientIsHandled,
NamedPipeClientCloseHandle,
NamedPipeClientGetFd,
- NULL, /* CleanupHandle */
+ nullptr, /* CleanupHandle */
NamedPipeRead,
- NULL, /* FileReadEx */
- NULL, /* FileReadScatter */
+ nullptr, /* FileReadEx */
+ nullptr, /* FileReadScatter */
NamedPipeWrite,
- NULL, /* FileWriteEx */
- NULL, /* FileWriteGather */
- NULL, /* FileGetFileSize */
- NULL, /* FlushFileBuffers */
- NULL, /* FileSetEndOfFile */
- NULL, /* FileSetFilePointer */
- NULL, /* SetFilePointerEx */
- NULL, /* FileLockFile */
- NULL, /* FileLockFileEx */
- NULL, /* FileUnlockFile */
- NULL, /* FileUnlockFileEx */
- NULL, /* SetFileTime */
- NULL, /* FileGetFileInformationByHandle */
+ nullptr, /* FileWriteEx */
+ nullptr, /* FileWriteGather */
+ nullptr, /* FileGetFileSize */
+ nullptr, /* FlushFileBuffers */
+ nullptr, /* FileSetEndOfFile */
+ nullptr, /* FileSetFilePointer */
+ nullptr, /* SetFilePointerEx */
+ nullptr, /* FileLockFile */
+ nullptr, /* FileLockFileEx */
+ nullptr, /* FileUnlockFile */
+ nullptr, /* FileUnlockFileEx */
+ nullptr, /* SetFileTime */
+ nullptr, /* FileGetFileInformationByHandle */
};
static HANDLE
@@ -230,13 +230,13 @@ BOOL IsNamedPipeFileNameA(LPCSTR lpName)
char* GetNamedPipeNameWithoutPrefixA(LPCSTR lpName)
{
- char* lpFileName = NULL;
+ char* lpFileName = nullptr;
if (!lpName)
- return NULL;
+ return nullptr;
if (!IsNamedPipeFileNameA(lpName))
- return NULL;
+ return nullptr;
lpFileName = _strdup(&lpName[strnlen(NAMED_PIPE_PREFIX_PATH, sizeof(NAMED_PIPE_PREFIX_PATH))]);
return lpFileName;
@@ -244,12 +244,12 @@ char* GetNamedPipeNameWithoutPrefixA(LPCSTR lpName)
char* GetNamedPipeUnixDomainSocketBaseFilePathA(void)
{
- char* lpTempPath = NULL;
- char* lpPipePath = NULL;
+ char* lpTempPath = nullptr;
+ char* lpPipePath = nullptr;
lpTempPath = GetKnownPath(KNOWN_PATH_TEMP);
if (!lpTempPath)
- return NULL;
+ return nullptr;
lpPipePath = GetCombinedPath(lpTempPath, ".pipe");
free(lpTempPath);
@@ -258,9 +258,9 @@ char* GetNamedPipeUnixDomainSocketBaseFilePathA(void)
char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName)
{
- char* lpPipePath = NULL;
- char* lpFileName = NULL;
- char* lpFilePath = NULL;
+ char* lpPipePath = nullptr;
+ char* lpFileName = nullptr;
+ char* lpFilePath = nullptr;
lpPipePath = GetNamedPipeUnixDomainSocketBaseFilePathA();
lpFileName = GetNamedPipeNameWithoutPrefixA(lpName);
lpFilePath = GetCombinedPath(lpPipePath, lpFileName);
diff --git a/winpr/libwinpr/file/pattern.c b/winpr/libwinpr/file/pattern.c
index cb4d61806..09ed642a2 100644
--- a/winpr/libwinpr/file/pattern.c
+++ b/winpr/libwinpr/file/pattern.c
@@ -42,7 +42,7 @@
LPSTR FilePatternFindNextWildcardA(LPCSTR lpPattern, DWORD* pFlags)
{
- LPSTR lpWildcard = NULL;
+ LPSTR lpWildcard = nullptr;
*pFlags = 0;
lpWildcard = strpbrk(lpPattern, "*?~");
@@ -78,14 +78,14 @@ LPSTR FilePatternFindNextWildcardA(LPCSTR lpPattern, DWORD* pFlags)
}
}
- return NULL;
+ return nullptr;
}
static BOOL FilePatternMatchSubExpressionA(LPCSTR lpFileName, size_t cchFileName, LPCSTR lpX,
size_t cchX, LPCSTR lpY, size_t cchY, LPCSTR lpWildcard,
LPCSTR* ppMatchEnd)
{
- LPCSTR lpMatch = NULL;
+ LPCSTR lpMatch = nullptr;
if (!lpFileName)
return FALSE;
@@ -198,14 +198,14 @@ static BOOL FilePatternMatchSubExpressionA(LPCSTR lpFileName, size_t cchFileName
BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern)
{
BOOL match = 0;
- LPCSTR lpTail = NULL;
+ LPCSTR lpTail = nullptr;
size_t cchTail = 0;
size_t cchPattern = 0;
size_t cchFileName = 0;
DWORD dwFlags = 0;
DWORD dwNextFlags = 0;
- LPSTR lpWildcard = NULL;
- LPSTR lpNextWildcard = NULL;
+ LPSTR lpWildcard = nullptr;
+ LPSTR lpNextWildcard = nullptr;
/**
* Wild Card Matching
@@ -305,14 +305,14 @@ BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern)
if (lpWildcard)
{
- LPCSTR lpX = NULL;
- LPCSTR lpY = NULL;
+ LPCSTR lpX = nullptr;
+ LPCSTR lpY = nullptr;
size_t cchX = 0;
size_t cchY = 0;
- LPCSTR lpMatchEnd = NULL;
- LPCSTR lpSubPattern = NULL;
+ LPCSTR lpMatchEnd = nullptr;
+ LPCSTR lpSubPattern = nullptr;
size_t cchSubPattern = 0;
- LPCSTR lpSubFileName = NULL;
+ LPCSTR lpSubFileName = nullptr;
size_t cchSubFileName = 0;
size_t cchWildcard = 0;
size_t cchNextWildcard = 0;
diff --git a/winpr/libwinpr/file/test/TestFileCreateFile.c b/winpr/libwinpr/file/test/TestFileCreateFile.c
index 0e6289111..f94120268 100644
--- a/winpr/libwinpr/file/test/TestFileCreateFile.c
+++ b/winpr/libwinpr/file/test/TestFileCreateFile.c
@@ -9,13 +9,13 @@
int TestFileCreateFile(int argc, char* argv[])
{
- HANDLE handle = NULL;
+ HANDLE handle = nullptr;
HRESULT hr = 0;
DWORD written = 0;
const char buffer[] = "Some random text\r\njust want it done.";
char cmp[sizeof(buffer)];
char sname[8192];
- LPSTR name = NULL;
+ LPSTR name = nullptr;
int rc = 0;
SYSTEMTIME systemTime;
WINPR_UNUSED(argc);
@@ -38,8 +38,8 @@ int TestFileCreateFile(int argc, char* argv[])
if (FAILED(hr))
rc = -1;
- handle = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ handle = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL, nullptr);
if (!handle)
{
@@ -50,28 +50,28 @@ int TestFileCreateFile(int argc, char* argv[])
if (!winpr_PathFileExists(name))
rc = -1;
- if (!WriteFile(handle, buffer, sizeof(buffer), &written, NULL))
+ if (!WriteFile(handle, buffer, sizeof(buffer), &written, nullptr))
rc = -1;
if (written != sizeof(buffer))
rc = -1;
- written = SetFilePointer(handle, 5, NULL, FILE_BEGIN);
+ written = SetFilePointer(handle, 5, nullptr, FILE_BEGIN);
if (written != 5)
rc = -1;
- written = SetFilePointer(handle, 0, NULL, FILE_CURRENT);
+ written = SetFilePointer(handle, 0, nullptr, FILE_CURRENT);
if (written != 5)
rc = -1;
- written = SetFilePointer(handle, -5, NULL, FILE_CURRENT);
+ written = SetFilePointer(handle, -5, nullptr, FILE_CURRENT);
if (written != 0)
rc = -1;
- if (!ReadFile(handle, cmp, sizeof(cmp), &written, NULL))
+ if (!ReadFile(handle, cmp, sizeof(cmp), &written, nullptr))
rc = -1;
if (written != sizeof(cmp))
diff --git a/winpr/libwinpr/file/test/TestFileDeleteFile.c b/winpr/libwinpr/file/test/TestFileDeleteFile.c
index d1073a2b7..97e7d0137 100644
--- a/winpr/libwinpr/file/test/TestFileDeleteFile.c
+++ b/winpr/libwinpr/file/test/TestFileDeleteFile.c
@@ -28,7 +28,7 @@ int TestFileDeleteFile(int argc, char* argv[])
int fd = 0;
char validA[] = "/tmp/valid-test-file-XXXXXX";
char validW[] = "/tmp/valid-test-file-XXXXXX";
- WCHAR* validWW = NULL;
+ WCHAR* validWW = nullptr;
const char invalidA[] = "/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
WCHAR invalidW[sizeof(invalidA)] = WINPR_C_ARRAY_INIT;
@@ -57,7 +57,7 @@ int TestFileDeleteFile(int argc, char* argv[])
if (fd < 0)
return -1;
- validWW = ConvertUtf8NToWCharAlloc(validW, ARRAYSIZE(validW), NULL);
+ validWW = ConvertUtf8NToWCharAlloc(validW, ARRAYSIZE(validW), nullptr);
if (validWW)
rc = DeleteFileW(validWW);
free(validWW);
diff --git a/winpr/libwinpr/file/test/TestFileFindFirstFile.c b/winpr/libwinpr/file/test/TestFileFindFirstFile.c
index e7fcb66f5..dc82114ee 100644
--- a/winpr/libwinpr/file/test/TestFileFindFirstFile.c
+++ b/winpr/libwinpr/file/test/TestFileFindFirstFile.c
@@ -12,8 +12,8 @@ static const CHAR testFile1A[] = "TestFile1A";
static BOOL create_fileA(const char* FilePath)
{
- HANDLE hdl =
- CreateFileA(FilePath, GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hdl = CreateFileA(FilePath, GENERIC_ALL, 0, nullptr, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, nullptr);
if (hdl == INVALID_HANDLE_VALUE)
return FALSE;
(void)CloseHandle(hdl);
@@ -22,8 +22,8 @@ static BOOL create_fileA(const char* FilePath)
static BOOL create_fileW(const WCHAR* FilePath)
{
- HANDLE hdl =
- CreateFileW(FilePath, GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hdl = CreateFileW(FilePath, GENERIC_ALL, 0, nullptr, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, nullptr);
if (hdl == INVALID_HANDLE_VALUE)
return FALSE;
(void)CloseHandle(hdl);
@@ -56,7 +56,7 @@ static BOOL create_layout_directories(size_t level, size_t max_level, const char
CHAR FilePath[PATHCCH_MAX_CCH] = WINPR_C_ARRAY_INIT;
strncpy(FilePath, BasePath, ARRAYSIZE(FilePath));
PathCchConvertStyleA(FilePath, ARRAYSIZE(FilePath), PATH_STYLE_NATIVE);
- if (!winpr_PathMakePath(FilePath, NULL))
+ if (!winpr_PathMakePath(FilePath, nullptr))
return FALSE;
ArrayList_Append(files, FilePath);
@@ -270,7 +270,7 @@ fail:
WINPR_ATTR_FORMAT_ARG(1, 0)
static int printf1W(const char* WINPR_FORMAT_ARG fmt, const WCHAR* arg1)
{
- char* var1 = ConvertWCharToUtf8Alloc(arg1, NULL);
+ char* var1 = ConvertWCharToUtf8Alloc(arg1, nullptr);
const int rc = printf(fmt, var1);
free(var1);
return rc;
@@ -279,8 +279,8 @@ static int printf1W(const char* WINPR_FORMAT_ARG fmt, const WCHAR* arg1)
WINPR_ATTR_FORMAT_ARG(1, 0)
static int printf2W(const char* WINPR_FORMAT_ARG fmt, const WCHAR* arg1, const WCHAR* arg2)
{
- char* var1 = ConvertWCharToUtf8Alloc(arg1, NULL);
- char* var2 = ConvertWCharToUtf8Alloc(arg2, NULL);
+ char* var1 = ConvertWCharToUtf8Alloc(arg1, nullptr);
+ char* var2 = ConvertWCharToUtf8Alloc(arg2, nullptr);
const int rc = printf(fmt, var1, var2);
free(var1);
free(var2);
@@ -349,7 +349,7 @@ int TestFileFindFirstFile(int argc, char* argv[])
int rc1 = -1;
int rc2 = -1;
- if (winpr_PathMakePath(str, NULL))
+ if (winpr_PathMakePath(str, nullptr))
{
rc1 = TestFileFindFirstFileA(str);
rc2 = TestFileFindFirstFileW(str);
diff --git a/winpr/libwinpr/file/test/TestFileFindNextFile.c b/winpr/libwinpr/file/test/TestFileFindNextFile.c
index f8205dbc6..21cc74899 100644
--- a/winpr/libwinpr/file/test/TestFileFindNextFile.c
+++ b/winpr/libwinpr/file/test/TestFileFindNextFile.c
@@ -11,11 +11,11 @@ static TCHAR testDirectory2File2[] = _T("TestDirectory2File2");
int TestFileFindNextFile(int argc, char* argv[])
{
- char* str = NULL;
+ char* str = nullptr;
size_t length = 0;
BOOL status = 0;
- HANDLE hFind = NULL;
- LPTSTR BasePath = NULL;
+ HANDLE hFind = nullptr;
+ LPTSTR BasePath = nullptr;
WIN32_FIND_DATA FindData;
TCHAR FilePath[PATHCCH_MAX_CCH] = WINPR_C_ARRAY_INIT;
WINPR_UNUSED(argc);
diff --git a/winpr/libwinpr/file/test/TestFileGetStdHandle.c b/winpr/libwinpr/file/test/TestFileGetStdHandle.c
index b28cabc16..ee7e7b53d 100644
--- a/winpr/libwinpr/file/test/TestFileGetStdHandle.c
+++ b/winpr/libwinpr/file/test/TestFileGetStdHandle.c
@@ -26,7 +26,7 @@
int TestFileGetStdHandle(int argc, char* argv[])
{
- HANDLE so = NULL;
+ HANDLE so = nullptr;
const char buf[] = "happy happy";
DWORD bytesWritten = 0;
WINPR_UNUSED(argc);
@@ -37,7 +37,7 @@ int TestFileGetStdHandle(int argc, char* argv[])
(void)fprintf(stderr, "GetStdHandle failed ;(\n");
return -1;
}
- WriteFile(so, buf, strnlen(buf, sizeof(buf)), &bytesWritten, NULL);
+ WriteFile(so, buf, strnlen(buf, sizeof(buf)), &bytesWritten, nullptr);
if (bytesWritten != strnlen(buf, sizeof(buf)))
{
(void)fprintf(stderr, "write failed\n");
diff --git a/winpr/libwinpr/file/test/TestFileWriteFile.c b/winpr/libwinpr/file/test/TestFileWriteFile.c
index 39391cf04..4e6d65d45 100644
--- a/winpr/libwinpr/file/test/TestFileWriteFile.c
+++ b/winpr/libwinpr/file/test/TestFileWriteFile.c
@@ -8,15 +8,15 @@ static const char* get_dir(char* filename, size_t len)
{
#if defined(WIN32)
if ((len == 0) || (strnlen_s(filename, len) == len))
- return NULL;
+ return nullptr;
char* ptr = strrchr(filename, '\\');
#else
if ((len == 0) || (strnlen(filename, len) == len))
- return NULL;
+ return nullptr;
char* ptr = strrchr(filename, '/');
#endif
if (!ptr)
- return NULL;
+ return nullptr;
*ptr = '\0';
return filename;
}
@@ -47,13 +47,13 @@ static BOOL test_write(const char* filename, const char* data, size_t datalen)
WINPR_ASSERT(data);
WINPR_ASSERT(datalen > 0);
- HANDLE hdl =
- CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hdl = CreateFileA(filename, GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL,
+ nullptr);
if (!hdl || (hdl == INVALID_HANDLE_VALUE))
goto fail;
DWORD written = 0;
- if (!WriteFile(hdl, data, datalen, &written, NULL))
+ if (!WriteFile(hdl, data, datalen, &written, nullptr))
goto fail;
if (written != datalen)
goto fail;
@@ -76,13 +76,13 @@ static BOOL test_read(const char* filename, const char* data, size_t datalen)
WINPR_ASSERT(datalen > 0);
char* cmp = calloc(datalen + 1, sizeof(char));
- HANDLE hdl =
- CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hdl = CreateFileA(filename, GENERIC_READ, 0, nullptr, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, nullptr);
if (!hdl || (hdl == INVALID_HANDLE_VALUE) || !cmp)
goto fail;
DWORD read = 0;
- if (!ReadFile(hdl, cmp, datalen, &read, NULL))
+ if (!ReadFile(hdl, cmp, datalen, &read, nullptr))
goto fail;
if (read != datalen)
goto fail;
diff --git a/winpr/libwinpr/file/test/TestSetFileAttributes.c b/winpr/libwinpr/file/test/TestSetFileAttributes.c
index 84a5b12f5..f11276acb 100644
--- a/winpr/libwinpr/file/test/TestSetFileAttributes.c
+++ b/winpr/libwinpr/file/test/TestSetFileAttributes.c
@@ -35,7 +35,7 @@ static const DWORD allflags[] = {
static BOOL test_SetFileAttributesA(void)
{
BOOL rc = FALSE;
- HANDLE handle = NULL;
+ HANDLE handle = nullptr;
const DWORD flags[] = { 0, FILE_ATTRIBUTE_READONLY };
char* name = GetKnownSubPath(KNOWN_PATH_TEMP, "afsklhjwe4oq5iu432oijrlkejadlkhjaklhfdkahfd");
if (!name)
@@ -44,7 +44,7 @@ static BOOL test_SetFileAttributesA(void)
for (size_t x = 0; x < ARRAYSIZE(allflags); x++)
{
const DWORD flag = allflags[x];
- const BOOL brc = SetFileAttributesA(NULL, flag);
+ const BOOL brc = SetFileAttributesA(nullptr, flag);
if (brc)
goto fail;
@@ -53,8 +53,8 @@ static BOOL test_SetFileAttributesA(void)
goto fail;
}
- handle = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ handle = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL, nullptr);
if (handle == INVALID_HANDLE_VALUE)
goto fail;
(void)CloseHandle(handle);
@@ -86,21 +86,21 @@ fail:
static BOOL test_SetFileAttributesW(void)
{
BOOL rc = FALSE;
- WCHAR* name = NULL;
- HANDLE handle = NULL;
+ WCHAR* name = nullptr;
+ HANDLE handle = nullptr;
const DWORD flags[] = { 0, FILE_ATTRIBUTE_READONLY };
char* base = GetKnownSubPath(KNOWN_PATH_TEMP, "afsklhjwe4oq5iu432oijrlkejadlkhjaklhfdkahfd");
if (!base)
goto fail;
- name = ConvertUtf8ToWCharAlloc(base, NULL);
+ name = ConvertUtf8ToWCharAlloc(base, nullptr);
if (!name)
goto fail;
for (size_t x = 0; x < ARRAYSIZE(allflags); x++)
{
const DWORD flag = allflags[x];
- const BOOL brc = SetFileAttributesW(NULL, flag);
+ const BOOL brc = SetFileAttributesW(nullptr, flag);
if (brc)
goto fail;
@@ -109,8 +109,8 @@ static BOOL test_SetFileAttributesW(void)
goto fail;
}
- handle = CreateFileW(name, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ handle = CreateFileW(name, GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL, nullptr);
if (handle == INVALID_HANDLE_VALUE)
goto fail;
(void)CloseHandle(handle);
diff --git a/winpr/libwinpr/handle/handle.c b/winpr/libwinpr/handle/handle.c
index 9ace858cf..2343712fc 100644
--- a/winpr/libwinpr/handle/handle.c
+++ b/winpr/libwinpr/handle/handle.c
@@ -43,7 +43,7 @@
BOOL CloseHandle(HANDLE hObject)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
+ WINPR_HANDLE* Object = nullptr;
if (!winpr_Handle_GetInfo(hObject, &Type, &Object))
return FALSE;
diff --git a/winpr/libwinpr/handle/handle.h b/winpr/libwinpr/handle/handle.h
index fd2cb6267..36087407d 100644
--- a/winpr/libwinpr/handle/handle.h
+++ b/winpr/libwinpr/handle/handle.h
@@ -143,9 +143,9 @@ static inline void WINPR_HANDLE_SET_TYPE_AND_MODE(void* _handle, ULONG _type, UL
static inline BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, WINPR_HANDLE** pObject)
{
- WINPR_HANDLE* wHandle = NULL;
+ WINPR_HANDLE* wHandle = nullptr;
- if (handle == NULL)
+ if (handle == nullptr)
return FALSE;
/* INVALID_HANDLE_VALUE is an invalid value for every handle, but it
@@ -165,7 +165,7 @@ static inline BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, WINPR_HANDL
static inline int winpr_Handle_getFd(HANDLE handle)
{
- WINPR_HANDLE* hdl = NULL;
+ WINPR_HANDLE* hdl = nullptr;
ULONG type = 0;
if (!winpr_Handle_GetInfo(handle, &type, &hdl))
@@ -179,7 +179,7 @@ static inline int winpr_Handle_getFd(HANDLE handle)
static inline DWORD winpr_Handle_cleanup(HANDLE handle)
{
- WINPR_HANDLE* hdl = NULL;
+ WINPR_HANDLE* hdl = nullptr;
ULONG type = 0;
if (!winpr_Handle_GetInfo(handle, &type, &hdl))
diff --git a/winpr/libwinpr/handle/nonehandle.c b/winpr/libwinpr/handle/nonehandle.c
index 1fe54b8af..d24f96618 100644
--- a/winpr/libwinpr/handle/nonehandle.c
+++ b/winpr/libwinpr/handle/nonehandle.c
@@ -49,31 +49,31 @@ static int NoneHandleGetFd(HANDLE handle)
static HANDLE_OPS ops = { NoneHandleIsHandle,
NoneHandleCloseHandle,
NoneHandleGetFd,
- NULL, /* CleanupHandle */
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL };
+ nullptr, /* CleanupHandle */
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr };
HANDLE CreateNoneHandle(void)
{
WINPR_NONE_HANDLE* none = (WINPR_NONE_HANDLE*)calloc(1, sizeof(WINPR_NONE_HANDLE));
if (!none)
- return NULL;
+ return nullptr;
none->common.ops = &ops;
return (HANDLE)none;
diff --git a/winpr/libwinpr/input/keycode.c b/winpr/libwinpr/input/keycode.c
index 15acf4ec3..4e6518c13 100644
--- a/winpr/libwinpr/input/keycode.c
+++ b/winpr/libwinpr/input/keycode.c
@@ -880,7 +880,7 @@ DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, WINPR_KEYCODE_TYPE type)
DWORD GetKeycodeFromVirtualKeyCode(DWORD keycode, WINPR_KEYCODE_TYPE type)
{
- DWORD* targetArray = NULL;
+ DWORD* targetArray = nullptr;
size_t targetSize = 0;
switch (type)
diff --git a/winpr/libwinpr/input/virtualkey.c b/winpr/libwinpr/input/virtualkey.c
index 2f1ef0884..7cebca415 100644
--- a/winpr/libwinpr/input/virtualkey.c
+++ b/winpr/libwinpr/input/virtualkey.c
@@ -34,29 +34,29 @@ typedef struct
} VIRTUAL_KEY_CODE;
static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = {
- { 0, NULL },
+ { 0, nullptr },
{ VK_LBUTTON, "VK_LBUTTON" },
{ VK_RBUTTON, "VK_RBUTTON" },
{ VK_CANCEL, "VK_CANCEL" },
{ VK_MBUTTON, "VK_MBUTTON" },
{ VK_XBUTTON1, "VK_XBUTTON1" },
{ VK_XBUTTON2, "VK_XBUTTON2" },
- { 0, NULL },
+ { 0, nullptr },
{ VK_BACK, "VK_BACK" },
{ VK_TAB, "VK_TAB" },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_CLEAR, "VK_CLEAR" },
{ VK_RETURN, "VK_RETURN" },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_SHIFT, "VK_SHIFT" },
{ VK_CONTROL, "VK_CONTROL" },
{ VK_MENU, "VK_MENU" },
{ VK_PAUSE, "VK_PAUSE" },
{ VK_CAPITAL, "VK_CAPITAL" },
{ VK_KANA, "VK_KANA" }, /* also VK_HANGUL */
- { 0, NULL },
+ { 0, nullptr },
{ VK_JUNJA, "VK_JUNJA" },
{ VK_FINAL, "VK_FINAL" },
{ VK_KANJI, "VK_KANJI" }, /* also VK_HANJA */
@@ -92,13 +92,13 @@ static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = {
{ VK_KEY_7, "VK_KEY_7" },
{ VK_KEY_8, "VK_KEY_8" },
{ VK_KEY_9, "VK_KEY_9" },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_KEY_A, "VK_KEY_A" },
{ VK_KEY_B, "VK_KEY_B" },
{ VK_KEY_C, "VK_KEY_C" },
@@ -128,7 +128,7 @@ static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = {
{ VK_LWIN, "VK_LWIN" },
{ VK_RWIN, "VK_RWIN" },
{ VK_APPS, "VK_APPS" },
- { 0, NULL },
+ { 0, nullptr },
{ VK_SLEEP, "VK_SLEEP" },
{ VK_NUMPAD0, "VK_NUMPAD0" },
{ VK_NUMPAD1, "VK_NUMPAD1" },
@@ -170,30 +170,30 @@ static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = {
{ VK_F22, "VK_F22" },
{ VK_F23, "VK_F23" },
{ VK_F24, "VK_F24" },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_NUMLOCK, "VK_NUMLOCK" },
{ VK_SCROLL, "VK_SCROLL" },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_LSHIFT, "VK_LSHIFT" },
{ VK_RSHIFT, "VK_RSHIFT" },
{ VK_LCONTROL, "VK_LCONTROL" },
@@ -218,8 +218,8 @@ static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = {
{ VK_MEDIA_SELECT, "VK_MEDIA_SELECT" },
{ VK_LAUNCH_APP1, "VK_LAUNCH_APP1" },
{ VK_LAUNCH_APP2, "VK_LAUNCH_APP2" },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_OEM_1, "VK_OEM_1" },
{ VK_OEM_PLUS, "VK_OEM_PLUS" },
{ VK_OEM_COMMA, "VK_OEM_COMMA" },
@@ -229,57 +229,57 @@ static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = {
{ VK_OEM_3, "VK_OEM_3" },
{ VK_ABNT_C1, "VK_ABNT_C1" },
{ VK_ABNT_C2, "VK_ABNT_C2" },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_OEM_4, "VK_OEM_4" },
{ VK_OEM_5, "VK_OEM_5" },
{ VK_OEM_6, "VK_OEM_6" },
{ VK_OEM_7, "VK_OEM_7" },
{ VK_OEM_8, "VK_OEM_8" },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_OEM_102, "VK_OEM_102" },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_PROCESSKEY, "VK_PROCESSKEY" },
- { 0, NULL },
+ { 0, nullptr },
{ VK_PACKET, "VK_PACKET" },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
- { 0, NULL },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
+ { 0, nullptr },
{ VK_ATTN, "VK_ATTN" },
{ VK_CRSEL, "VK_CRSEL" },
{ VK_EXSEL, "VK_EXSEL" },
@@ -289,7 +289,7 @@ static const VIRTUAL_KEY_CODE VIRTUAL_KEY_CODE_TABLE[256] = {
{ VK_NONAME, "VK_NONAME" },
{ VK_PA1, "VK_PA1" },
{ VK_OEM_CLEAR, "VK_OEM_CLEAR" },
- { 0, NULL }
+ { 0, nullptr }
};
typedef struct
@@ -424,7 +424,7 @@ static XKB_KEYNAME XKB_KEYNAME_TABLE[] = {
const char* GetVirtualKeyName(DWORD vkcode)
{
- const char* vkname = NULL;
+ const char* vkname = nullptr;
if (vkcode < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE))
vkname = VIRTUAL_KEY_CODE_TABLE[vkcode].name;
diff --git a/winpr/libwinpr/interlocked/interlocked.c b/winpr/libwinpr/interlocked/interlocked.c
index 5ce08f82f..fb31e1db4 100644
--- a/winpr/libwinpr/interlocked/interlocked.c
+++ b/winpr/libwinpr/interlocked/interlocked.c
@@ -85,11 +85,11 @@ WINPR_PSLIST_ENTRY InterlockedPushEntrySList(WINPR_PSLIST_HEADER ListHead,
newHeader.s.Depth = old.s.Depth + 1;
newHeader.s.Sequence = old.s.Sequence + 1;
if (old.Alignment > INT64_MAX)
- return NULL;
+ return nullptr;
if (newHeader.Alignment > INT64_MAX)
- return NULL;
+ return nullptr;
if (ListHead->Alignment > INT64_MAX)
- return NULL;
+ return nullptr;
} while (InterlockedCompareExchange64((LONGLONG*)&ListHead->Alignment,
(LONGLONG)newHeader.Alignment,
(LONGLONG)old.Alignment) != (LONGLONG)old.Alignment);
@@ -113,14 +113,14 @@ WINPR_PSLIST_ENTRY InterlockedPushListSListEx(WINPR_ATTR_UNUSED WINPR_PSLIST_HEA
#else
#endif
- return NULL;
+ return nullptr;
}
WINPR_PSLIST_ENTRY InterlockedPopEntrySList(WINPR_PSLIST_HEADER ListHead)
{
WINPR_SLIST_HEADER old = WINPR_C_ARRAY_INIT;
WINPR_SLIST_HEADER newHeader = WINPR_C_ARRAY_INIT;
- WINPR_PSLIST_ENTRY entry = NULL;
+ WINPR_PSLIST_ENTRY entry = nullptr;
WINPR_ASSERT(ListHead);
@@ -132,7 +132,7 @@ WINPR_PSLIST_ENTRY InterlockedPopEntrySList(WINPR_PSLIST_HEADER ListHead)
entry = (PSLIST_ENTRY)(((ULONG_PTR)old.HeaderX64.NextEntry) << 4);
if (!entry)
- return NULL;
+ return nullptr;
newHeader.HeaderX64.NextEntry = ((ULONG_PTR)entry->Next) >> 4;
newHeader.HeaderX64.Depth = old.HeaderX64.Depth - 1;
@@ -153,18 +153,18 @@ WINPR_PSLIST_ENTRY InterlockedPopEntrySList(WINPR_PSLIST_HEADER ListHead)
entry = old.s.Next.Next;
if (!entry)
- return NULL;
+ return nullptr;
newHeader.s.Next.Next = entry->Next;
newHeader.s.Depth = old.s.Depth - 1;
newHeader.s.Sequence = old.s.Sequence + 1;
if (old.Alignment > INT64_MAX)
- return NULL;
+ return nullptr;
if (newHeader.Alignment > INT64_MAX)
- return NULL;
+ return nullptr;
if (ListHead->Alignment > INT64_MAX)
- return NULL;
+ return nullptr;
} while (InterlockedCompareExchange64((LONGLONG*)&ListHead->Alignment,
(LONGLONG)newHeader.Alignment,
(LONGLONG)old.Alignment) != (LONGLONG)old.Alignment);
@@ -179,7 +179,7 @@ WINPR_PSLIST_ENTRY InterlockedFlushSList(WINPR_PSLIST_HEADER ListHead)
WINPR_ASSERT(ListHead);
if (!QueryDepthSList(ListHead))
- return NULL;
+ return nullptr;
#ifdef _WIN64
newHeader).Alignment = 0;
@@ -209,11 +209,11 @@ WINPR_PSLIST_ENTRY InterlockedFlushSList(WINPR_PSLIST_HEADER ListHead)
newHeader.s.Sequence = old.s.Sequence + 1;
if (old.Alignment > INT64_MAX)
- return NULL;
+ return nullptr;
if (newHeader.Alignment > INT64_MAX)
- return NULL;
+ return nullptr;
if (ListHead->Alignment > INT64_MAX)
- return NULL;
+ return nullptr;
} while (InterlockedCompareExchange64((LONGLONG*)&ListHead->Alignment,
(LONGLONG)newHeader.Alignment,
(LONGLONG)old.Alignment) != (LONGLONG)old.Alignment);
@@ -326,18 +326,19 @@ PVOID InterlockedCompareExchangePointer(PVOID volatile* Destination, PVOID Excha
#elif defined(_WIN32) && defined(WINPR_INTERLOCKED_COMPARE_EXCHANGE64)
-static volatile HANDLE mutex = NULL;
+static volatile HANDLE mutex = nullptr;
BOOL static_mutex_lock(volatile HANDLE* static_mutex)
{
- if (*static_mutex == NULL)
+ if (*static_mutex == nullptr)
{
HANDLE handle;
- if (!(handle = CreateMutex(NULL, FALSE, NULL)))
+ if (!(handle = CreateMutex(nullptr, FALSE, nullptr)))
return FALSE;
- if (InterlockedCompareExchangePointer((PVOID*)static_mutex, (PVOID)handle, NULL) != NULL)
+ if (InterlockedCompareExchangePointer((PVOID*)static_mutex, (PVOID)handle, nullptr) !=
+ nullptr)
(void)CloseHandle(handle);
}
@@ -531,7 +532,7 @@ WINPR_PSINGLE_LIST_ENTRY PopEntryList(WINPR_PSINGLE_LIST_ENTRY ListHead)
WINPR_ASSERT(ListHead);
WINPR_PSINGLE_LIST_ENTRY FirstEntry = ListHead->Next;
- if (FirstEntry != NULL)
+ if (FirstEntry != nullptr)
ListHead->Next = FirstEntry->Next;
return FirstEntry;
diff --git a/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c b/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c
index 1d00d7a00..1c98d5187 100644
--- a/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c
+++ b/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c
@@ -5,12 +5,12 @@
int TestInterlockedAccess(int argc, char* argv[])
{
- LONG* Addend = NULL;
- LONG* Target = NULL;
+ LONG* Addend = nullptr;
+ LONG* Target = nullptr;
LONG oldValue = 0;
- LONG* Destination = NULL;
+ LONG* Destination = nullptr;
LONGLONG oldValue64 = 0;
- LONGLONG* Destination64 = NULL;
+ LONGLONG* Destination64 = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
/* InterlockedIncrement */
diff --git a/winpr/libwinpr/interlocked/test/TestInterlockedDList.c b/winpr/libwinpr/interlocked/test/TestInterlockedDList.c
index f49e37d9c..d8fd66995 100644
--- a/winpr/libwinpr/interlocked/test/TestInterlockedDList.c
+++ b/winpr/libwinpr/interlocked/test/TestInterlockedDList.c
@@ -13,9 +13,9 @@ typedef struct
int TestInterlockedDList(int argc, char* argv[])
{
ULONG Count = 0;
- PLIST_ITEM pListItem = NULL;
- WINPR_PLIST_ENTRY pListHead = NULL;
- WINPR_PLIST_ENTRY pListEntry = NULL;
+ PLIST_ITEM pListItem = nullptr;
+ WINPR_PLIST_ENTRY pListHead = nullptr;
+ WINPR_PLIST_ENTRY pListEntry = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
pListHead = (WINPR_PLIST_ENTRY)winpr_aligned_malloc(sizeof(WINPR_LIST_ENTRY),
diff --git a/winpr/libwinpr/io/device.c b/winpr/libwinpr/io/device.c
index 05839d6d0..5c826b2ee 100644
--- a/winpr/libwinpr/io/device.c
+++ b/winpr/libwinpr/io/device.c
@@ -64,13 +64,13 @@
static char* GetDeviceFileNameWithoutPrefixA(LPCSTR lpName)
{
- char* lpFileName = NULL;
+ char* lpFileName = nullptr;
if (!lpName)
- return NULL;
+ return nullptr;
if (strncmp(lpName, DEVICE_FILE_PREFIX_PATH, sizeof(DEVICE_FILE_PREFIX_PATH) - 1) != 0)
- return NULL;
+ return nullptr;
lpFileName =
_strdup(&lpName[strnlen(DEVICE_FILE_PREFIX_PATH, sizeof(DEVICE_FILE_PREFIX_PATH))]);
@@ -79,12 +79,12 @@ static char* GetDeviceFileNameWithoutPrefixA(LPCSTR lpName)
static char* GetDeviceFileUnixDomainSocketBaseFilePathA(void)
{
- char* lpTempPath = NULL;
- char* lpPipePath = NULL;
+ char* lpTempPath = nullptr;
+ char* lpPipePath = nullptr;
lpTempPath = GetKnownPath(KNOWN_PATH_TEMP);
if (!lpTempPath)
- return NULL;
+ return nullptr;
lpPipePath = GetCombinedPath(lpTempPath, ".device");
free(lpTempPath);
@@ -93,20 +93,20 @@ static char* GetDeviceFileUnixDomainSocketBaseFilePathA(void)
static char* GetDeviceFileUnixDomainSocketFilePathA(LPCSTR lpName)
{
- char* lpPipePath = NULL;
- char* lpFileName = NULL;
- char* lpFilePath = NULL;
+ char* lpPipePath = nullptr;
+ char* lpFileName = nullptr;
+ char* lpFilePath = nullptr;
lpPipePath = GetDeviceFileUnixDomainSocketBaseFilePathA();
if (!lpPipePath)
- return NULL;
+ return nullptr;
lpFileName = GetDeviceFileNameWithoutPrefixA(lpName);
if (!lpFileName)
{
free(lpPipePath);
- return NULL;
+ return nullptr;
}
lpFilePath = GetCombinedPath(lpPipePath, lpFileName);
@@ -127,8 +127,8 @@ NTSTATUS _IoCreateDeviceEx(WINPR_ATTR_UNUSED PDRIVER_OBJECT_EX DriverObject,
WINPR_ATTR_UNUSED BOOLEAN Exclusive, PDEVICE_OBJECT_EX* DeviceObject)
{
int status = 0;
- char* DeviceBasePath = NULL;
- DEVICE_OBJECT_EX* pDeviceObjectEx = NULL;
+ char* DeviceBasePath = nullptr;
+ DEVICE_OBJECT_EX* pDeviceObjectEx = nullptr;
DeviceBasePath = GetDeviceFileUnixDomainSocketBaseFilePathA();
if (!DeviceBasePath)
@@ -150,7 +150,7 @@ NTSTATUS _IoCreateDeviceEx(WINPR_ATTR_UNUSED PDRIVER_OBJECT_EX DriverObject,
return STATUS_NO_MEMORY;
pDeviceObjectEx->DeviceName =
- ConvertWCharNToUtf8Alloc(DeviceName->Buffer, DeviceName->Length / sizeof(WCHAR), NULL);
+ ConvertWCharNToUtf8Alloc(DeviceName->Buffer, DeviceName->Length / sizeof(WCHAR), nullptr);
if (!pDeviceObjectEx->DeviceName)
{
free(pDeviceObjectEx);
@@ -220,7 +220,7 @@ NTSTATUS _IoCreateDeviceEx(WINPR_ATTR_UNUSED PDRIVER_OBJECT_EX DriverObject,
VOID _IoDeleteDeviceEx(PDEVICE_OBJECT_EX DeviceObject)
{
- DEVICE_OBJECT_EX* pDeviceObjectEx = NULL;
+ DEVICE_OBJECT_EX* pDeviceObjectEx = nullptr;
pDeviceObjectEx = (DEVICE_OBJECT_EX*)DeviceObject;
if (!pDeviceObjectEx)
diff --git a/winpr/libwinpr/io/io.c b/winpr/libwinpr/io/io.c
index 22399bee7..0e3b85ce7 100644
--- a/winpr/libwinpr/io/io.c
+++ b/winpr/libwinpr/io/io.c
@@ -87,7 +87,7 @@ HANDLE CreateIoCompletionPort(WINPR_ATTR_UNUSED HANDLE FileHandle,
{
WLog_ERR(TAG, "Not implemented");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return NULL;
+ return nullptr;
}
BOOL GetQueuedCompletionStatus(WINPR_ATTR_UNUSED HANDLE CompletionPort,
@@ -176,7 +176,7 @@ HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort,
{
WLog_ERR(TAG, "Not implemented");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return NULL;
+ return nullptr;
}
BOOL GetQueuedCompletionStatus(HANDLE CompletionPort, LPDWORD lpNumberOfBytesTransferred,
@@ -207,7 +207,7 @@ BOOL PostQueuedCompletionStatus(HANDLE CompletionPort, DWORD dwNumberOfBytesTran
BOOL CancelIo(HANDLE hFile)
{
- return CancelIoEx(hFile, NULL);
+ return CancelIoEx(hFile, nullptr);
}
BOOL CancelSynchronousIo(HANDLE hThread)
diff --git a/winpr/libwinpr/library/library.c b/winpr/libwinpr/library/library.c
index dfbb93a67..c39a29164 100644
--- a/winpr/libwinpr/library/library.c
+++ b/winpr/libwinpr/library/library.c
@@ -88,7 +88,7 @@ DLL_DIRECTORY_COOKIE AddDllDirectory(WINPR_ATTR_UNUSED PCWSTR NewDirectory)
/* TODO: Implement */
WLog_ERR(TAG, "not implemented");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return NULL;
+ return nullptr;
}
BOOL RemoveDllDirectory(WINPR_ATTR_UNUSED DLL_DIRECTORY_COOKIE Cookie)
@@ -110,16 +110,16 @@ BOOL SetDefaultDllDirectories(WINPR_ATTR_UNUSED DWORD DirectoryFlags)
HMODULE LoadLibraryA(LPCSTR lpLibFileName)
{
if (!lpLibFileName)
- return NULL;
+ return nullptr;
#if defined(_UWP)
int status;
- HMODULE hModule = NULL;
- WCHAR* filenameW = NULL;
+ HMODULE hModule = nullptr;
+ WCHAR* filenameW = nullptr;
- filenameW = ConvertUtf8ToWCharAlloc(lpLibFileName, NULL);
+ filenameW = ConvertUtf8ToWCharAlloc(lpLibFileName, nullptr);
if (filenameW)
- return NULL;
+ return nullptr;
hModule = LoadLibraryW(filenameW);
free(filenameW);
@@ -132,7 +132,7 @@ HMODULE LoadLibraryA(LPCSTR lpLibFileName)
// NOLINTNEXTLINE(concurrency-mt-unsafe)
const char* err = dlerror();
WLog_ERR(TAG, "failed with %s", err);
- return NULL;
+ return nullptr;
}
return library;
@@ -144,10 +144,10 @@ HMODULE LoadLibraryW(LPCWSTR lpLibFileName)
#if defined(_UWP)
return LoadPackagedLibrary(lpLibFileName, 0);
#else
- char* name = NULL;
+ char* name = nullptr;
if (lpLibFileName)
- name = ConvertWCharToUtf8Alloc(lpLibFileName, NULL);
+ name = ConvertWCharToUtf8Alloc(lpLibFileName, nullptr);
HMODULE module = LoadLibraryA(name);
free(name);
@@ -161,7 +161,7 @@ HMODULE LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
WLog_WARN(TAG, "does not support dwFlags 0x%08" PRIx32, dwFlags);
if (hFile)
- WLog_WARN(TAG, "does not support hFile != NULL");
+ WLog_WARN(TAG, "does not support hFile != nullptr");
return LoadLibraryA(lpLibFileName);
}
@@ -172,7 +172,7 @@ HMODULE LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
WLog_WARN(TAG, "does not support dwFlags 0x%08" PRIx32, dwFlags);
if (hFile)
- WLog_WARN(TAG, "does not support hFile != NULL");
+ WLog_WARN(TAG, "does not support hFile != nullptr");
return LoadLibraryW(lpLibFileName);
}
@@ -183,14 +183,14 @@ HMODULE LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
{
- FARPROC proc = NULL;
+ FARPROC proc = nullptr;
proc = dlsym(hModule, lpProcName);
- if (proc == NULL)
+ if (proc == nullptr)
{
// NOLINTNEXTLINE(concurrency-mt-unsafe)
WLog_ERR(TAG, "GetProcAddress: could not find procedure %s: %s", lpProcName, dlerror());
- return (FARPROC)NULL;
+ return (FARPROC) nullptr;
}
return proc;
@@ -211,9 +211,9 @@ HMODULE GetModuleHandleA(LPCSTR lpModuleName)
HMODULE GetModuleHandleW(LPCWSTR lpModuleName)
{
- char* name = NULL;
+ char* name = nullptr;
if (lpModuleName)
- name = ConvertWCharToUtf8Alloc(lpModuleName, NULL);
+ name = ConvertWCharToUtf8Alloc(lpModuleName, nullptr);
HANDLE hdl = GetModuleHandleA(name);
free(name);
return hdl;
@@ -308,7 +308,7 @@ DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
size_t cb = nSize;
{
- const int rc = sysctl(mib, ARRAYSIZE(mib), NULL, &cb, NULL, 0);
+ const int rc = sysctl(mib, ARRAYSIZE(mib), nullptr, &cb, nullptr, 0);
if (rc != 0)
{
SetLastError(ERROR_INTERNAL_ERROR);
@@ -325,7 +325,7 @@ DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
{
size_t cb2 = cb;
- const int rc = sysctl(mib, ARRAYSIZE(mib), fullname, &cb2, NULL, 0);
+ const int rc = sysctl(mib, ARRAYSIZE(mib), fullname, &cb2, nullptr, 0);
if ((rc != 0) || (cb2 != cb))
{
SetLastError(ERROR_INTERNAL_ERROR);
@@ -392,11 +392,11 @@ DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
HMODULE LoadLibraryX(LPCSTR lpLibFileName)
{
#if defined(_WIN32)
- HMODULE hm = NULL;
- WCHAR* wstr = NULL;
+ HMODULE hm = nullptr;
+ WCHAR* wstr = nullptr;
if (lpLibFileName)
- wstr = ConvertUtf8ToWCharAlloc(lpLibFileName, NULL);
+ wstr = ConvertUtf8ToWCharAlloc(lpLibFileName, nullptr);
hm = LoadLibraryW(wstr);
free(wstr);
@@ -409,10 +409,10 @@ HMODULE LoadLibraryX(LPCSTR lpLibFileName)
HMODULE LoadLibraryExX(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
{
if (!lpLibFileName)
- return NULL;
+ return nullptr;
#if defined(_WIN32)
- HMODULE hm = NULL;
- WCHAR* wstr = ConvertUtf8ToWCharAlloc(lpLibFileName, NULL);
+ HMODULE hm = nullptr;
+ WCHAR* wstr = ConvertUtf8ToWCharAlloc(lpLibFileName, nullptr);
if (wstr)
hm = LoadLibraryExW(wstr, hFile, dwFlags);
free(wstr);
diff --git a/winpr/libwinpr/library/test/TestLibraryGetModuleFileName.c b/winpr/libwinpr/library/test/TestLibraryGetModuleFileName.c
index 714522a0d..1ddfc5ea4 100644
--- a/winpr/libwinpr/library/test/TestLibraryGetModuleFileName.c
+++ b/winpr/libwinpr/library/test/TestLibraryGetModuleFileName.c
@@ -14,7 +14,7 @@ int TestLibraryGetModuleFileName(int argc, char* argv[])
WINPR_UNUSED(argv);
/* Test insufficient buffer size behaviour */
SetLastError(ERROR_SUCCESS);
- len = GetModuleFileNameA(NULL, ModuleFileName, 2);
+ len = GetModuleFileNameA(nullptr, ModuleFileName, 2);
if (len != 2)
{
printf("%s: GetModuleFileNameA unexpectedly returned %" PRIu32 " instead of 2\n", __func__,
@@ -31,7 +31,7 @@ int TestLibraryGetModuleFileName(int argc, char* argv[])
/* Test with real/sufficient buffer size */
SetLastError(ERROR_SUCCESS);
- len = GetModuleFileNameA(NULL, ModuleFileName, sizeof(ModuleFileName));
+ len = GetModuleFileNameA(nullptr, ModuleFileName, sizeof(ModuleFileName));
if (len == 0)
{
printf("%s: GetModuleFileNameA failed with error 0x%08" PRIX32 "\n", __func__,
diff --git a/winpr/libwinpr/library/test/TestLibraryGetProcAddress.c b/winpr/libwinpr/library/test/TestLibraryGetProcAddress.c
index e9ecee66b..a3ec6bf0b 100644
--- a/winpr/libwinpr/library/test/TestLibraryGetProcAddress.c
+++ b/winpr/libwinpr/library/test/TestLibraryGetProcAddress.c
@@ -14,15 +14,15 @@ int TestLibraryGetProcAddress(int argc, char* argv[])
int a = 0;
int b = 0;
int c = 0;
- HINSTANCE library = NULL;
- TEST_AB_FN pFunctionA = NULL;
- TEST_AB_FN pFunctionB = NULL;
- LPCSTR SharedLibraryExtension = NULL;
+ HINSTANCE library = nullptr;
+ TEST_AB_FN pFunctionA = nullptr;
+ TEST_AB_FN pFunctionB = nullptr;
+ LPCSTR SharedLibraryExtension = nullptr;
CHAR LibraryPath[PATHCCH_MAX_CCH] = WINPR_C_ARRAY_INIT;
- PCHAR p = NULL;
+ PCHAR p = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- if (!GetModuleFileNameA(NULL, LibraryPath, PATHCCH_MAX_CCH))
+ if (!GetModuleFileNameA(nullptr, LibraryPath, PATHCCH_MAX_CCH))
{
const UINT32 err = GetLastError();
const HRESULT herr = HRESULT_FROM_WIN32(err);
diff --git a/winpr/libwinpr/library/test/TestLibraryLoadLibrary.c b/winpr/libwinpr/library/test/TestLibraryLoadLibrary.c
index 1464e3319..2cb10007b 100644
--- a/winpr/libwinpr/library/test/TestLibraryLoadLibrary.c
+++ b/winpr/libwinpr/library/test/TestLibraryLoadLibrary.c
@@ -9,13 +9,13 @@
int TestLibraryLoadLibrary(int argc, char* argv[])
{
- HINSTANCE library = NULL;
- LPCSTR SharedLibraryExtension = NULL;
+ HINSTANCE library = nullptr;
+ LPCSTR SharedLibraryExtension = nullptr;
CHAR LibraryPath[PATHCCH_MAX_CCH] = WINPR_C_ARRAY_INIT;
- PCHAR p = NULL;
+ PCHAR p = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- if (!GetModuleFileNameA(NULL, LibraryPath, PATHCCH_MAX_CCH))
+ if (!GetModuleFileNameA(nullptr, LibraryPath, PATHCCH_MAX_CCH))
{
const UINT32 err = GetLastError();
const HRESULT herr = HRESULT_FROM_WIN32(err);
diff --git a/winpr/libwinpr/memory/memory.c b/winpr/libwinpr/memory/memory.c
index 9ded9dc84..601b78b7e 100644
--- a/winpr/libwinpr/memory/memory.c
+++ b/winpr/libwinpr/memory/memory.c
@@ -86,10 +86,10 @@ HANDLE CreateFileMappingA(WINPR_ATTR_UNUSED HANDLE hFile,
WLog_ERR("TODO", "TODO: Implement");
if (hFile != INVALID_HANDLE_VALUE)
{
- return NULL; /* not yet implemented */
+ return nullptr; /* not yet implemented */
}
- return NULL;
+ return nullptr;
}
HANDLE CreateFileMappingW(WINPR_ATTR_UNUSED HANDLE hFile,
@@ -100,21 +100,21 @@ HANDLE CreateFileMappingW(WINPR_ATTR_UNUSED HANDLE hFile,
WINPR_ATTR_UNUSED LPCWSTR lpName)
{
WLog_ERR("TODO", "TODO: Implement");
- return NULL;
+ return nullptr;
}
HANDLE OpenFileMappingA(WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
WINPR_ATTR_UNUSED BOOL bInheritHandle, WINPR_ATTR_UNUSED LPCSTR lpName)
{
WLog_ERR("TODO", "TODO: Implement");
- return NULL;
+ return nullptr;
}
HANDLE OpenFileMappingW(WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
WINPR_ATTR_UNUSED BOOL bInheritHandle, WINPR_ATTR_UNUSED LPCWSTR lpName)
{
WLog_ERR("TODO", "TODO: Implement");
- return NULL;
+ return nullptr;
}
LPVOID MapViewOfFile(WINPR_ATTR_UNUSED HANDLE hFileMappingObject,
@@ -124,7 +124,7 @@ LPVOID MapViewOfFile(WINPR_ATTR_UNUSED HANDLE hFileMappingObject,
WINPR_ATTR_UNUSED size_t dwNumberOfBytesToMap)
{
WLog_ERR("TODO", "TODO: Implement");
- return NULL;
+ return nullptr;
}
LPVOID MapViewOfFileEx(WINPR_ATTR_UNUSED HANDLE hFileMappingObject,
@@ -135,7 +135,7 @@ LPVOID MapViewOfFileEx(WINPR_ATTR_UNUSED HANDLE hFileMappingObject,
WINPR_ATTR_UNUSED LPVOID lpBaseAddress)
{
WLog_ERR("TODO", "TODO: Implement");
- return NULL;
+ return nullptr;
}
BOOL FlushViewOfFile(WINPR_ATTR_UNUSED LPCVOID lpBaseAddress,
diff --git a/winpr/libwinpr/ncrypt/ncrypt.c b/winpr/libwinpr/ncrypt/ncrypt.c
index 38a88ebb8..649b24ba1 100644
--- a/winpr/libwinpr/ncrypt/ncrypt.c
+++ b/winpr/libwinpr/ncrypt/ncrypt.c
@@ -36,7 +36,7 @@ SECURITY_STATUS checkNCryptHandle(NCRYPT_HANDLE handle, NCryptHandleType matchTy
{
if (!handle)
{
- WLog_VRB(TAG, "invalid handle 'NULL'");
+ WLog_VRB(TAG, "invalid handle 'nullptr'");
return ERROR_INVALID_PARAMETER;
}
@@ -81,7 +81,7 @@ void* ncrypt_new_handle(NCryptHandleType kind, size_t len, NCryptGetPropertyFn g
{
NCryptBaseHandle* ret = calloc(1, len);
if (!ret)
- return NULL;
+ return nullptr;
memcpy(ret->magic, NCRYPT_MAGIC, sizeof(ret->magic));
ret->type = kind;
@@ -97,7 +97,7 @@ SECURITY_STATUS winpr_NCryptDefault_dtor(NCRYPT_HANDLE handle)
{
memset(h->magic, 0, sizeof(h->magic));
h->type = WINPR_NCRYPT_INVALID;
- h->releaseFn = NULL;
+ h->releaseFn = nullptr;
free(h);
}
return ERROR_SUCCESS;
@@ -107,16 +107,16 @@ SECURITY_STATUS NCryptEnumStorageProviders(DWORD* wProviderCount,
NCryptProviderName** ppProviderList,
WINPR_ATTR_UNUSED DWORD dwFlags)
{
- NCryptProviderName* ret = NULL;
+ NCryptProviderName* ret = nullptr;
size_t stringAllocSize = 0;
#ifdef WITH_PKCS11
- LPWSTR strPtr = NULL;
+ LPWSTR strPtr = nullptr;
static const WCHAR emptyComment[1] = WINPR_C_ARRAY_INIT;
size_t copyAmount = 0;
#endif
*wProviderCount = 0;
- *ppProviderList = NULL;
+ *ppProviderList = nullptr;
#ifdef WITH_PKCS11
*wProviderCount += 1;
@@ -152,7 +152,7 @@ SECURITY_STATUS NCryptEnumStorageProviders(DWORD* wProviderCount,
SECURITY_STATUS NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE* phProvider, LPCWSTR pszProviderName,
DWORD dwFlags)
{
- return winpr_NCryptOpenStorageProviderEx(phProvider, pszProviderName, dwFlags, NULL);
+ return winpr_NCryptOpenStorageProviderEx(phProvider, pszProviderName, dwFlags, nullptr);
}
SECURITY_STATUS winpr_NCryptOpenStorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
@@ -228,7 +228,7 @@ SECURITY_STATUS NCryptGetProperty(NCRYPT_HANDLE hObject, LPCWSTR pszProperty, PB
DWORD cbOutput, DWORD* pcbResult, DWORD dwFlags)
{
NCryptKeyGetPropertyEnum property = NCRYPT_PROPERTY_UNKNOWN;
- NCryptBaseHandle* base = NULL;
+ NCryptBaseHandle* base = nullptr;
if (!hObject)
return ERROR_INVALID_PARAMETER;
@@ -246,7 +246,7 @@ SECURITY_STATUS NCryptGetProperty(NCRYPT_HANDLE hObject, LPCWSTR pszProperty, PB
SECURITY_STATUS NCryptFreeObject(NCRYPT_HANDLE hObject)
{
- NCryptBaseHandle* base = NULL;
+ NCryptBaseHandle* base = nullptr;
SECURITY_STATUS ret = checkNCryptHandle(hObject, WINPR_NCRYPT_INVALID);
if (ret != ERROR_SUCCESS)
return ret;
@@ -358,6 +358,6 @@ const char* winpr_NCryptGetModulePath(NCRYPT_PROV_HANDLE phProvider)
#if defined(WITH_PKCS11)
return NCryptGetModulePath(phProvider);
#else
- return NULL;
+ return nullptr;
#endif
}
diff --git a/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c b/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c
index 04523fe6f..6267a6a56 100644
--- a/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c
+++ b/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c
@@ -119,7 +119,7 @@ static SECURITY_STATUS NCryptP11StorageProvider_dtor(NCRYPT_HANDLE handle)
if (provider)
{
if (provider->p11 && provider->p11->C_Finalize)
- rv = provider->p11->C_Finalize(NULL);
+ rv = provider->p11->C_Finalize(nullptr);
if (rv != CKR_OK)
WLog_WARN(TAG, "C_Finalize failed with %s [0x%08lx]", CK_RV_error_string(rv), rv);
@@ -363,7 +363,7 @@ static void log_(const char* tag, const char* msg, CK_RV rv, CK_ULONG index, CK_
const char* file, const char* fkt, size_t line)
{
const DWORD log_level = WLOG_ERROR;
- static wLog* log_cached_ptr = NULL;
+ static wLog* log_cached_ptr = nullptr;
if (!log_cached_ptr)
log_cached_ptr = WLog_Get(tag);
if (!WLog_IsLevelActive(log_cached_ptr, log_level))
@@ -386,7 +386,7 @@ static SECURITY_STATUS collect_keys(NCryptP11ProviderHandle* provider, P11EnumKe
state->nKeys = 0;
for (CK_ULONG i = 0; i < state->nslots; i++)
{
- CK_SESSION_HANDLE session = (CK_SESSION_HANDLE)NULL;
+ CK_SESSION_HANDLE session = 0;
CK_SLOT_INFO slotInfo = WINPR_C_ARRAY_INIT;
CK_TOKEN_INFO tokenInfo = WINPR_C_ARRAY_INIT;
@@ -421,7 +421,7 @@ static SECURITY_STATUS collect_keys(NCryptP11ProviderHandle* provider, P11EnumKe
}
WINPR_ASSERT(p11->C_OpenSession);
- rv = p11->C_OpenSession(state->slots[i], CKF_SERIAL_SESSION, NULL, NULL, &session);
+ rv = p11->C_OpenSession(state->slots[i], CKF_SERIAL_SESSION, nullptr, nullptr, &session);
if (rv != CKR_OK)
{
WLog_ERR(TAG, "unable to openSession for slot #%lu(%lu), session=%p rv=%s", i,
@@ -494,7 +494,7 @@ static SECURITY_STATUS collect_keys(NCryptP11ProviderHandle* provider, P11EnumKe
static BOOL convertKeyType(CK_KEY_TYPE k, LPWSTR dest, DWORD len, DWORD* outlen)
{
- const WCHAR* r = NULL;
+ const WCHAR* r = nullptr;
size_t retLen = 0;
#define ALGO_CASE(V, S) \
@@ -565,7 +565,7 @@ static void wprintKeyName(LPWSTR str, CK_SLOT_ID slotId, CK_BYTE* id, CK_ULONG i
{
char asciiName[128] = WINPR_C_ARRAY_INIT;
char* ptr = asciiName;
- const CK_BYTE* bytePtr = NULL;
+ const CK_BYTE* bytePtr = nullptr;
*ptr = '\\';
ptr++;
@@ -639,7 +639,7 @@ static SECURITY_STATUS parseKeyName(LPCWSTR pszKeyName, CK_SLOT_ID* slotId, CK_B
CK_ULONG* idLen)
{
char asciiKeyName[128] = WINPR_C_ARRAY_INIT;
- char* pos = NULL;
+ char* pos = nullptr;
if (ConvertWCharToUtf8(pszKeyName, asciiKeyName, ARRAYSIZE(asciiKeyName)) < 0)
return NTE_BAD_KEY;
@@ -658,7 +658,7 @@ static SECURITY_STATUS parseKeyName(LPCWSTR pszKeyName, CK_SLOT_ID* slotId, CK_B
if (parseHex(&asciiKeyName[1], pos, (CK_BYTE*)slotId) != sizeof(CK_SLOT_ID))
return NTE_BAD_KEY;
- *idLen = parseHex(pos + 1, NULL, id);
+ *idLen = parseHex(pos + 1, nullptr, id);
if (!*idLen)
return NTE_BAD_KEY;
@@ -673,9 +673,9 @@ static SECURITY_STATUS NCryptP11EnumKeys(NCRYPT_PROV_HANDLE hProvider, LPCWSTR p
P11EnumKeysState* state = (P11EnumKeysState*)*ppEnumState;
CK_RV rv = WINPR_C_ARRAY_INIT;
CK_SLOT_ID currentSlot = WINPR_C_ARRAY_INIT;
- CK_SESSION_HANDLE currentSession = (CK_SESSION_HANDLE)NULL;
+ CK_SESSION_HANDLE currentSession = 0;
char slotFilterBuffer[65] = WINPR_C_ARRAY_INIT;
- char* slotFilter = NULL;
+ char* slotFilter = nullptr;
size_t slotFilterLen = 0;
SECURITY_STATUS ret = checkNCryptHandle((NCRYPT_HANDLE)hProvider, WINPR_NCRYPT_PROVIDER);
@@ -724,7 +724,7 @@ static SECURITY_STATUS NCryptP11EnumKeys(NCRYPT_PROV_HANDLE hProvider, LPCWSTR p
return NTE_NO_MEMORY;
WINPR_ASSERT(provider->p11->C_GetSlotList);
- rv = provider->p11->C_GetSlotList(CK_TRUE, NULL, &state->nslots);
+ rv = provider->p11->C_GetSlotList(CK_TRUE, nullptr, &state->nslots);
if (rv != CKR_OK)
{
free(state);
@@ -757,7 +757,7 @@ static SECURITY_STATUS NCryptP11EnumKeys(NCRYPT_PROV_HANDLE hProvider, LPCWSTR p
for (; state->keyIndex < state->nKeys; state->keyIndex++)
{
- NCryptKeyName* keyName = NULL;
+ NCryptKeyName* keyName = nullptr;
NCryptKeyEnum* key = &state->keys[state->keyIndex];
CK_OBJECT_CLASS oclass = CKO_CERTIFICATE;
CK_CERTIFICATE_TYPE ctype = CKC_X_509;
@@ -782,11 +782,11 @@ static SECURITY_STATUS NCryptP11EnumKeys(NCRYPT_PROV_HANDLE hProvider, LPCWSTR p
if (rv != CKR_OK)
WLog_WARN(TAG, "C_CloseSession failed with %s [0x%08lx]",
CK_RV_error_string(rv), rv);
- currentSession = (CK_SESSION_HANDLE)NULL;
+ currentSession = 0;
}
WINPR_ASSERT(provider->p11->C_OpenSession);
- rv = provider->p11->C_OpenSession(key->slotId, CKF_SERIAL_SESSION, NULL, NULL,
+ rv = provider->p11->C_OpenSession(key->slotId, CKF_SERIAL_SESSION, nullptr, nullptr,
¤tSession);
if (rv != CKR_OK)
{
@@ -825,7 +825,7 @@ static SECURITY_STATUS NCryptP11EnumKeys(NCRYPT_PROV_HANDLE hProvider, LPCWSTR p
(key->idLen * 2ull) + 1ull) *
sizeof(WCHAR);
- convertKeyType(key->keyType, NULL, 0, &algoSz);
+ convertKeyType(key->keyType, nullptr, 0, &algoSz);
KEYNAME_SZ += (1ULL + algoSz) * sizeof(WCHAR);
keyName = calloc(1, sizeof(*keyName) + KEYNAME_SZ);
@@ -840,7 +840,7 @@ static SECURITY_STATUS NCryptP11EnumKeys(NCRYPT_PROV_HANDLE hProvider, LPCWSTR p
wprintKeyName(keyName->pszName, key->slotId, key->id, key->idLen);
keyName->pszAlgid = keyName->pszName + _wcslen(keyName->pszName) + 1;
- convertKeyType(key->keyType, keyName->pszAlgid, algoSz + 1, NULL);
+ convertKeyType(key->keyType, keyName->pszAlgid, algoSz + 1, nullptr);
}
cleanup_FindObjects:
@@ -865,12 +865,12 @@ static SECURITY_STATUS get_piv_container_name(NCryptP11KeyHandle* key, const BYT
BYTE* output, size_t output_len)
{
CK_SLOT_INFO slot_info = WINPR_C_ARRAY_INIT;
- CK_FUNCTION_LIST_PTR p11 = NULL;
- WCHAR* reader = NULL;
+ CK_FUNCTION_LIST_PTR p11 = nullptr;
+ WCHAR* reader = nullptr;
SCARDCONTEXT context = 0;
SCARDHANDLE card = 0;
DWORD proto = 0;
- const SCARD_IO_REQUEST* pci = NULL;
+ const SCARD_IO_REQUEST* pci = nullptr;
BYTE buf[258] = WINPR_C_ARRAY_INIT;
char container_name[PIV_CONTAINER_NAME_LEN + 1] = WINPR_C_ARRAY_INIT;
DWORD buf_len = 0;
@@ -879,7 +879,7 @@ static SECURITY_STATUS get_piv_container_name(NCryptP11KeyHandle* key, const BYT
WinPrAsn1Decoder dec2 = WinPrAsn1Decoder_init();
size_t len = 0;
BYTE tag = 0;
- BYTE* p = NULL;
+ BYTE* p = nullptr;
wStream s = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(key);
@@ -896,13 +896,13 @@ static SECURITY_STATUS get_piv_container_name(NCryptP11KeyHandle* key, const BYT
fix_padded_string((char*)slot_info.slotDescription, sizeof(slot_info.slotDescription));
reader = ConvertUtf8NToWCharAlloc((char*)slot_info.slotDescription,
- ARRAYSIZE(slot_info.slotDescription), NULL);
+ ARRAYSIZE(slot_info.slotDescription), nullptr);
ret = NTE_NO_MEMORY;
if (!reader)
goto out;
ret = NTE_BAD_KEY;
- if (SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, &context) != SCARD_S_SUCCESS)
+ if (SCardEstablishContext(SCARD_SCOPE_USER, nullptr, nullptr, &context) != SCARD_S_SUCCESS)
goto out;
if (SCardConnectW(context, reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_Tx, &card, &proto) !=
@@ -911,14 +911,14 @@ static SECURITY_STATUS get_piv_container_name(NCryptP11KeyHandle* key, const BYT
pci = (proto == SCARD_PROTOCOL_T0) ? SCARD_PCI_T0 : SCARD_PCI_T1;
buf_len = sizeof(buf);
- if (SCardTransmit(card, pci, APDU_PIV_SELECT_AID, sizeof(APDU_PIV_SELECT_AID), NULL, buf,
+ if (SCardTransmit(card, pci, APDU_PIV_SELECT_AID, sizeof(APDU_PIV_SELECT_AID), nullptr, buf,
&buf_len) != SCARD_S_SUCCESS)
goto out;
if ((buf[buf_len - 2] != 0x90 || buf[buf_len - 1] != 0) && buf[buf_len - 2] != 0x61)
goto out;
buf_len = sizeof(buf);
- if (SCardTransmit(card, pci, APDU_PIV_GET_CHUID, sizeof(APDU_PIV_GET_CHUID), NULL, buf,
+ if (SCardTransmit(card, pci, APDU_PIV_GET_CHUID, sizeof(APDU_PIV_GET_CHUID), nullptr, buf,
&buf_len) != SCARD_S_SUCCESS)
goto out;
if ((buf[buf_len - 2] != 0x90 || buf[buf_len - 1] != 0) && buf[buf_len - 2] != 0x61)
@@ -993,7 +993,7 @@ static SECURITY_STATUS NCryptP11KeyGetProperties(NCryptP11KeyHandle* keyHandle,
CK_SESSION_HANDLE session = 0;
CK_OBJECT_HANDLE objectHandle = 0;
CK_ULONG objectCount = 0;
- NCryptP11ProviderHandle* provider = NULL;
+ NCryptP11ProviderHandle* provider = nullptr;
CK_OBJECT_CLASS oclass = CKO_CERTIFICATE;
CK_CERTIFICATE_TYPE ctype = CKC_X_509;
CK_ATTRIBUTE certificateFilter[] = { { CKA_CLASS, &oclass, sizeof(oclass) },
@@ -1069,7 +1069,8 @@ static SECURITY_STATUS NCryptP11KeyGetProperties(NCryptP11KeyHandle* keyHandle,
}
WINPR_ASSERT(provider->p11->C_OpenSession);
- rv = provider->p11->C_OpenSession(keyHandle->slotId, CKF_SERIAL_SESSION, NULL, NULL, &session);
+ rv = provider->p11->C_OpenSession(keyHandle->slotId, CKF_SERIAL_SESSION, nullptr, nullptr,
+ &session);
if (rv != CKR_OK)
{
WLog_ERR(TAG, "error opening session on slot %lu", keyHandle->slotId);
@@ -1121,8 +1122,8 @@ static SECURITY_STATUS NCryptP11KeyGetProperties(NCryptP11KeyHandle* keyHandle,
}
case NCRYPT_PROPERTY_NAME:
{
- CK_ATTRIBUTE attr = { CKA_LABEL, NULL, 0 };
- char* label = NULL;
+ CK_ATTRIBUTE attr = { CKA_LABEL, nullptr, 0 };
+ char* label = nullptr;
WINPR_ASSERT(provider->p11->C_GetAttributeValue);
rv = provider->p11->C_GetAttributeValue(session, objectHandle, &attr, 1);
@@ -1216,7 +1217,7 @@ static SECURITY_STATUS NCryptP11OpenKey(NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY
CK_SLOT_ID slotId = 0;
CK_BYTE keyCertId[64] = WINPR_C_ARRAY_INIT;
CK_ULONG keyCertIdLen = 0;
- NCryptP11KeyHandle* keyHandle = NULL;
+ NCryptP11KeyHandle* keyHandle = nullptr;
ret = parseKeyName(pszKeyName, &slotId, keyCertId, &keyCertIdLen);
if (ret != ERROR_SUCCESS)
@@ -1240,7 +1241,7 @@ static SECURITY_STATUS initialize_pkcs11(HANDLE handle,
NCRYPT_PROV_HANDLE* phProvider)
{
SECURITY_STATUS status = ERROR_SUCCESS;
- NCryptP11ProviderHandle* ret = NULL;
+ NCryptP11ProviderHandle* ret = nullptr;
CK_RV rv = 0;
WINPR_ASSERT(c_get_function_list);
@@ -1264,7 +1265,7 @@ static SECURITY_STATUS initialize_pkcs11(HANDLE handle,
WINPR_ASSERT(ret->p11);
WINPR_ASSERT(ret->p11->C_Initialize);
- rv = ret->p11->C_Initialize(NULL);
+ rv = ret->p11->C_Initialize(nullptr);
if (rv != CKR_OK)
{
status = NTE_PROVIDER_DLL_FAIL;
@@ -1284,7 +1285,7 @@ SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
WINPR_ATTR_UNUSED DWORD dwFlags, LPCSTR* modulePaths)
{
SECURITY_STATUS status = ERROR_INVALID_PARAMETER;
- LPCSTR defaultPaths[] = { "p11-kit-proxy.so", "opensc-pkcs11.so", NULL };
+ LPCSTR defaultPaths[] = { "p11-kit-proxy.so", "opensc-pkcs11.so", nullptr };
if (!phProvider)
return ERROR_INVALID_PARAMETER;
@@ -1297,7 +1298,7 @@ SECURITY_STATUS NCryptOpenP11StorageProviderEx(NCRYPT_PROV_HANDLE* phProvider,
const char* modulePath = *modulePaths++;
HANDLE library = LoadLibrary(modulePath);
typedef CK_RV (*c_get_function_list_t)(CK_FUNCTION_LIST_PTR_PTR);
- NCryptP11ProviderHandle* provider = NULL;
+ NCryptP11ProviderHandle* provider = nullptr;
WLog_DBG(TAG, "Trying pkcs11 module '%s'", modulePath);
if (!library)
diff --git a/winpr/libwinpr/ncrypt/pkcs11-headers/pkcs11.h b/winpr/libwinpr/ncrypt/pkcs11-headers/pkcs11.h
index 81695a6ee..86c5b4c25 100644
--- a/winpr/libwinpr/ncrypt/pkcs11-headers/pkcs11.h
+++ b/winpr/libwinpr/ncrypt/pkcs11-headers/pkcs11.h
@@ -24,7 +24,11 @@ typedef CK_UTF8CHAR * CK_UTF8CHAR_PTR;
typedef CK_ULONG * CK_ULONG_PTR;
/* Basic defines */
+#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202003L)) || defined(__cplusplus)
+#define NULL_PTR nullptr
+#else
#define NULL_PTR ((void *)0)
+#endif
typedef void * CK_VOID_PTR;
typedef void ** CK_VOID_PTR_PTR;
diff --git a/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c b/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c
index 03756ee74..7e871ae0c 100644
--- a/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c
+++ b/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c
@@ -28,7 +28,7 @@ int TestNCryptProviders(int argc, char* argv[])
{
SECURITY_STATUS status = 0;
DWORD nproviders = 0;
- NCryptProviderName* providers = NULL;
+ NCryptProviderName* providers = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
diff --git a/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c b/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c
index 858519c90..e97911c25 100644
--- a/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c
+++ b/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c
@@ -35,7 +35,7 @@ static void crypto_print_name(const BYTE* b, DWORD sz)
if (!bio)
return;
- X509* x509 = d2i_X509_bio(bio, NULL);
+ X509* x509 = d2i_X509_bio(bio, nullptr);
if (!x509)
goto bio_release;
@@ -62,7 +62,7 @@ int TestNCryptSmartcard(int argc, char* argv[])
{
int rc = -1;
DWORD providerCount = 0;
- NCryptProviderName* names = NULL;
+ NCryptProviderName* names = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
@@ -76,9 +76,9 @@ int TestNCryptSmartcard(int argc, char* argv[])
const NCryptProviderName* name = &names[j];
NCRYPT_PROV_HANDLE provider = 0;
char providerNameStr[256] = WINPR_C_ARRAY_INIT;
- PVOID enumState = NULL;
+ PVOID enumState = nullptr;
size_t i = 0;
- NCryptKeyName* keyName = NULL;
+ NCryptKeyName* keyName = nullptr;
if (ConvertWCharToUtf8(name->pszName, providerNameStr, ARRAYSIZE(providerNameStr)) < 0)
continue;
@@ -88,7 +88,7 @@ int TestNCryptSmartcard(int argc, char* argv[])
if (status != ERROR_SUCCESS)
continue;
- while ((status = NCryptEnumKeys(provider, NULL, &keyName, &enumState,
+ while ((status = NCryptEnumKeys(provider, nullptr, &keyName, &enumState,
NCRYPT_SILENT_FLAG)) == ERROR_SUCCESS)
{
NCRYPT_KEY_HANDLE phKey = 0;
@@ -96,7 +96,7 @@ int TestNCryptSmartcard(int argc, char* argv[])
DWORD cbOutput = 0;
char keyNameStr[256] = WINPR_C_ARRAY_INIT;
WCHAR reader[1024] = WINPR_C_ARRAY_INIT;
- PBYTE certBytes = NULL;
+ PBYTE certBytes = nullptr;
if (ConvertWCharToUtf8(keyName->pszName, keyNameStr, ARRAYSIZE(keyNameStr)) < 0)
continue;
@@ -121,8 +121,8 @@ int TestNCryptSmartcard(int argc, char* argv[])
}
cbOutput = 0;
- status =
- NCryptGetProperty(phKey, NCRYPT_CERTIFICATE_PROPERTY, NULL, 0, &cbOutput, dwFlags);
+ status = NCryptGetProperty(phKey, NCRYPT_CERTIFICATE_PROPERTY, nullptr, 0, &cbOutput,
+ dwFlags);
if (status != ERROR_SUCCESS)
{
WLog_ERR(TAG, "unable to retrieve certificate len for key '%s'", keyNameStr);
diff --git a/winpr/libwinpr/nt/nt.c b/winpr/libwinpr/nt/nt.c
index d9bea2f1d..4973544fb 100644
--- a/winpr/libwinpr/nt/nt.c
+++ b/winpr/libwinpr/nt/nt.c
@@ -48,11 +48,11 @@ static void sTebInitOnce(void)
PTEB NtCurrentTeb(void)
{
- PTEB teb = NULL;
+ PTEB teb = nullptr;
if (pthread_once(&sTebOnceControl, sTebInitOnce) == 0)
{
- if ((teb = pthread_getspecific(sTebKey)) == NULL)
+ if ((teb = pthread_getspecific(sTebKey)) == nullptr)
{
teb = calloc(1, sizeof(TEB));
if (teb)
diff --git a/winpr/libwinpr/nt/ntstatus.c b/winpr/libwinpr/nt/ntstatus.c
index cb593da2e..464864bdd 100644
--- a/winpr/libwinpr/nt/ntstatus.c
+++ b/winpr/libwinpr/nt/ntstatus.c
@@ -4624,7 +4624,7 @@ const char* NtStatus2Tag(NTSTATUS ntstatus)
const struct ntstatus_map* found =
bsearch(&ntstatus, ntstatusmap, count, base, ntstatus_compare);
if (!found)
- return NULL;
+ return nullptr;
return found->tag;
#else
for (size_t x = 0; x < ARRAYSIZE(ntstatusmap); x++)
@@ -4634,7 +4634,7 @@ const char* NtStatus2Tag(NTSTATUS ntstatus)
return cur->tag;
}
- return NULL;
+ return nullptr;
#endif
}
@@ -4647,7 +4647,7 @@ const char* Win32ErrorCode2Tag(UINT16 code)
const struct ntstatus_map* found =
bsearch(&ntstatus, win32errmap, count, base, ntstatus_compare);
if (!found)
- return NULL;
+ return nullptr;
return found->tag;
#else
for (size_t x = 0; x < ARRAYSIZE(win32errmap); x++)
@@ -4657,6 +4657,6 @@ const char* Win32ErrorCode2Tag(UINT16 code)
return cur->tag;
}
- return NULL;
+ return nullptr;
#endif
}
diff --git a/winpr/libwinpr/nt/test/TestNtCurrentTeb.c b/winpr/libwinpr/nt/test/TestNtCurrentTeb.c
index 6ee383638..e6e5fc9cd 100644
--- a/winpr/libwinpr/nt/test/TestNtCurrentTeb.c
+++ b/winpr/libwinpr/nt/test/TestNtCurrentTeb.c
@@ -6,13 +6,13 @@
int TestNtCurrentTeb(int argc, char* argv[])
{
#ifndef _WIN32
- PTEB teb = NULL;
+ PTEB teb = nullptr;
teb = NtCurrentTeb();
if (!teb)
{
- printf("NtCurrentTeb() returned NULL\n");
+ printf("NtCurrentTeb() returned nullptr\n");
return -1;
}
#endif
diff --git a/winpr/libwinpr/path/include/PathAllocCombine.h b/winpr/libwinpr/path/include/PathAllocCombine.h
index 5461252a9..c159f6ce4 100644
--- a/winpr/libwinpr/path/include/PathAllocCombine.h
+++ b/winpr/libwinpr/path/include/PathAllocCombine.h
@@ -9,7 +9,7 @@
/**
* FIXME: These implementations of the PathAllocCombine functions have
* several issues:
- * - pszPathIn or pszMore may be NULL (but not both)
+ * - pszPathIn or pszMore may be nullptr (but not both)
* - no check if pszMore is fully qualified (if so, it must be directly
* copied to the output buffer without being combined with pszPathIn.
* - if pszMore begins with a _single_ backslash it must be combined with
diff --git a/winpr/libwinpr/path/path.c b/winpr/libwinpr/path/path.c
index 85451c05e..1fdf64aa1 100644
--- a/winpr/libwinpr/path/path.c
+++ b/winpr/libwinpr/path/path.c
@@ -1020,8 +1020,6 @@ PCSTR PathGetSharedLibraryExtensionA(unsigned long dwFlags)
return SharedLibraryExtensionSoA;
#endif
}
-
- return NULL;
}
PCWSTR PathGetSharedLibraryExtensionW(unsigned long dwFlags)
@@ -1092,8 +1090,6 @@ PCWSTR PathGetSharedLibraryExtensionW(unsigned long dwFlags)
return SharedLibraryExtensionSoW;
#endif
}
-
- return NULL;
}
const char* GetKnownPathIdString(int id)
@@ -1124,7 +1120,7 @@ static char* concat(const char* path, size_t pathlen, const char* name, size_t n
const size_t strsize = pathlen + namelen + 2;
char* str = calloc(strsize, sizeof(char));
if (!str)
- return NULL;
+ return nullptr;
winpr_str_append(path, str, strsize, "");
winpr_str_append(name, str, strsize, "");
@@ -1208,7 +1204,7 @@ fail:
BOOL winpr_RemoveDirectory_RecursiveW(LPCWSTR lpPathName)
{
- char* name = ConvertWCharToUtf8Alloc(lpPathName, NULL);
+ char* name = ConvertWCharToUtf8Alloc(lpPathName, nullptr);
if (!name)
return FALSE;
const BOOL rc = winpr_RemoveDirectory_RecursiveA(name);
@@ -1224,13 +1220,13 @@ char* winpr_GetConfigFilePathVA(BOOL system, WINPR_FORMAT_ARG const char* filena
const SSIZE_T version = winpr_getApplicationDetailsVersion();
if (!vendor || !product)
- return NULL;
+ return nullptr;
char* config = GetKnownSubPathV(id, "%s", vendor);
if (!config)
- return NULL;
+ return nullptr;
- char* base = NULL;
+ char* base = nullptr;
if (version < 0)
base = GetCombinedPathV(config, "%s", product);
else
@@ -1238,7 +1234,7 @@ char* winpr_GetConfigFilePathVA(BOOL system, WINPR_FORMAT_ARG const char* filena
free(config);
if (!base)
- return NULL;
+ return nullptr;
char* path = GetCombinedPathVA(base, filename, ap);
free(base);
diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c
index d66f66a56..85e241f6c 100644
--- a/winpr/libwinpr/path/shell.c
+++ b/winpr/libwinpr/path/shell.c
@@ -64,15 +64,15 @@ static char* GetPath_XDG_RUNTIME_DIR(void);
static char* win_get_known_folder(REFKNOWNFOLDERID id, BOOL currentUser)
{
- WCHAR* wpath = NULL;
- HANDLE handle = currentUser ? NULL : (HANDLE)-1;
+ WCHAR* wpath = nullptr;
+ HANDLE handle = currentUser ? nullptr : (HANDLE)-1;
if (FAILED(SHGetKnownFolderPath(id, 0, handle, &wpath)))
- return NULL;
+ return nullptr;
if (!wpath)
- return NULL;
+ return nullptr;
- char* path = ConvertWCharToUtf8Alloc(wpath, NULL);
+ char* path = ConvertWCharToUtf8Alloc(wpath, nullptr);
CoTaskMemFree(wpath);
return path;
}
@@ -87,23 +87,23 @@ char* GetEnvAlloc(LPCSTR lpName)
{
DWORD nSize = 0;
DWORD nStatus = 0;
- char* env = NULL;
+ char* env = nullptr;
- nSize = GetEnvironmentVariableX(lpName, NULL, 0);
+ nSize = GetEnvironmentVariableX(lpName, nullptr, 0);
if (nSize > 0)
{
env = malloc(nSize);
if (!env)
- return NULL;
+ return nullptr;
nStatus = GetEnvironmentVariableX(lpName, env, nSize);
if (nStatus != (nSize - 1))
{
free(env);
- return NULL;
+ return nullptr;
}
}
@@ -112,7 +112,7 @@ char* GetEnvAlloc(LPCSTR lpName)
static char* GetPath_HOME(void)
{
- char* path = NULL;
+ char* path = nullptr;
#ifdef _WIN32
path = GetEnvAlloc("UserProfile");
#elif defined(__IOS__)
@@ -125,7 +125,7 @@ static char* GetPath_HOME(void)
static char* GetPath_TEMP(void)
{
- char* path = NULL;
+ char* path = nullptr;
#ifdef _WIN32
path = GetEnvAlloc("TEMP");
#elif defined(__IOS__)
@@ -142,12 +142,12 @@ static char* GetPath_TEMP(void)
static char* GetPath_XDG_DATA_HOME(void)
{
- char* path = NULL;
+ char* path = nullptr;
#if defined(WIN32) || defined(__IOS__)
path = GetPath_XDG_CONFIG_HOME();
#else
size_t size = 0;
- char* home = NULL;
+ char* home = nullptr;
/**
* There is a single base directory relative to which user-specific data files should be
* written. This directory is defined by the environment variable $XDG_DATA_HOME.
@@ -164,7 +164,7 @@ static char* GetPath_XDG_DATA_HOME(void)
home = GetPath_HOME();
if (!home)
- return NULL;
+ return nullptr;
size = strlen(home) + strlen("/.local/share") + 1;
path = (char*)malloc(size);
@@ -172,7 +172,7 @@ static char* GetPath_XDG_DATA_HOME(void)
if (!path)
{
free(home);
- return NULL;
+ return nullptr;
}
(void)sprintf_s(path, size, "%s%s", home, "/.local/share");
@@ -183,7 +183,7 @@ static char* GetPath_XDG_DATA_HOME(void)
static char* GetPath_XDG_CONFIG_HOME(void)
{
- char* path = NULL;
+ char* path = nullptr;
#if defined(WIN32) && !defined(_UWP)
path = win_get_known_folder(&FOLDERID_RoamingAppData, TRUE);
@@ -192,7 +192,7 @@ static char* GetPath_XDG_CONFIG_HOME(void)
path = ios_get_data();
#else
size_t size = 0;
- char* home = NULL;
+ char* home = nullptr;
/**
* There is a single base directory relative to which user-specific configuration files should
* be written. This directory is defined by the environment variable $XDG_CONFIG_HOME.
@@ -212,7 +212,7 @@ static char* GetPath_XDG_CONFIG_HOME(void)
home = GetPath_TEMP();
if (!home)
- return NULL;
+ return nullptr;
size = strlen(home) + strlen("/.config") + 1;
path = (char*)malloc(size);
@@ -220,7 +220,7 @@ static char* GetPath_XDG_CONFIG_HOME(void)
if (!path)
{
free(home);
- return NULL;
+ return nullptr;
}
(void)sprintf_s(path, size, "%s%s", home, "/.config");
@@ -231,7 +231,7 @@ static char* GetPath_XDG_CONFIG_HOME(void)
static char* GetPath_SYSTEM_CONFIG_HOME(void)
{
- char* path = NULL;
+ char* path = nullptr;
#if defined(WIN32) && !defined(_UWP)
path = win_get_known_folder(&FOLDERID_ProgramData, FALSE);
@@ -246,7 +246,7 @@ static char* GetPath_SYSTEM_CONFIG_HOME(void)
static char* GetPath_XDG_CACHE_HOME(void)
{
- char* path = NULL;
+ char* path = nullptr;
#if defined(WIN32)
{
char* home = GetPath_XDG_RUNTIME_DIR();
@@ -256,8 +256,8 @@ static char* GetPath_XDG_CACHE_HOME(void)
path = GetCombinedPath(home, "cache");
if (!winpr_PathFileExists(path))
- if (!winpr_PathMakePath(path, NULL))
- path = NULL;
+ if (!winpr_PathMakePath(path, nullptr))
+ path = nullptr;
}
free(home);
@@ -282,7 +282,7 @@ static char* GetPath_XDG_CACHE_HOME(void)
char* home = GetPath_HOME();
if (!home)
- return NULL;
+ return nullptr;
size = strlen(home) + strlen("/.cache") + 1;
path = (char*)malloc(size);
@@ -290,7 +290,7 @@ static char* GetPath_XDG_CACHE_HOME(void)
if (!path)
{
free(home);
- return NULL;
+ return nullptr;
}
(void)sprintf_s(path, size, "%s%s", home, "/.cache");
@@ -301,7 +301,7 @@ static char* GetPath_XDG_CACHE_HOME(void)
char* GetPath_XDG_RUNTIME_DIR(void)
{
- char* path = NULL;
+ char* path = nullptr;
#if defined(WIN32) && !defined(_UWP)
path = win_get_known_folder(&FOLDERID_LocalAppData, TRUE);
@@ -350,7 +350,7 @@ char* GetPath_XDG_RUNTIME_DIR(void)
char* GetKnownPath(eKnownPathTypes id)
{
- char* path = NULL;
+ char* path = nullptr;
switch (id)
{
@@ -383,12 +383,13 @@ char* GetKnownPath(eKnownPathTypes id)
break;
default:
- path = NULL;
+ path = nullptr;
break;
}
if (!path)
- WLog_WARN(TAG, "Path %s is NULL", GetKnownPathIdString(WINPR_ASSERTING_INT_CAST(int, id)));
+ WLog_WARN(TAG, "Path %s is nullptr",
+ GetKnownPathIdString(WINPR_ASSERTING_INT_CAST(int, id)));
return path;
}
@@ -413,7 +414,7 @@ char* GetKnownSubPathVA(eKnownPathTypes id, const char* path, va_list ap)
{
char* knownPath = GetKnownPath(id);
if (!knownPath)
- return NULL;
+ return nullptr;
char* subPath = GetCombinedPathVA(knownPath, path, ap);
free(knownPath);
@@ -422,24 +423,24 @@ char* GetKnownSubPathVA(eKnownPathTypes id, const char* path, va_list ap)
char* GetEnvironmentPath(char* name)
{
- char* env = NULL;
+ char* env = nullptr;
DWORD nSize = 0;
DWORD nStatus = 0;
- nSize = GetEnvironmentVariableX(name, NULL, 0);
+ nSize = GetEnvironmentVariableX(name, nullptr, 0);
if (nSize)
{
env = (LPSTR)malloc(nSize);
if (!env)
- return NULL;
+ return nullptr;
nStatus = GetEnvironmentVariableX(name, env, nSize);
if (nStatus != (nSize - 1))
{
free(env);
- return NULL;
+ return nullptr;
}
}
@@ -467,7 +468,7 @@ char* GetEnvironmentSubPathVA(char* name, WINPR_FORMAT_ARG const char* path, va_
char* env = GetEnvironmentPath(name);
if (!env)
- return NULL;
+ return nullptr;
char* subpath = GetCombinedPathVA(env, path, ap);
free(env);
@@ -494,7 +495,7 @@ char* GetCombinedPathV(const char* basePath, const char* subPathFmt, ...)
char* GetCombinedPathVA(const char* basePath, WINPR_FORMAT_ARG const char* subPathFmt, va_list ap)
{
HRESULT status = 0;
- char* subPathCpy = NULL;
+ char* subPathCpy = nullptr;
size_t basePathLength = 0;
size_t subPathLength = 0;
@@ -506,11 +507,11 @@ char* GetCombinedPathVA(const char* basePath, WINPR_FORMAT_ARG const char* subPa
{
const int rc = winpr_vasprintf(&subPathCpy, &subPathLength, subPathFmt, ap);
if (rc < 0)
- return NULL;
+ return nullptr;
if (rc == 0)
{
free(subPathCpy);
- subPathCpy = NULL;
+ subPathCpy = nullptr;
subPathLength = 0;
haveSubPath = false;
}
@@ -547,7 +548,7 @@ char* GetCombinedPathVA(const char* basePath, WINPR_FORMAT_ARG const char* subPa
fail:
free(path);
free(subPathCpy);
- return NULL;
+ return nullptr;
}
BOOL PathMakePathA(LPCSTR path, WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpAttributes)
@@ -555,10 +556,10 @@ BOOL PathMakePathA(LPCSTR path, WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpAttrib
#if defined(_UWP)
return FALSE;
#elif defined(_WIN32)
- return (SHCreateDirectoryExA(NULL, path, lpAttributes) == ERROR_SUCCESS);
+ return (SHCreateDirectoryExA(nullptr, path, lpAttributes) == ERROR_SUCCESS);
#else
const char delim = PathGetSeparatorA(PATH_STYLE_NATIVE);
- char* dup = NULL;
+ char* dup = nullptr;
BOOL result = TRUE;
/* we only operate on a non-null, absolute path */
#if defined(__OS2__)
@@ -608,11 +609,11 @@ BOOL PathMakePathW(LPCWSTR path, WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpAttri
#if defined(_UWP)
return FALSE;
#elif defined(_WIN32)
- return (SHCreateDirectoryExW(NULL, path, lpAttributes) == ERROR_SUCCESS);
+ return (SHCreateDirectoryExW(nullptr, path, lpAttributes) == ERROR_SUCCESS);
#else
const WCHAR wdelim = PathGetSeparatorW(PATH_STYLE_NATIVE);
const char delim = PathGetSeparatorA(PATH_STYLE_NATIVE);
- char* dup = NULL;
+ char* dup = nullptr;
BOOL result = TRUE;
/* we only operate on a non-null, absolute path */
#if defined(__OS2__)
@@ -627,7 +628,7 @@ BOOL PathMakePathW(LPCWSTR path, WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpAttri
#endif
- dup = ConvertWCharToUtf8Alloc(path, NULL);
+ dup = ConvertWCharToUtf8Alloc(path, nullptr);
if (!dup)
return FALSE;
@@ -670,13 +671,13 @@ BOOL PathIsRelativeA(LPCSTR pszPath)
BOOL PathIsRelativeW(LPCWSTR pszPath)
{
- LPSTR lpFileNameA = NULL;
+ LPSTR lpFileNameA = nullptr;
BOOL ret = FALSE;
if (!pszPath)
goto fail;
- lpFileNameA = ConvertWCharToUtf8Alloc(pszPath, NULL);
+ lpFileNameA = ConvertWCharToUtf8Alloc(pszPath, nullptr);
if (!lpFileNameA)
goto fail;
ret = PathIsRelativeA(lpFileNameA);
@@ -694,12 +695,12 @@ BOOL PathFileExistsA(LPCSTR pszPath)
BOOL PathFileExistsW(LPCWSTR pszPath)
{
- LPSTR lpFileNameA = NULL;
+ LPSTR lpFileNameA = nullptr;
BOOL ret = FALSE;
if (!pszPath)
goto fail;
- lpFileNameA = ConvertWCharToUtf8Alloc(pszPath, NULL);
+ lpFileNameA = ConvertWCharToUtf8Alloc(pszPath, nullptr);
if (!lpFileNameA)
goto fail;
@@ -711,15 +712,15 @@ fail:
BOOL PathIsDirectoryEmptyA(LPCSTR pszPath)
{
- struct dirent* dp = NULL;
+ struct dirent* dp = nullptr;
int empty = 1;
DIR* dir = opendir(pszPath);
- if (dir == NULL) /* Not a directory or doesn't exist */
+ if (dir == nullptr) /* Not a directory or doesn't exist */
return 1;
// NOLINTNEXTLINE(concurrency-mt-unsafe)
- while ((dp = readdir(dir)) != NULL)
+ while ((dp = readdir(dir)) != nullptr)
{
if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)
continue; /* Skip . and .. */
@@ -734,11 +735,11 @@ BOOL PathIsDirectoryEmptyA(LPCSTR pszPath)
BOOL PathIsDirectoryEmptyW(LPCWSTR pszPath)
{
- LPSTR lpFileNameA = NULL;
+ LPSTR lpFileNameA = nullptr;
BOOL ret = FALSE;
if (!pszPath)
goto fail;
- lpFileNameA = ConvertWCharToUtf8Alloc(pszPath, NULL);
+ lpFileNameA = ConvertWCharToUtf8Alloc(pszPath, nullptr);
if (!lpFileNameA)
goto fail;
ret = PathIsDirectoryEmptyA(lpFileNameA);
@@ -786,16 +787,16 @@ BOOL winpr_MoveFileEx(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, DWORD dwF
return ret == 0;
#else
BOOL result = FALSE;
- LPWSTR lpExistingFileNameW = NULL;
- LPWSTR lpNewFileNameW = NULL;
+ LPWSTR lpExistingFileNameW = nullptr;
+ LPWSTR lpNewFileNameW = nullptr;
if (!lpExistingFileName || !lpNewFileName)
return FALSE;
- lpExistingFileNameW = ConvertUtf8ToWCharAlloc(lpExistingFileName, NULL);
+ lpExistingFileNameW = ConvertUtf8ToWCharAlloc(lpExistingFileName, nullptr);
if (!lpExistingFileNameW)
goto cleanup;
- lpNewFileNameW = ConvertUtf8ToWCharAlloc(lpNewFileName, NULL);
+ lpNewFileNameW = ConvertUtf8ToWCharAlloc(lpNewFileName, nullptr);
if (!lpNewFileNameW)
goto cleanup;
@@ -817,11 +818,11 @@ BOOL winpr_DeleteFile(const char* lpFileName)
const int status = unlink(lpFileName);
return (status != -1);
#else
- LPWSTR lpFileNameW = NULL;
+ LPWSTR lpFileNameW = nullptr;
BOOL result = FALSE;
if (lpFileName)
- lpFileNameW = ConvertUtf8ToWCharAlloc(lpFileName, NULL);
+ lpFileNameW = ConvertUtf8ToWCharAlloc(lpFileName, nullptr);
if (!lpFileNameW)
goto cleanup;
@@ -846,11 +847,11 @@ BOOL winpr_RemoveDirectory(LPCSTR lpPathName)
return ret == 0;
#else
- LPWSTR lpPathNameW = NULL;
+ LPWSTR lpPathNameW = nullptr;
BOOL result = FALSE;
if (lpPathName)
- lpPathNameW = ConvertUtf8ToWCharAlloc(lpPathName, NULL);
+ lpPathNameW = ConvertUtf8ToWCharAlloc(lpPathName, nullptr);
if (!lpPathNameW)
goto cleanup;
@@ -870,7 +871,7 @@ BOOL winpr_PathFileExists(const char* pszPath)
#ifndef _WIN32
return PathFileExistsA(pszPath);
#else
- WCHAR* pathW = ConvertUtf8ToWCharAlloc(pszPath, NULL);
+ WCHAR* pathW = ConvertUtf8ToWCharAlloc(pszPath, nullptr);
BOOL result = FALSE;
if (!pathW)
@@ -890,13 +891,13 @@ BOOL winpr_PathMakePath(const char* path, LPSECURITY_ATTRIBUTES lpAttributes)
#ifndef _WIN32
return PathMakePathA(path, lpAttributes);
#else
- WCHAR* pathW = ConvertUtf8ToWCharAlloc(path, NULL);
+ WCHAR* pathW = ConvertUtf8ToWCharAlloc(path, nullptr);
BOOL result = FALSE;
if (!pathW)
return FALSE;
- result = SHCreateDirectoryExW(NULL, pathW, lpAttributes) == ERROR_SUCCESS;
+ result = SHCreateDirectoryExW(nullptr, pathW, lpAttributes) == ERROR_SUCCESS;
free(pathW);
return result;
diff --git a/winpr/libwinpr/path/test/TestPathAllocCombine.c b/winpr/libwinpr/path/test/TestPathAllocCombine.c
index 4630df001..967092524 100644
--- a/winpr/libwinpr/path/test/TestPathAllocCombine.c
+++ b/winpr/libwinpr/path/test/TestPathAllocCombine.c
@@ -15,7 +15,7 @@ static const TCHAR testPathOutMorePathBackslash[] = _T("C:\\Microsoft Visual Stu
int TestPathAllocCombine(int argc, char* argv[])
{
HRESULT status = 0;
- LPTSTR PathOut = NULL;
+ LPTSTR PathOut = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslash.c b/winpr/libwinpr/path/test/TestPathCchAddBackslash.c
index 3066aa5bb..e67bb1f91 100644
--- a/winpr/libwinpr/path/test/TestPathCchAddBackslash.c
+++ b/winpr/libwinpr/path/test/TestPathCchAddBackslash.c
@@ -58,9 +58,9 @@ int TestPathCchAddBackslash(int argc, char* argv[])
return -1;
}
- /* Use NULL PSTR, expect FAILED(status) */
+ /* Use nullptr PSTR, expect FAILED(status) */
- status = PathCchAddBackslash(NULL, PATHCCH_MAX_CCH);
+ status = PathCchAddBackslash(nullptr, PATHCCH_MAX_CCH);
if (SUCCEEDED(status))
{
diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c b/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c
index 3c06bab9b..b66067dd5 100644
--- a/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c
+++ b/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c
@@ -11,7 +11,7 @@ static const TCHAR testPathNoBackslash[] = _T("C:\\Program Files");
int TestPathCchAddBackslashEx(int argc, char* argv[])
{
HRESULT status = 0;
- LPTSTR pszEnd = NULL;
+ LPTSTR pszEnd = nullptr;
size_t cchRemaining = 0;
TCHAR Path[PATHCCH_MAX_CCH] = WINPR_C_ARRAY_INIT;
@@ -60,9 +60,9 @@ int TestPathCchAddBackslashEx(int argc, char* argv[])
return -1;
}
- /* Use NULL PSTR, expect FAILED(status) */
+ /* Use nullptr PSTR, expect FAILED(status) */
- status = PathCchAddBackslashEx(NULL, PATHCCH_MAX_CCH, NULL, NULL);
+ status = PathCchAddBackslashEx(nullptr, PATHCCH_MAX_CCH, nullptr, nullptr);
if (SUCCEEDED(status))
{
@@ -77,7 +77,7 @@ int TestPathCchAddBackslashEx(int argc, char* argv[])
_tcsncpy(Path, _T("C:\\tmp"), ARRAYSIZE(Path));
- status = PathCchAddBackslashEx(Path, 7, NULL, NULL);
+ status = PathCchAddBackslashEx(Path, 7, nullptr, nullptr);
if (SUCCEEDED(status))
{
@@ -91,7 +91,7 @@ int TestPathCchAddBackslashEx(int argc, char* argv[])
_tcsncpy(Path, _T("C:\\tmp"), ARRAYSIZE(Path));
- status = PathCchAddBackslashEx(Path, 8, NULL, NULL);
+ status = PathCchAddBackslashEx(Path, 8, nullptr, nullptr);
if (status != S_OK)
{
diff --git a/winpr/libwinpr/path/test/TestPathCchAddExtension.c b/winpr/libwinpr/path/test/TestPathCchAddExtension.c
index 4a8f1a3ac..fd6d95941 100644
--- a/winpr/libwinpr/path/test/TestPathCchAddExtension.c
+++ b/winpr/libwinpr/path/test/TestPathCchAddExtension.c
@@ -90,9 +90,9 @@ int TestPathCchAddExtension(int argc, char* argv[])
return -1;
}
- /* Path: NULL */
+ /* Path: nullptr */
- status = PathCchAddExtension(NULL, PATHCCH_MAX_CCH, testExtDot);
+ status = PathCchAddExtension(nullptr, PATHCCH_MAX_CCH, testExtDot);
if (status != E_INVALIDARG)
{
_tprintf(_T("PathCchAddExtension with null buffer returned status: 0x%08") _T(
@@ -101,9 +101,9 @@ int TestPathCchAddExtension(int argc, char* argv[])
return -1;
}
- /* Extension: NULL */
+ /* Extension: nullptr */
- status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, NULL);
+ status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, nullptr);
if (status != E_INVALIDARG)
{
_tprintf(_T("PathCchAddExtension with null extension returned status: 0x%08") _T(
diff --git a/winpr/libwinpr/path/test/TestPathCchAppend.c b/winpr/libwinpr/path/test/TestPathCchAppend.c
index bd47b1dce..3e1017749 100644
--- a/winpr/libwinpr/path/test/TestPathCchAppend.c
+++ b/winpr/libwinpr/path/test/TestPathCchAppend.c
@@ -91,22 +91,22 @@ int TestPathCchAppend(int argc, char* argv[])
return -1;
}
- /* According to msdn a NULL Path is an invalid argument */
- status = PathCchAppend(NULL, PATHCCH_MAX_CCH, testMorePathNoBackslash);
+ /* According to msdn a nullptr Path is an invalid argument */
+ status = PathCchAppend(nullptr, PATHCCH_MAX_CCH, testMorePathNoBackslash);
if (status != E_INVALIDARG)
{
- _tprintf(_T("PathCchAppend with NULL path unexpectedly returned status: 0x%08") _T(
+ _tprintf(_T("PathCchAppend with nullptr path unexpectedly returned status: 0x%08") _T(
PRIX32) _T("\n"),
status);
return -1;
}
- /* According to msdn a NULL pszMore is an invalid argument (although optional !?) */
+ /* According to msdn a nullptr pszMore is an invalid argument (although optional !?) */
_tcsncpy(Path, testBasePathNoBackslash, ARRAYSIZE(Path));
- status = PathCchAppend(Path, PATHCCH_MAX_CCH, NULL);
+ status = PathCchAppend(Path, PATHCCH_MAX_CCH, nullptr);
if (status != E_INVALIDARG)
{
- _tprintf(_T("PathCchAppend with NULL pszMore unexpectedly returned status: 0x%08") _T(
+ _tprintf(_T("PathCchAppend with nullptr pszMore unexpectedly returned status: 0x%08") _T(
PRIX32) _T("\n"),
status);
return -1;
diff --git a/winpr/libwinpr/path/test/TestPathCchFindExtension.c b/winpr/libwinpr/path/test/TestPathCchFindExtension.c
index 5478b0196..b9fd7a7e1 100644
--- a/winpr/libwinpr/path/test/TestPathCchFindExtension.c
+++ b/winpr/libwinpr/path/test/TestPathCchFindExtension.c
@@ -8,8 +8,8 @@ static const char testPathExtension[] = "C:\\Windows\\System32\\cmd.exe";
int TestPathCchFindExtension(int argc, char* argv[])
{
- PCSTR pszExt = NULL;
- PCSTR pszTmp = NULL;
+ PCSTR pszExt = nullptr;
+ PCSTR pszTmp = nullptr;
HRESULT hr = 0;
WINPR_UNUSED(argc);
@@ -17,13 +17,12 @@ int TestPathCchFindExtension(int argc, char* argv[])
/* Test invalid args */
- hr = PathCchFindExtensionA(NULL, sizeof(testPathExtension), &pszExt);
+ hr = PathCchFindExtensionA(nullptr, sizeof(testPathExtension), &pszExt);
if (SUCCEEDED(hr))
{
- printf(
- "PathCchFindExtensionA unexpectedly succeeded with pszPath = NULL. result: 0x%08" PRIX32
- "\n",
- hr);
+ printf("PathCchFindExtensionA unexpectedly succeeded with pszPath = nullptr. result: "
+ "0x%08" PRIX32 "\n",
+ hr);
return -1;
}
@@ -36,13 +35,12 @@ int TestPathCchFindExtension(int argc, char* argv[])
return -1;
}
- hr = PathCchFindExtensionA(testPathExtension, sizeof(testPathExtension), NULL);
+ hr = PathCchFindExtensionA(testPathExtension, sizeof(testPathExtension), nullptr);
if (SUCCEEDED(hr))
{
- printf(
- "PathCchFindExtensionA unexpectedly succeeded with ppszExt = NULL. result: 0x%08" PRIX32
- "\n",
- hr);
+ printf("PathCchFindExtensionA unexpectedly succeeded with ppszExt = nullptr. result: "
+ "0x%08" PRIX32 "\n",
+ hr);
return -1;
}
@@ -59,7 +57,7 @@ int TestPathCchFindExtension(int argc, char* argv[])
/* Test passing of an empty terminated string (must succeed) */
- pszExt = NULL;
+ pszExt = nullptr;
pszTmp = "";
hr = PathCchFindExtensionA(pszTmp, 1, &pszExt);
if (hr != S_OK)
@@ -79,7 +77,7 @@ int TestPathCchFindExtension(int argc, char* argv[])
/* Test a path without file extension (must succeed) */
- pszExt = NULL;
+ pszExt = nullptr;
pszTmp = "c:\\4.678\\";
hr = PathCchFindExtensionA(pszTmp, 10, &pszExt);
if (hr != S_OK)
@@ -88,7 +86,7 @@ int TestPathCchFindExtension(int argc, char* argv[])
return -1;
}
/* The extension must not have been found and pszExt must point to the
- * strings terminating NULL now */
+ * strings terminating nullptr now */
if (pszExt != &pszTmp[9])
{
printf("PathCchFindExtensionA failed with a directory path: pszExt pointer mismatch\n");
@@ -97,7 +95,7 @@ int TestPathCchFindExtension(int argc, char* argv[])
/* Non-special tests */
- pszExt = NULL;
+ pszExt = nullptr;
if (PathCchFindExtensionA(testPathExtension, sizeof(testPathExtension), &pszExt) != S_OK)
{
printf("PathCchFindExtensionA failure: expected S_OK\n");
diff --git a/winpr/libwinpr/path/test/TestPathCchStripPrefix.c b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c
index bb62e03b1..a416755ff 100644
--- a/winpr/libwinpr/path/test/TestPathCchStripPrefix.c
+++ b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c
@@ -68,8 +68,8 @@ int TestPathCchStripPrefix(int argc, char* argv[])
return -1;
}
- /* NULL Path */
- status = PathCchStripPrefix(NULL, PATHCCH_MAX_CCH);
+ /* nullptr Path */
+ status = PathCchStripPrefix(nullptr, PATHCCH_MAX_CCH);
if (status != E_INVALIDARG)
{
_tprintf(
diff --git a/winpr/libwinpr/path/test/TestPathIsUNCEx.c b/winpr/libwinpr/path/test/TestPathIsUNCEx.c
index 9789e1110..d0e42b15b 100644
--- a/winpr/libwinpr/path/test/TestPathIsUNCEx.c
+++ b/winpr/libwinpr/path/test/TestPathIsUNCEx.c
@@ -12,7 +12,7 @@ static const TCHAR testPathNotUNC[] = _T("C:\\share\\path\\file");
int TestPathIsUNCEx(int argc, char* argv[])
{
BOOL status = 0;
- LPCTSTR Server = NULL;
+ LPCTSTR Server = nullptr;
TCHAR Path[PATHCCH_MAX_CCH] = WINPR_C_ARRAY_INIT;
WINPR_UNUSED(argc);
diff --git a/winpr/libwinpr/path/test/TestPathMakePath.c b/winpr/libwinpr/path/test/TestPathMakePath.c
index 707a40be9..e36abb892 100644
--- a/winpr/libwinpr/path/test/TestPathMakePath.c
+++ b/winpr/libwinpr/path/test/TestPathMakePath.c
@@ -21,8 +21,8 @@ int TestPathMakePath(int argc, char* argv[])
size_t baseLen = 0;
BOOL success = 0;
char tmp[64] = WINPR_C_ARRAY_INIT;
- char* path = NULL;
- char* cur = NULL;
+ char* path = nullptr;
+ char* cur = nullptr;
char delim = PathGetSeparatorA(0);
char* base = GetKnownPath(KNOWN_PATH_TEMP);
@@ -53,7 +53,7 @@ int TestPathMakePath(int argc, char* argv[])
}
printf("Creating path %s\n", path);
- success = winpr_PathMakePath(path, NULL);
+ success = winpr_PathMakePath(path, nullptr);
if (!success)
{
diff --git a/winpr/libwinpr/pipe/pipe.c b/winpr/libwinpr/pipe/pipe.c
index 0e4c5fb87..a0ea441bd 100644
--- a/winpr/libwinpr/pipe/pipe.c
+++ b/winpr/libwinpr/pipe/pipe.c
@@ -68,7 +68,7 @@
* descriptor gets closed and the entry is removed from the list.
*/
-static wArrayList* g_NamedPipeServerSockets = NULL;
+static wArrayList* g_NamedPipeServerSockets = nullptr;
typedef struct
{
@@ -113,7 +113,7 @@ static BOOL PipeRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
{
SSIZE_T io_status = 0;
- WINPR_PIPE* pipe = NULL;
+ WINPR_PIPE* pipe = nullptr;
BOOL status = TRUE;
if (lpOverlapped)
@@ -154,7 +154,7 @@ static BOOL PipeWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrit
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
{
SSIZE_T io_status = 0;
- WINPR_PIPE* pipe = NULL;
+ WINPR_PIPE* pipe = nullptr;
if (lpOverlapped)
{
@@ -180,25 +180,25 @@ static BOOL PipeWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrit
static HANDLE_OPS ops = { PipeIsHandled,
PipeCloseHandle,
PipeGetFd,
- NULL, /* CleanupHandle */
+ nullptr, /* CleanupHandle */
PipeRead,
- NULL, /* FileReadEx */
- NULL, /* FileReadScatter */
+ nullptr, /* FileReadEx */
+ nullptr, /* FileReadScatter */
PipeWrite,
- NULL, /* FileWriteEx */
- NULL, /* FileWriteGather */
- NULL, /* FileGetFileSize */
- NULL, /* FlushFileBuffers */
- NULL, /* FileSetEndOfFile */
- NULL, /* FileSetFilePointer */
- NULL, /* SetFilePointerEx */
- NULL, /* FileLockFile */
- NULL, /* FileLockFileEx */
- NULL, /* FileUnlockFile */
- NULL, /* FileUnlockFileEx */
- NULL /* SetFileTime */
+ nullptr, /* FileWriteEx */
+ nullptr, /* FileWriteGather */
+ nullptr, /* FileGetFileSize */
+ nullptr, /* FlushFileBuffers */
+ nullptr, /* FileSetEndOfFile */
+ nullptr, /* FileSetFilePointer */
+ nullptr, /* SetFilePointerEx */
+ nullptr, /* FileLockFile */
+ nullptr, /* FileLockFileEx */
+ nullptr, /* FileUnlockFile */
+ nullptr, /* FileUnlockFileEx */
+ nullptr /* SetFileTime */
,
- NULL };
+ nullptr };
static BOOL NamedPipeIsHandled(HANDLE handle)
{
@@ -294,7 +294,7 @@ BOOL NamedPipeRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
/* Overlapped I/O */
if (!lpOverlapped)
{
- WLog_ERR(TAG, "requires lpOverlapped != NULL as FILE_FLAG_OVERLAPPED is set");
+ WLog_ERR(TAG, "requires lpOverlapped != nullptr as FILE_FLAG_OVERLAPPED is set");
SetLastError(ERROR_NOT_SUPPORTED);
return FALSE;
}
@@ -340,7 +340,7 @@ BOOL NamedPipeWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
{
SSIZE_T io_status = 0;
- WINPR_NAMED_PIPE* pipe = NULL;
+ WINPR_NAMED_PIPE* pipe = nullptr;
BOOL status = TRUE;
if (lpOverlapped)
@@ -434,24 +434,24 @@ BOOL NamedPipeWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
static HANDLE_OPS namedOps = { NamedPipeIsHandled,
NamedPipeCloseHandle,
NamedPipeGetFd,
- NULL, /* CleanupHandle */
+ nullptr, /* CleanupHandle */
NamedPipeRead,
- NULL,
- NULL,
+ nullptr,
+ nullptr,
NamedPipeWrite,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL };
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr };
static BOOL InitWinPRPipeModule(void)
{
@@ -459,7 +459,7 @@ static BOOL InitWinPRPipeModule(void)
return TRUE;
g_NamedPipeServerSockets = ArrayList_New(FALSE);
- return g_NamedPipeServerSockets != NULL;
+ return g_NamedPipeServerSockets != nullptr;
}
/*
@@ -470,8 +470,8 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP
DWORD nSize)
{
int pipe_fd[] = { -1, -1 };
- WINPR_PIPE* pReadPipe = NULL;
- WINPR_PIPE* pWritePipe = NULL;
+ WINPR_PIPE* pReadPipe = nullptr;
+ WINPR_PIPE* pWritePipe = nullptr;
WINPR_UNUSED(lpPipeAttributes);
WINPR_UNUSED(nSize);
@@ -518,7 +518,7 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP
static void winpr_unref_named_pipe(WINPR_NAMED_PIPE* pNamedPipe)
{
- NamedPipeServerSocketEntry* baseSocket = NULL;
+ NamedPipeServerSocketEntry* baseSocket = nullptr;
if (!pNamedPipe)
return;
@@ -560,10 +560,10 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut,
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{
- char* lpPipePath = NULL;
- WINPR_NAMED_PIPE* pNamedPipe = NULL;
+ char* lpPipePath = nullptr;
+ WINPR_NAMED_PIPE* pNamedPipe = nullptr;
int serverfd = -1;
- NamedPipeServerSocketEntry* baseSocket = NULL;
+ NamedPipeServerSocketEntry* baseSocket = nullptr;
WINPR_UNUSED(lpSecurityAttributes);
@@ -634,7 +634,7 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
if (!winpr_PathFileExists(lpPipePath))
{
- if (!CreateDirectoryA(lpPipePath, 0))
+ if (!CreateDirectoryA(lpPipePath, nullptr))
{
free(lpPipePath);
goto out;
@@ -734,14 +734,14 @@ HANDLE CreateNamedPipeW(WINPR_ATTR_UNUSED LPCWSTR lpName, WINPR_ATTR_UNUSED DWOR
{
WLog_ERR(TAG, "is not implemented");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return NULL;
+ return nullptr;
}
BOOL ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped)
{
int status = 0;
socklen_t length = 0;
- WINPR_NAMED_PIPE* pNamedPipe = NULL;
+ WINPR_NAMED_PIPE* pNamedPipe = nullptr;
if (lpOverlapped)
{
@@ -782,7 +782,7 @@ BOOL ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped)
/* synchronous behavior */
lpOverlapped->Internal = 2;
lpOverlapped->InternalHigh = (ULONG_PTR)0;
- lpOverlapped->DUMMYUNIONNAME.Pointer = (PVOID)NULL;
+ lpOverlapped->DUMMYUNIONNAME.Pointer = (PVOID) nullptr;
(void)SetEvent(lpOverlapped->hEvent);
}
@@ -791,7 +791,7 @@ BOOL ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped)
BOOL DisconnectNamedPipe(HANDLE hNamedPipe)
{
- WINPR_NAMED_PIPE* pNamedPipe = NULL;
+ WINPR_NAMED_PIPE* pNamedPipe = nullptr;
pNamedPipe = (WINPR_NAMED_PIPE*)hNamedPipe;
if (pNamedPipe->clientfd != -1)
@@ -828,7 +828,7 @@ BOOL WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut)
{
BOOL status = 0;
DWORD nWaitTime = 0;
- char* lpFilePath = NULL;
+ char* lpFilePath = nullptr;
DWORD dwSleepInterval = 0;
if (!lpNamedPipeName)
@@ -876,7 +876,7 @@ BOOL SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCol
{
int fd = 0;
int flags = 0;
- WINPR_NAMED_PIPE* pNamedPipe = NULL;
+ WINPR_NAMED_PIPE* pNamedPipe = nullptr;
pNamedPipe = (WINPR_NAMED_PIPE*)hNamedPipe;
if (lpMode)
diff --git a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c
index bc7c18cbe..8b7b1f02c 100644
--- a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c
+++ b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c
@@ -25,17 +25,17 @@ static BOOL testFailed = FALSE;
static DWORD WINAPI named_pipe_client_thread(LPVOID arg)
{
- HANDLE hNamedPipe = NULL;
- BYTE* lpReadBuffer = NULL;
- BYTE* lpWriteBuffer = NULL;
+ HANDLE hNamedPipe = nullptr;
+ BYTE* lpReadBuffer = nullptr;
+ BYTE* lpWriteBuffer = nullptr;
BOOL fSuccess = FALSE;
DWORD nNumberOfBytesToRead = 0;
DWORD nNumberOfBytesToWrite = 0;
DWORD lpNumberOfBytesRead = 0;
DWORD lpNumberOfBytesWritten = 0;
(void)WaitForSingleObject(ReadyEvent, INFINITE);
- hNamedPipe =
- CreateFile(lpszPipeNameMt, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ hNamedPipe = CreateFile(lpszPipeNameMt, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING,
+ 0, nullptr);
if (hNamedPipe == INVALID_HANDLE_VALUE)
{
@@ -60,7 +60,7 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg)
FillMemory(lpWriteBuffer, PIPE_BUFFER_SIZE, 0x59);
if (!WriteFile(hNamedPipe, lpWriteBuffer, nNumberOfBytesToWrite, &lpNumberOfBytesWritten,
- NULL) ||
+ nullptr) ||
lpNumberOfBytesWritten != nNumberOfBytesToWrite)
{
printf("%s: Client NamedPipe WriteFile failure\n", __func__);
@@ -71,7 +71,7 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg)
nNumberOfBytesToRead = PIPE_BUFFER_SIZE;
ZeroMemory(lpReadBuffer, PIPE_BUFFER_SIZE);
- if (!ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, &lpNumberOfBytesRead, NULL) ||
+ if (!ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, &lpNumberOfBytesRead, nullptr) ||
lpNumberOfBytesRead != nNumberOfBytesToRead)
{
printf("%s: Client NamedPipe ReadFile failure\n", __func__);
@@ -95,9 +95,9 @@ out:
static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
{
- HANDLE hNamedPipe = NULL;
- BYTE* lpReadBuffer = NULL;
- BYTE* lpWriteBuffer = NULL;
+ HANDLE hNamedPipe = nullptr;
+ BYTE* lpReadBuffer = nullptr;
+ BYTE* lpWriteBuffer = nullptr;
BOOL fSuccess = FALSE;
BOOL fConnected = FALSE;
DWORD nNumberOfBytesToRead = 0;
@@ -106,11 +106,11 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
DWORD lpNumberOfBytesWritten = 0;
hNamedPipe = CreateNamedPipe(
lpszPipeNameMt, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
- PIPE_UNLIMITED_INSTANCES, PIPE_BUFFER_SIZE, PIPE_BUFFER_SIZE, 0, NULL);
+ PIPE_UNLIMITED_INSTANCES, PIPE_BUFFER_SIZE, PIPE_BUFFER_SIZE, 0, nullptr);
if (!hNamedPipe)
{
- printf("%s: CreateNamedPipe failure: NULL handle\n", __func__);
+ printf("%s: CreateNamedPipe failure: nullptr handle\n", __func__);
goto out;
}
@@ -131,7 +131,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
* the function returns zero.
*/
fConnected =
- ConnectNamedPipe(hNamedPipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
+ ConnectNamedPipe(hNamedPipe, nullptr) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
if (!fConnected)
{
@@ -154,7 +154,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
lpNumberOfBytesRead = 0;
nNumberOfBytesToRead = PIPE_BUFFER_SIZE;
- if (!ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, &lpNumberOfBytesRead, NULL) ||
+ if (!ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, &lpNumberOfBytesRead, nullptr) ||
lpNumberOfBytesRead != nNumberOfBytesToRead)
{
printf("%s: Server NamedPipe ReadFile failure\n", __func__);
@@ -168,7 +168,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
FillMemory(lpWriteBuffer, PIPE_BUFFER_SIZE, 0x45);
if (!WriteFile(hNamedPipe, lpWriteBuffer, nNumberOfBytesToWrite, &lpNumberOfBytesWritten,
- NULL) ||
+ nullptr) ||
lpNumberOfBytesWritten != nNumberOfBytesToWrite)
{
printf("%s: Server NamedPipe WriteFile failure\n", __func__);
@@ -205,7 +205,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
if (!(servers[i] = CreateNamedPipe(lpszPipeNameSt, PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES, PIPE_BUFFER_SIZE,
- PIPE_BUFFER_SIZE, 0, NULL)))
+ PIPE_BUFFER_SIZE, 0, nullptr)))
{
printf("%s: CreateNamedPipe #%d failed\n", __func__, i);
goto out;
@@ -251,8 +251,8 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
for (int i = 0; i < numPipes; i++)
{
BOOL fConnected = 0;
- if ((clients[i] = CreateFile(lpszPipeNameSt, GENERIC_READ | GENERIC_WRITE, 0, NULL,
- OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
+ if ((clients[i] = CreateFile(lpszPipeNameSt, GENERIC_READ | GENERIC_WRITE, 0, nullptr,
+ OPEN_EXISTING, 0, nullptr)) == INVALID_HANDLE_VALUE)
{
printf("%s: CreateFile #%d failed\n", __func__, i);
goto out;
@@ -267,7 +267,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
* the function returns zero.
*/
fConnected =
- ConnectNamedPipe(servers[i], NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
+ ConnectNamedPipe(servers[i], nullptr) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
if (!fConnected)
{
@@ -304,14 +304,14 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
/* Test writing from clients to servers */
(void)sprintf_s(sndbuf, sizeof(sndbuf), "CLIENT->SERVER ON PIPE #%05d", i);
- if (!WriteFile(clients[i], sndbuf, sizeof(sndbuf), &dwWritten, NULL) ||
+ if (!WriteFile(clients[i], sndbuf, sizeof(sndbuf), &dwWritten, nullptr) ||
dwWritten != sizeof(sndbuf))
{
printf("%s: Error writing to client end of pipe #%d\n", __func__, i);
goto out;
}
- if (!ReadFile(servers[i], rcvbuf, dwWritten, &dwRead, NULL) || dwRead != dwWritten)
+ if (!ReadFile(servers[i], rcvbuf, dwWritten, &dwRead, nullptr) || dwRead != dwWritten)
{
printf("%s: Error reading on server end of pipe #%d\n", __func__, i);
goto out;
@@ -331,14 +331,14 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
(void)sprintf_s(sndbuf, sizeof(sndbuf), "SERVER->CLIENT ON PIPE #%05d", i);
- if (!WriteFile(servers[i], sndbuf, sizeof(sndbuf), &dwWritten, NULL) ||
+ if (!WriteFile(servers[i], sndbuf, sizeof(sndbuf), &dwWritten, nullptr) ||
dwWritten != sizeof(sndbuf))
{
printf("%s: Error writing to server end of pipe #%d\n", __func__, i);
goto out;
}
- if (!ReadFile(clients[i], rcvbuf, dwWritten, &dwRead, NULL) || dwRead != dwWritten)
+ if (!ReadFile(clients[i], rcvbuf, dwWritten, &dwRead, nullptr) || dwRead != dwWritten)
{
printf("%s: Error reading on client end of pipe #%d\n", __func__, i);
goto out;
@@ -362,7 +362,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
{
char sndbuf[PIPE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
char rcvbuf[PIPE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
- if (ReadFile(clients[i], rcvbuf, sizeof(rcvbuf), &dwRead, NULL))
+ if (ReadFile(clients[i], rcvbuf, sizeof(rcvbuf), &dwRead, nullptr))
{
printf("%s: Error ReadFile on client should have failed after DisconnectNamedPipe on "
"server\n",
@@ -370,7 +370,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
goto out;
}
- if (WriteFile(clients[i], sndbuf, sizeof(sndbuf), &dwWritten, NULL))
+ if (WriteFile(clients[i], sndbuf, sizeof(sndbuf), &dwWritten, nullptr))
{
printf(
"%s: Error WriteFile on client end should have failed after DisconnectNamedPipe on "
@@ -393,7 +393,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
char sndbuf[PIPE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
char rcvbuf[PIPE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
- if (ReadFile(clients[i], rcvbuf, sizeof(rcvbuf), &dwRead, NULL))
+ if (ReadFile(clients[i], rcvbuf, sizeof(rcvbuf), &dwRead, nullptr))
{
printf(
"%s: Error ReadFile on client end should have failed after CloseHandle on server\n",
@@ -401,7 +401,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
goto out;
}
- if (WriteFile(clients[i], sndbuf, sizeof(sndbuf), &dwWritten, NULL))
+ if (WriteFile(clients[i], sndbuf, sizeof(sndbuf), &dwWritten, nullptr))
{
printf("%s: Error WriteFile on client end should have failed after CloseHandle on "
"server\n",
@@ -422,7 +422,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
char sndbuf[PIPE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
char rcvbuf[PIPE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
- if (ReadFile(servers[i], rcvbuf, sizeof(rcvbuf), &dwRead, NULL))
+ if (ReadFile(servers[i], rcvbuf, sizeof(rcvbuf), &dwRead, nullptr))
{
printf(
"%s: Error ReadFile on server end should have failed after CloseHandle on client\n",
@@ -430,7 +430,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg)
goto out;
}
- if (WriteFile(servers[i], sndbuf, sizeof(sndbuf), &dwWritten, NULL))
+ if (WriteFile(servers[i], sndbuf, sizeof(sndbuf), &dwWritten, nullptr))
{
printf("%s: Error WriteFile on server end should have failed after CloseHandle on "
"client\n",
@@ -462,14 +462,14 @@ out:
int TestPipeCreateNamedPipe(int argc, char* argv[])
{
- HANDLE SingleThread = NULL;
- HANDLE ClientThread = NULL;
- HANDLE ServerThread = NULL;
- HANDLE hPipe = NULL;
+ HANDLE SingleThread = nullptr;
+ HANDLE ClientThread = nullptr;
+ HANDLE ServerThread = nullptr;
+ HANDLE hPipe = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
/* Verify that CreateNamedPipe returns INVALID_HANDLE_VALUE on failure */
- hPipe = CreateNamedPipeA(NULL, 0, 0, 0, 0, 0, 0, NULL);
+ hPipe = CreateNamedPipeA(nullptr, 0, 0, 0, 0, 0, 0, nullptr);
if (hPipe != INVALID_HANDLE_VALUE)
{
printf("CreateNamedPipe unexpectedly returned %p instead of INVALID_HANDLE_VALUE (%p)\n",
@@ -480,22 +480,22 @@ int TestPipeCreateNamedPipe(int argc, char* argv[])
#ifndef _WIN32
(void)signal(SIGPIPE, SIG_IGN);
#endif
- if (!(ReadyEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(ReadyEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
printf("CreateEvent failure: (%" PRIu32 ")\n", GetLastError());
return -1;
}
- if (!(SingleThread = CreateThread(NULL, 0, named_pipe_single_thread, NULL, 0, NULL)))
+ if (!(SingleThread = CreateThread(nullptr, 0, named_pipe_single_thread, nullptr, 0, nullptr)))
{
printf("CreateThread (SingleThread) failure: (%" PRIu32 ")\n", GetLastError());
return -1;
}
- if (!(ClientThread = CreateThread(NULL, 0, named_pipe_client_thread, NULL, 0, NULL)))
+ if (!(ClientThread = CreateThread(nullptr, 0, named_pipe_client_thread, nullptr, 0, nullptr)))
{
printf("CreateThread (ClientThread) failure: (%" PRIu32 ")\n", GetLastError());
return -1;
}
- if (!(ServerThread = CreateThread(NULL, 0, named_pipe_server_thread, NULL, 0, NULL)))
+ if (!(ServerThread = CreateThread(nullptr, 0, named_pipe_server_thread, nullptr, 0, nullptr)))
{
printf("CreateThread (ServerThread) failure: (%" PRIu32 ")\n", GetLastError());
return -1;
diff --git a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c
index 6740c2656..7237eb30b 100644
--- a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c
+++ b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c
@@ -19,16 +19,16 @@ static BYTE CLIENT_MESSAGE[PIPE_BUFFER_SIZE];
static BOOL bClientSuccess = FALSE;
static BOOL bServerSuccess = FALSE;
-static HANDLE serverReadyEvent = NULL;
+static HANDLE serverReadyEvent = nullptr;
static LPTSTR lpszPipeName = _T("\\\\.\\pipe\\winpr_test_pipe_overlapped");
static DWORD WINAPI named_pipe_client_thread(LPVOID arg)
{
DWORD status = 0;
- HANDLE hEvent = NULL;
- HANDLE hNamedPipe = NULL;
- BYTE* lpReadBuffer = NULL;
+ HANDLE hEvent = nullptr;
+ HANDLE hNamedPipe = nullptr;
+ BYTE* lpReadBuffer = nullptr;
BOOL fSuccess = FALSE;
OVERLAPPED overlapped = WINPR_C_ARRAY_INIT;
DWORD nNumberOfBytesToRead = 0;
@@ -45,7 +45,7 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg)
}
/* 1: initialize overlapped structure */
- if (!(hEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
printf("client: CreateEvent failure: %" PRIu32 "\n", GetLastError());
goto finish;
@@ -54,8 +54,8 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg)
/* 2: connect to server named pipe */
- hNamedPipe = CreateFile(lpszPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
- FILE_FLAG_OVERLAPPED, NULL);
+ hNamedPipe = CreateFile(lpszPipeName, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING,
+ FILE_FLAG_OVERLAPPED, nullptr);
if (hNamedPipe == INVALID_HANDLE_VALUE)
{
@@ -68,7 +68,7 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg)
nNumberOfBytesToWrite = PIPE_BUFFER_SIZE;
NumberOfBytesTransferred = 0;
- fSuccess = WriteFile(hNamedPipe, CLIENT_MESSAGE, nNumberOfBytesToWrite, NULL, &overlapped);
+ fSuccess = WriteFile(hNamedPipe, CLIENT_MESSAGE, nNumberOfBytesToWrite, nullptr, &overlapped);
if (!fSuccess)
fSuccess = (GetLastError() == ERROR_IO_PENDING);
@@ -105,7 +105,7 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg)
nNumberOfBytesToRead = PIPE_BUFFER_SIZE;
NumberOfBytesTransferred = 0;
- fSuccess = ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, NULL, &overlapped);
+ fSuccess = ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, nullptr, &overlapped);
if (!fSuccess)
fSuccess = (GetLastError() == ERROR_IO_PENDING);
@@ -156,9 +156,9 @@ finish:
static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
{
DWORD status = 0;
- HANDLE hEvent = NULL;
- HANDLE hNamedPipe = NULL;
- BYTE* lpReadBuffer = NULL;
+ HANDLE hEvent = nullptr;
+ HANDLE hNamedPipe = nullptr;
+ BYTE* lpReadBuffer = nullptr;
OVERLAPPED overlapped = WINPR_C_ARRAY_INIT;
BOOL fSuccess = FALSE;
BOOL fConnected = FALSE;
@@ -169,7 +169,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
WINPR_UNUSED(arg);
/* 1: initialize overlapped structure */
- if (!(hEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
printf("server: CreateEvent failure: %" PRIu32 "\n", GetLastError());
(void)SetEvent(serverReadyEvent); /* unblock client thread */
@@ -182,7 +182,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
hNamedPipe =
CreateNamedPipe(lpszPipeName, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,
- PIPE_BUFFER_SIZE, PIPE_BUFFER_SIZE, 0, NULL);
+ PIPE_BUFFER_SIZE, PIPE_BUFFER_SIZE, 0, nullptr);
if (hNamedPipe == INVALID_HANDLE_VALUE)
{
@@ -247,7 +247,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
nNumberOfBytesToRead = PIPE_BUFFER_SIZE;
NumberOfBytesTransferred = 0;
- fSuccess = ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, NULL, &overlapped);
+ fSuccess = ReadFile(hNamedPipe, lpReadBuffer, nNumberOfBytesToRead, nullptr, &overlapped);
if (!fSuccess)
fSuccess = (GetLastError() == ERROR_IO_PENDING);
@@ -287,7 +287,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg)
nNumberOfBytesToWrite = PIPE_BUFFER_SIZE;
NumberOfBytesTransferred = 0;
- fSuccess = WriteFile(hNamedPipe, SERVER_MESSAGE, nNumberOfBytesToWrite, NULL, &overlapped);
+ fSuccess = WriteFile(hNamedPipe, SERVER_MESSAGE, nNumberOfBytesToWrite, nullptr, &overlapped);
if (!fSuccess)
fSuccess = (GetLastError() == ERROR_IO_PENDING);
@@ -327,25 +327,25 @@ finish:
int TestPipeCreateNamedPipeOverlapped(int argc, char* argv[])
{
- HANDLE ClientThread = NULL;
- HANDLE ServerThread = NULL;
+ HANDLE ClientThread = nullptr;
+ HANDLE ServerThread = nullptr;
int result = -1;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
FillMemory(SERVER_MESSAGE, PIPE_BUFFER_SIZE, 0xAA);
FillMemory(CLIENT_MESSAGE, PIPE_BUFFER_SIZE, 0xBB);
- if (!(serverReadyEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(serverReadyEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
printf("CreateEvent failed: %" PRIu32 "\n", GetLastError());
goto out;
}
- if (!(ClientThread = CreateThread(NULL, 0, named_pipe_client_thread, NULL, 0, NULL)))
+ if (!(ClientThread = CreateThread(nullptr, 0, named_pipe_client_thread, nullptr, 0, nullptr)))
{
printf("CreateThread (client) failed: %" PRIu32 "\n", GetLastError());
goto out;
}
- if (!(ServerThread = CreateThread(NULL, 0, named_pipe_server_thread, NULL, 0, NULL)))
+ if (!(ServerThread = CreateThread(nullptr, 0, named_pipe_server_thread, nullptr, 0, nullptr)))
{
printf("CreateThread (server) failed: %" PRIu32 "\n", GetLastError());
goto out;
diff --git a/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c b/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c
index 4661b306c..9580bfb54 100644
--- a/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c
+++ b/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c
@@ -12,13 +12,13 @@ int TestPipeCreatePipe(int argc, char* argv[])
BOOL status = 0;
DWORD dwRead = 0;
DWORD dwWrite = 0;
- HANDLE hReadPipe = NULL;
- HANDLE hWritePipe = NULL;
+ HANDLE hReadPipe = nullptr;
+ HANDLE hWritePipe = nullptr;
BYTE readBuffer[BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
BYTE writeBuffer[BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- status = CreatePipe(&hReadPipe, &hWritePipe, NULL, BUFFER_SIZE * 2);
+ status = CreatePipe(&hReadPipe, &hWritePipe, nullptr, BUFFER_SIZE * 2);
if (!status)
{
@@ -27,7 +27,7 @@ int TestPipeCreatePipe(int argc, char* argv[])
}
FillMemory(writeBuffer, sizeof(writeBuffer), 0xAA);
- status = WriteFile(hWritePipe, &writeBuffer, sizeof(writeBuffer), &dwWrite, NULL);
+ status = WriteFile(hWritePipe, &writeBuffer, sizeof(writeBuffer), &dwWrite, nullptr);
if (!status)
{
@@ -43,7 +43,7 @@ int TestPipeCreatePipe(int argc, char* argv[])
return -1;
}
- status = ReadFile(hReadPipe, &readBuffer, sizeof(readBuffer), &dwRead, NULL);
+ status = ReadFile(hReadPipe, &readBuffer, sizeof(readBuffer), &dwRead, nullptr);
if (!status)
{
diff --git a/winpr/libwinpr/pool/callback.c b/winpr/libwinpr/pool/callback.c
index ce628e4f7..d2c423c92 100644
--- a/winpr/libwinpr/pool/callback.c
+++ b/winpr/libwinpr/pool/callback.c
@@ -29,7 +29,7 @@
#ifdef _WIN32
typedef BOOL(WINAPI* pCallbackMayRunLong_t)(PTP_CALLBACK_INSTANCE pci);
static INIT_ONCE init_once_module = INIT_ONCE_STATIC_INIT;
-static pCallbackMayRunLong_t pCallbackMayRunLong = NULL;
+static pCallbackMayRunLong_t pCallbackMayRunLong = nullptr;
static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
{
@@ -44,7 +44,7 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
BOOL winpr_CallbackMayRunLong(WINPR_ATTR_UNUSED PTP_CALLBACK_INSTANCE pci)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pCallbackMayRunLong)
return pCallbackMayRunLong(pci);
#endif
diff --git a/winpr/libwinpr/pool/callback_cleanup.c b/winpr/libwinpr/pool/callback_cleanup.c
index d40ec51c9..64b76f6eb 100644
--- a/winpr/libwinpr/pool/callback_cleanup.c
+++ b/winpr/libwinpr/pool/callback_cleanup.c
@@ -64,7 +64,7 @@ VOID SetEventWhenCallbackReturns(WINPR_ATTR_UNUSED PTP_CALLBACK_INSTANCE pci,
WINPR_ATTR_UNUSED HANDLE evt)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pSetEventWhenCallbackReturns)
{
pSetEventWhenCallbackReturns(pci, evt);
@@ -79,7 +79,7 @@ VOID ReleaseSemaphoreWhenCallbackReturns(WINPR_ATTR_UNUSED PTP_CALLBACK_INSTANCE
WINPR_ATTR_UNUSED HANDLE sem, WINPR_ATTR_UNUSED DWORD crel)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pReleaseSemaphoreWhenCallbackReturns)
{
pReleaseSemaphoreWhenCallbackReturns(pci, sem, crel);
@@ -94,7 +94,7 @@ VOID ReleaseMutexWhenCallbackReturns(WINPR_ATTR_UNUSED PTP_CALLBACK_INSTANCE pci
WINPR_ATTR_UNUSED HANDLE mut)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pReleaseMutexWhenCallbackReturns)
{
pReleaseMutexWhenCallbackReturns(pci, mut);
@@ -109,7 +109,7 @@ VOID LeaveCriticalSectionWhenCallbackReturns(WINPR_ATTR_UNUSED PTP_CALLBACK_INST
WINPR_ATTR_UNUSED PCRITICAL_SECTION pcs)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pLeaveCriticalSectionWhenCallbackReturns)
{
pLeaveCriticalSectionWhenCallbackReturns(pci, pcs);
@@ -123,7 +123,7 @@ VOID FreeLibraryWhenCallbackReturns(WINPR_ATTR_UNUSED PTP_CALLBACK_INSTANCE pci,
WINPR_ATTR_UNUSED HMODULE mod)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pFreeLibraryWhenCallbackReturns)
{
pFreeLibraryWhenCallbackReturns(pci, mod);
@@ -137,7 +137,7 @@ VOID FreeLibraryWhenCallbackReturns(WINPR_ATTR_UNUSED PTP_CALLBACK_INSTANCE pci,
VOID DisassociateCurrentThreadFromCallback(WINPR_ATTR_UNUSED PTP_CALLBACK_INSTANCE pci)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pDisassociateCurrentThreadFromCallback)
{
pDisassociateCurrentThreadFromCallback(pci);
diff --git a/winpr/libwinpr/pool/cleanup_group.c b/winpr/libwinpr/pool/cleanup_group.c
index 33b854e7e..08a4f6c11 100644
--- a/winpr/libwinpr/pool/cleanup_group.c
+++ b/winpr/libwinpr/pool/cleanup_group.c
@@ -56,9 +56,9 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
PTP_CLEANUP_GROUP winpr_CreateThreadpoolCleanupGroup(void)
{
- PTP_CLEANUP_GROUP cleanupGroup = NULL;
+ PTP_CLEANUP_GROUP cleanupGroup = nullptr;
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pCreateThreadpoolCleanupGroup)
return pCreateThreadpoolCleanupGroup();
@@ -68,14 +68,14 @@ PTP_CLEANUP_GROUP winpr_CreateThreadpoolCleanupGroup(void)
cleanupGroup = (PTP_CLEANUP_GROUP)calloc(1, sizeof(TP_CLEANUP_GROUP));
if (!cleanupGroup)
- return NULL;
+ return nullptr;
cleanupGroup->groups = ArrayList_New(FALSE);
if (!cleanupGroup->groups)
{
free(cleanupGroup);
- return NULL;
+ return nullptr;
}
return cleanupGroup;
@@ -97,7 +97,7 @@ VOID winpr_CloseThreadpoolCleanupGroupMembers(WINPR_ATTR_UNUSED PTP_CLEANUP_GROU
WINPR_ATTR_UNUSED PVOID pvCleanupContext)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pCloseThreadpoolCleanupGroupMembers)
{
@@ -119,7 +119,7 @@ VOID winpr_CloseThreadpoolCleanupGroupMembers(WINPR_ATTR_UNUSED PTP_CLEANUP_GROU
VOID winpr_CloseThreadpoolCleanupGroup(PTP_CLEANUP_GROUP ptpcg)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pCloseThreadpoolCleanupGroup)
{
@@ -133,7 +133,7 @@ VOID winpr_CloseThreadpoolCleanupGroup(PTP_CLEANUP_GROUP ptpcg)
ArrayList_Free(ptpcg->groups);
if (ptpcg && ptpcg->env)
- ptpcg->env->CleanupGroup = NULL;
+ ptpcg->env->CleanupGroup = nullptr;
free(ptpcg);
#endif
diff --git a/winpr/libwinpr/pool/io.c b/winpr/libwinpr/pool/io.c
index f0364524f..d2fee9cac 100644
--- a/winpr/libwinpr/pool/io.c
+++ b/winpr/libwinpr/pool/io.c
@@ -31,7 +31,7 @@ PTP_IO winpr_CreateThreadpoolIo(WINPR_ATTR_UNUSED HANDLE fl,
WINPR_ATTR_UNUSED PTP_CALLBACK_ENVIRON pcbe)
{
WLog_ERR("TODO", "TODO: Implement");
- return NULL;
+ return nullptr;
}
VOID winpr_CloseThreadpoolIo(WINPR_ATTR_UNUSED PTP_IO pio)
diff --git a/winpr/libwinpr/pool/pool.c b/winpr/libwinpr/pool/pool.c
index fe2eb51b3..e7d5583a9 100644
--- a/winpr/libwinpr/pool/pool.c
+++ b/winpr/libwinpr/pool/pool.c
@@ -52,21 +52,21 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
#endif
static TP_POOL DEFAULT_POOL = {
- 0, /* DWORD Minimum */
- 500, /* DWORD Maximum */
- NULL, /* wArrayList* Threads */
- NULL, /* wQueue* PendingQueue */
- NULL, /* HANDLE TerminateEvent */
- NULL, /* wCountdownEvent* WorkComplete */
+ 0, /* DWORD Minimum */
+ 500, /* DWORD Maximum */
+ nullptr, /* wArrayList* Threads */
+ nullptr, /* wQueue* PendingQueue */
+ nullptr, /* HANDLE TerminateEvent */
+ nullptr, /* wCountdownEvent* WorkComplete */
};
static DWORD WINAPI thread_pool_work_func(LPVOID arg)
{
DWORD status = 0;
- PTP_POOL pool = NULL;
- PTP_WORK work = NULL;
+ PTP_POOL pool = nullptr;
+ PTP_WORK work = nullptr;
HANDLE events[2];
- PTP_CALLBACK_INSTANCE callbackInstance = NULL;
+ PTP_CALLBACK_INSTANCE callbackInstance = nullptr;
pool = (PTP_POOL)arg;
@@ -107,7 +107,7 @@ static void threads_close(void* thread)
static BOOL InitializeThreadpool(PTP_POOL pool)
{
BOOL rc = FALSE;
- wObject* obj = NULL;
+ wObject* obj = nullptr;
if (pool->Threads)
return TRUE;
@@ -118,7 +118,7 @@ static BOOL InitializeThreadpool(PTP_POOL pool)
if (!(pool->WorkComplete = CountdownEvent_New(0)))
goto fail;
- if (!(pool->TerminateEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(pool->TerminateEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
goto fail;
if (!(pool->Threads = ArrayList_New(TRUE)))
@@ -164,28 +164,28 @@ PTP_POOL GetDefaultThreadpool(void)
PTP_POOL pool = &DEFAULT_POOL;
if (!InitializeThreadpool(pool))
- return NULL;
+ return nullptr;
return pool;
}
PTP_POOL winpr_CreateThreadpool(PVOID reserved)
{
- PTP_POOL pool = NULL;
+ PTP_POOL pool = nullptr;
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pCreateThreadpool)
return pCreateThreadpool(reserved);
#else
WINPR_UNUSED(reserved);
#endif
if (!(pool = (PTP_POOL)calloc(1, sizeof(TP_POOL))))
- return NULL;
+ return nullptr;
if (!InitializeThreadpool(pool))
{
winpr_CloseThreadpool(pool);
- return NULL;
+ return nullptr;
}
return pool;
@@ -194,7 +194,7 @@ PTP_POOL winpr_CreateThreadpool(PVOID reserved)
VOID winpr_CloseThreadpool(PTP_POOL ptpp)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pCloseThreadpool)
{
pCloseThreadpool(ptpp);
@@ -221,7 +221,7 @@ BOOL winpr_SetThreadpoolThreadMinimum(PTP_POOL ptpp, DWORD cthrdMic)
{
BOOL rc = FALSE;
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pSetThreadpoolThreadMinimum)
return pSetThreadpoolThreadMinimum(ptpp, cthrdMic);
#endif
@@ -230,7 +230,7 @@ BOOL winpr_SetThreadpoolThreadMinimum(PTP_POOL ptpp, DWORD cthrdMic)
ArrayList_Lock(ptpp->Threads);
while (ArrayList_Count(ptpp->Threads) < ptpp->Minimum)
{
- HANDLE thread = CreateThread(NULL, 0, thread_pool_work_func, (void*)ptpp, 0, NULL);
+ HANDLE thread = CreateThread(nullptr, 0, thread_pool_work_func, (void*)ptpp, 0, nullptr);
if (!thread)
goto fail;
@@ -251,7 +251,7 @@ fail:
VOID winpr_SetThreadpoolThreadMaximum(PTP_POOL ptpp, DWORD cthrdMost)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pSetThreadpoolThreadMaximum)
{
pSetThreadpoolThreadMaximum(ptpp, cthrdMost);
diff --git a/winpr/libwinpr/pool/synch.c b/winpr/libwinpr/pool/synch.c
index d69ce3408..1b884a15a 100644
--- a/winpr/libwinpr/pool/synch.c
+++ b/winpr/libwinpr/pool/synch.c
@@ -30,7 +30,7 @@ PTP_WAIT winpr_CreateThreadpoolWait(WINPR_ATTR_UNUSED PTP_WAIT_CALLBACK pfnwa,
WINPR_ATTR_UNUSED PTP_CALLBACK_ENVIRON pcbe)
{
WLog_ERR("TODO", "TODO: Implement");
- return NULL;
+ return nullptr;
}
VOID winpr_CloseThreadpoolWait(WINPR_ATTR_UNUSED PTP_WAIT pwa)
diff --git a/winpr/libwinpr/pool/test/TestPoolThread.c b/winpr/libwinpr/pool/test/TestPoolThread.c
index d006ae6f8..caab91971 100644
--- a/winpr/libwinpr/pool/test/TestPoolThread.c
+++ b/winpr/libwinpr/pool/test/TestPoolThread.c
@@ -16,12 +16,12 @@
int TestPoolThread(int argc, char* argv[])
{
- TP_POOL* pool = NULL;
+ TP_POOL* pool = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- if (!(pool = CreateThreadpool(NULL)))
+ if (!(pool = CreateThreadpool(nullptr)))
{
printf("CreateThreadpool failed\n");
return -1;
diff --git a/winpr/libwinpr/pool/test/TestPoolWork.c b/winpr/libwinpr/pool/test/TestPoolWork.c
index 2159d8970..f87fa05c4 100644
--- a/winpr/libwinpr/pool/test/TestPoolWork.c
+++ b/winpr/libwinpr/pool/test/TestPoolWork.c
@@ -27,9 +27,9 @@ static void CALLBACK test_WorkCallback(PTP_CALLBACK_INSTANCE instance, void* con
static BOOL test1(void)
{
- PTP_WORK work = NULL;
+ PTP_WORK work = nullptr;
printf("Global Thread Pool\n");
- work = CreateThreadpoolWork(test_WorkCallback, "world", NULL);
+ work = CreateThreadpoolWork(test_WorkCallback, "world", nullptr);
if (!work)
{
@@ -54,13 +54,13 @@ static BOOL test1(void)
static BOOL test2(void)
{
BOOL rc = FALSE;
- PTP_POOL pool = NULL;
- PTP_WORK work = NULL;
- PTP_CLEANUP_GROUP cleanupGroup = NULL;
+ PTP_POOL pool = nullptr;
+ PTP_WORK work = nullptr;
+ PTP_CLEANUP_GROUP cleanupGroup = nullptr;
TP_CALLBACK_ENVIRON environment;
printf("Private Thread Pool\n");
- if (!(pool = CreateThreadpool(NULL)))
+ if (!(pool = CreateThreadpool(nullptr)))
{
printf("CreateThreadpool failure\n");
return FALSE;
@@ -83,7 +83,7 @@ static BOOL test2(void)
goto fail;
}
- SetThreadpoolCallbackCleanupGroup(&environment, cleanupGroup, NULL);
+ SetThreadpoolCallbackCleanupGroup(&environment, cleanupGroup, nullptr);
work = CreateThreadpoolWork(test_WorkCallback, "world", &environment);
if (!work)
@@ -101,7 +101,7 @@ fail:
if (cleanupGroup)
{
- CloseThreadpoolCleanupGroupMembers(cleanupGroup, TRUE, NULL);
+ CloseThreadpoolCleanupGroupMembers(cleanupGroup, TRUE, nullptr);
CloseThreadpoolCleanupGroup(cleanupGroup);
DestroyThreadpoolEnvironment(&environment);
/**
diff --git a/winpr/libwinpr/pool/timer.c b/winpr/libwinpr/pool/timer.c
index 393dbe3f2..613137ab4 100644
--- a/winpr/libwinpr/pool/timer.c
+++ b/winpr/libwinpr/pool/timer.c
@@ -30,7 +30,7 @@ PTP_TIMER winpr_CreateThreadpoolTimer(WINPR_ATTR_UNUSED PTP_TIMER_CALLBACK pfnti
WINPR_ATTR_UNUSED PTP_CALLBACK_ENVIRON pcbe)
{
WLog_ERR("TODO", "TODO: Implement");
- return NULL;
+ return nullptr;
}
VOID winpr_CloseThreadpoolTimer(WINPR_ATTR_UNUSED PTP_TIMER pti)
diff --git a/winpr/libwinpr/pool/work.c b/winpr/libwinpr/pool/work.c
index 63e9a0430..021da7158 100644
--- a/winpr/libwinpr/pool/work.c
+++ b/winpr/libwinpr/pool/work.c
@@ -60,20 +60,20 @@ static BOOL CALLBACK init_module(PINIT_ONCE once, PVOID param, PVOID* context)
#endif
static TP_CALLBACK_ENVIRON DEFAULT_CALLBACK_ENVIRONMENT = {
- 1, /* Version */
- NULL, /* Pool */
- NULL, /* CleanupGroup */
- NULL, /* CleanupGroupCancelCallback */
- NULL, /* RaceDll */
- NULL, /* FinalizationCallback */
- { 0 } /* Flags */
+ 1, /* Version */
+ nullptr, /* Pool */
+ nullptr, /* CleanupGroup */
+ nullptr, /* CleanupGroupCancelCallback */
+ nullptr, /* RaceDll */
+ nullptr, /* FinalizationCallback */
+ { 0 } /* Flags */
};
PTP_WORK winpr_CreateThreadpoolWork(PTP_WORK_CALLBACK pfnwk, PVOID pv, PTP_CALLBACK_ENVIRON pcbe)
{
- PTP_WORK work = NULL;
+ PTP_WORK work = nullptr;
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pCreateThreadpoolWork)
return pCreateThreadpoolWork(pfnwk, pv, pcbe);
@@ -106,7 +106,7 @@ PTP_WORK winpr_CreateThreadpoolWork(PTP_WORK_CALLBACK pfnwk, PVOID pv, PTP_CALLB
VOID winpr_CloseThreadpoolWork(PTP_WORK pwk)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pCloseThreadpoolWork)
{
@@ -127,10 +127,10 @@ VOID winpr_CloseThreadpoolWork(PTP_WORK pwk)
VOID winpr_SubmitThreadpoolWork(PTP_WORK pwk)
{
- PTP_POOL pool = NULL;
- PTP_CALLBACK_INSTANCE callbackInstance = NULL;
+ PTP_POOL pool = nullptr;
+ PTP_CALLBACK_INSTANCE callbackInstance = nullptr;
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pSubmitThreadpoolWork)
{
@@ -160,7 +160,7 @@ BOOL winpr_TrySubmitThreadpoolCallback(WINPR_ATTR_UNUSED PTP_SIMPLE_CALLBACK pfn
WINPR_ATTR_UNUSED PTP_CALLBACK_ENVIRON pcbe)
{
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pTrySubmitThreadpoolCallback)
return pTrySubmitThreadpoolCallback(pfns, pv, pcbe);
@@ -173,11 +173,11 @@ BOOL winpr_TrySubmitThreadpoolCallback(WINPR_ATTR_UNUSED PTP_SIMPLE_CALLBACK pfn
VOID winpr_WaitForThreadpoolWorkCallbacks(PTP_WORK pwk,
WINPR_ATTR_UNUSED BOOL fCancelPendingCallbacks)
{
- HANDLE event = NULL;
- PTP_POOL pool = NULL;
+ HANDLE event = nullptr;
+ PTP_POOL pool = nullptr;
#ifdef _WIN32
- InitOnceExecuteOnce(&init_once_module, init_module, NULL, NULL);
+ InitOnceExecuteOnce(&init_once_module, init_module, nullptr, nullptr);
if (pWaitForThreadpoolWorkCallbacks)
{
diff --git a/winpr/libwinpr/registry/registry.c b/winpr/libwinpr/registry/registry.c
index 89c41fcb5..d91f931a4 100644
--- a/winpr/libwinpr/registry/registry.c
+++ b/winpr/libwinpr/registry/registry.c
@@ -42,7 +42,7 @@
#include "../log.h"
#define TAG WINPR_TAG("registry")
-static Reg* instance = NULL;
+static Reg* instance = nullptr;
static size_t regsz_length(const char* key, const void* value, bool unicode)
{
@@ -290,7 +290,7 @@ LONG RegOpenCurrentUser(WINPR_ATTR_UNUSED REGSAM samDesired, WINPR_ATTR_UNUSED P
LONG RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
{
LONG rc = 0;
- char* str = ConvertWCharToUtf8Alloc(lpSubKey, NULL);
+ char* str = ConvertWCharToUtf8Alloc(lpSubKey, nullptr);
if (!str)
return ERROR_FILE_NOT_FOUND;
@@ -316,7 +316,7 @@ LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, WINPR_ATTR_UNUSED DWORD ulOptions
WINPR_ASSERT(reg->root_key);
RegKey* pKey = reg->root_key->subkeys;
- while (pKey != NULL)
+ while (pKey != nullptr)
{
WINPR_ASSERT(lpSubKey);
@@ -329,7 +329,7 @@ LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, WINPR_ATTR_UNUSED DWORD ulOptions
pKey = pKey->next;
}
- *phkResult = NULL;
+ *phkResult = nullptr;
return ERROR_FILE_NOT_FOUND;
}
@@ -371,7 +371,7 @@ LONG RegQueryInfoKeyA(WINPR_ATTR_UNUSED HKEY hKey, WINPR_ATTR_UNUSED LPSTR lpCla
static LONG reg_read_int(const RegVal* pValue, LPBYTE lpData, LPDWORD lpcbData)
{
- const BYTE* ptr = NULL;
+ const BYTE* ptr = nullptr;
DWORD required = 0;
WINPR_ASSERT(pValue);
@@ -402,7 +402,7 @@ static LONG reg_read_int(const RegVal* pValue, LPBYTE lpData, LPDWORD lpcbData)
}
}
- if (lpData != NULL)
+ if (lpData != nullptr)
{
DWORD size = 0;
WINPR_ASSERT(lpcbData);
@@ -413,7 +413,7 @@ static LONG reg_read_int(const RegVal* pValue, LPBYTE lpData, LPDWORD lpcbData)
return ERROR_MORE_DATA;
memcpy(lpData, ptr, required);
}
- else if (lpcbData != NULL)
+ else if (lpcbData != nullptr)
*lpcbData = required;
return ERROR_SUCCESS;
}
@@ -424,22 +424,22 @@ LONG RegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWOR
// NOLINTEND(readability-non-const-parameter)
{
LONG status = ERROR_FILE_NOT_FOUND;
- RegKey* key = NULL;
- RegVal* pValue = NULL;
- char* valueName = NULL;
+ RegKey* key = nullptr;
+ RegVal* pValue = nullptr;
+ char* valueName = nullptr;
WINPR_UNUSED(lpReserved);
key = (RegKey*)hKey;
WINPR_ASSERT(key);
- valueName = ConvertWCharToUtf8Alloc(lpValueName, NULL);
+ valueName = ConvertWCharToUtf8Alloc(lpValueName, nullptr);
if (!valueName)
goto end;
pValue = key->values;
- while (pValue != NULL)
+ while (pValue != nullptr)
{
if (strcmp(pValue->name, valueName) == 0)
{
@@ -459,7 +459,7 @@ LONG RegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWOR
regsz_length(pValue->name, pValue->data.string, TRUE) * sizeof(WCHAR);
status = ERROR_SUCCESS;
- if (lpData != NULL)
+ if (lpData != nullptr)
{
DWORD size = 0;
union
@@ -503,8 +503,8 @@ LONG RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD
LPBYTE lpData, LPDWORD lpcbData)
// NOLINTEND(readability-non-const-parameter)
{
- RegKey* key = NULL;
- RegVal* pValue = NULL;
+ RegKey* key = nullptr;
+ RegVal* pValue = nullptr;
WINPR_UNUSED(lpReserved);
@@ -513,7 +513,7 @@ LONG RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD
pValue = key->values;
- while (pValue != NULL)
+ while (pValue != nullptr)
{
if (strcmp(pValue->name, lpValueName) == 0)
{
@@ -532,7 +532,7 @@ LONG RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD
char* pData = (char*)lpData;
- if (pData != NULL)
+ if (pData != nullptr)
{
DWORD size = 0;
WINPR_ASSERT(lpcbData);
diff --git a/winpr/libwinpr/registry/registry_reg.c b/winpr/libwinpr/registry/registry_reg.c
index 6f97296a9..76a43c401 100644
--- a/winpr/libwinpr/registry/registry_reg.c
+++ b/winpr/libwinpr/registry/registry_reg.c
@@ -88,7 +88,7 @@ static char* reg_data_type_string(DWORD type)
static BOOL reg_load_start(Reg* reg)
{
- char* buffer = NULL;
+ char* buffer = nullptr;
INT64 file_size = 0;
WINPR_ASSERT(reg);
@@ -99,8 +99,8 @@ static BOOL reg_load_start(Reg* reg)
file_size = _ftelli64(reg->fp);
if (_fseeki64(reg->fp, 0, SEEK_SET) != 0)
return FALSE;
- reg->line = NULL;
- reg->next_line = NULL;
+ reg->line = nullptr;
+ reg->next_line = nullptr;
if (file_size < 1)
return FALSE;
@@ -128,7 +128,7 @@ static void reg_load_finish(Reg* reg)
if (reg->buffer)
{
free(reg->buffer);
- reg->buffer = NULL;
+ reg->buffer = nullptr;
}
}
@@ -136,10 +136,10 @@ static RegVal* reg_load_value(const Reg* reg, RegKey* key)
{
const char* p[5] = WINPR_C_ARRAY_INIT;
size_t length = 0;
- char* name = NULL;
- const char* type = NULL;
- const char* data = NULL;
- RegVal* value = NULL;
+ char* name = nullptr;
+ const char* type = nullptr;
+ const char* data = nullptr;
+ RegVal* value = nullptr;
WINPR_ASSERT(reg);
WINPR_ASSERT(key);
@@ -148,7 +148,7 @@ static RegVal* reg_load_value(const Reg* reg, RegKey* key)
p[0] = reg->line + 1;
p[1] = strstr(p[0], "\"=");
if (!p[1])
- return NULL;
+ return nullptr;
p[2] = p[1] + 2;
type = p[2];
@@ -159,7 +159,7 @@ static RegVal* reg_load_value(const Reg* reg, RegKey* key)
p[3] = strchr(p[2], ':');
if (!p[3])
- return NULL;
+ return nullptr;
data = p[3] + 1;
length = (size_t)(p[1] - p[0]);
@@ -200,7 +200,7 @@ static RegVal* reg_load_value(const Reg* reg, RegKey* key)
{
unsigned long val = 0;
errno = 0;
- val = strtoul(data, NULL, 0);
+ val = strtoul(data, nullptr, 0);
if ((errno != 0) || (val > UINT32_MAX))
{
@@ -214,7 +214,7 @@ static RegVal* reg_load_value(const Reg* reg, RegKey* key)
{
unsigned long long val = 0;
errno = 0;
- val = strtoull(data, NULL, 0);
+ val = strtoull(data, nullptr, 0);
if ((errno != 0) || (val > UINT64_MAX))
{
@@ -263,7 +263,7 @@ static RegVal* reg_load_value(const Reg* reg, RegKey* key)
{
RegVal* pValue = key->values;
- while (pValue->next != NULL)
+ while (pValue->next != nullptr)
{
pValue = pValue->next;
}
@@ -277,7 +277,7 @@ static RegVal* reg_load_value(const Reg* reg, RegKey* key)
fail:
free(value);
free(name);
- return NULL;
+ return nullptr;
}
static BOOL reg_load_has_next_line(Reg* reg)
@@ -285,16 +285,16 @@ static BOOL reg_load_has_next_line(Reg* reg)
if (!reg)
return 0;
- return (reg->next_line != NULL) ? 1 : 0;
+ return (reg->next_line != nullptr) ? 1 : 0;
}
static char* reg_load_get_next_line(Reg* reg)
{
if (!reg)
- return NULL;
+ return nullptr;
reg->line = reg->next_line;
- reg->next_line = strtok_s(NULL, "\n", ®->saveptr);
+ reg->next_line = strtok_s(nullptr, "\n", ®->saveptr);
reg->line_length = strlen(reg->line);
return reg->line;
}
@@ -307,9 +307,9 @@ static char* reg_load_peek_next_line(Reg* reg)
static void reg_insert_key(WINPR_ATTR_UNUSED Reg* reg, RegKey* key, RegKey* subkey)
{
- char* name = NULL;
- char* path = NULL;
- char* save = NULL;
+ char* name = nullptr;
+ char* path = nullptr;
+ char* save = nullptr;
WINPR_ASSERT(reg);
WINPR_ASSERT(key);
@@ -323,7 +323,7 @@ static void reg_insert_key(WINPR_ATTR_UNUSED Reg* reg, RegKey* key, RegKey* subk
name = strtok_s(path, "\\", &save);
- while (name != NULL)
+ while (name != nullptr)
{
if (strcmp(key->name, name) == 0)
{
@@ -338,7 +338,7 @@ static void reg_insert_key(WINPR_ATTR_UNUSED Reg* reg, RegKey* key, RegKey* subk
}
}
- name = strtok_s(NULL, "\\", &save);
+ name = strtok_s(nullptr, "\\", &save);
}
free(path);
@@ -348,7 +348,7 @@ static RegKey* reg_load_key(Reg* reg, RegKey* key)
{
char* p[2];
size_t length = 0;
- RegKey* subkey = NULL;
+ RegKey* subkey = nullptr;
WINPR_ASSERT(reg);
WINPR_ASSERT(key);
@@ -357,12 +357,12 @@ static RegKey* reg_load_key(Reg* reg, RegKey* key)
p[0] = reg->line + 1;
p[1] = strrchr(p[0], ']');
if (!p[1])
- return NULL;
+ return nullptr;
subkey = (RegKey*)calloc(1, sizeof(RegKey));
if (!subkey)
- return NULL;
+ return nullptr;
length = (size_t)(p[1] - p[0]);
subkey->name = (char*)malloc(length + 1);
@@ -370,7 +370,7 @@ static RegKey* reg_load_key(Reg* reg, RegKey* key)
if (!subkey->name)
{
free(subkey);
- return NULL;
+ return nullptr;
}
memcpy(subkey->name, p[0], length);
@@ -401,7 +401,7 @@ static RegKey* reg_load_key(Reg* reg, RegKey* key)
{
RegKey* pKey = key->subkeys;
- while (pKey->next != NULL)
+ while (pKey->next != nullptr)
{
pKey = pKey->next;
}
@@ -449,14 +449,14 @@ static void reg_unload_value(WINPR_ATTR_UNUSED Reg* reg, RegVal* value)
static void reg_unload_key(Reg* reg, RegKey* key)
{
- RegVal* pValue = NULL;
+ RegVal* pValue = nullptr;
WINPR_ASSERT(reg);
WINPR_ASSERT(key);
pValue = key->values;
- while (pValue != NULL)
+ while (pValue != nullptr)
{
RegVal* pValueNext = pValue->next;
reg_unload_value(reg, pValue);
@@ -474,7 +474,7 @@ static void reg_unload(Reg* reg)
{
RegKey* pKey = reg->root_key->subkeys;
- while (pKey != NULL)
+ while (pKey != nullptr)
{
RegKey* pKeyNext = pKey->next;
reg_unload_key(reg, pKey);
@@ -490,7 +490,7 @@ Reg* reg_open(BOOL read_only)
Reg* reg = (Reg*)calloc(1, sizeof(Reg));
if (!reg)
- return NULL;
+ return nullptr;
reg->read_only = read_only;
reg->filename = winpr_GetConfigFilePath(TRUE, "HKLM.reg");
@@ -515,15 +515,15 @@ Reg* reg_open(BOOL read_only)
if (!reg->root_key)
goto fail;
- reg->root_key->values = NULL;
- reg->root_key->subkeys = NULL;
+ reg->root_key->values = nullptr;
+ reg->root_key->subkeys = nullptr;
reg->root_key->name = "HKEY_LOCAL_MACHINE";
reg_load(reg);
return reg;
fail:
reg_close(reg);
- return NULL;
+ return nullptr;
}
void reg_close(Reg* reg)
diff --git a/winpr/libwinpr/shell/shell.c b/winpr/libwinpr/shell/shell.c
index 982d6d780..6d5724470 100644
--- a/winpr/libwinpr/shell/shell.c
+++ b/winpr/libwinpr/shell/shell.c
@@ -46,7 +46,7 @@
BOOL GetUserProfileDirectoryA(HANDLE hToken, LPSTR lpProfileDir, LPDWORD lpcchSize)
{
struct passwd pwd = WINPR_C_ARRAY_INIT;
- struct passwd* pw = NULL;
+ struct passwd* pw = nullptr;
WINPR_ACCESS_TOKEN* token = (WINPR_ACCESS_TOKEN*)hToken;
if (!AccessTokenIsValid(hToken))
@@ -105,7 +105,7 @@ BOOL GetUserProfileDirectoryW(HANDLE hToken, LPWSTR lpProfileDir, LPDWORD lpcchS
{
BOOL bStatus = 0;
DWORD cchSizeA = 0;
- LPSTR lpProfileDirA = NULL;
+ LPSTR lpProfileDirA = nullptr;
if (!lpcchSize)
{
@@ -114,13 +114,13 @@ BOOL GetUserProfileDirectoryW(HANDLE hToken, LPWSTR lpProfileDir, LPDWORD lpcchS
}
cchSizeA = *lpcchSize;
- lpProfileDirA = NULL;
+ lpProfileDirA = nullptr;
if (lpProfileDir)
{
lpProfileDirA = (LPSTR)malloc(cchSizeA);
- if (lpProfileDirA == NULL)
+ if (lpProfileDirA == nullptr)
{
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
diff --git a/winpr/libwinpr/smartcard/smartcard.c b/winpr/libwinpr/smartcard/smartcard.c
index 67806ac95..453e906cf 100644
--- a/winpr/libwinpr/smartcard/smartcard.c
+++ b/winpr/libwinpr/smartcard/smartcard.c
@@ -37,44 +37,47 @@
#endif
static INIT_ONCE g_Initialized = INIT_ONCE_STATIC_INIT;
-static const SCardApiFunctionTable* g_SCardApi = NULL;
+static const SCardApiFunctionTable* g_SCardApi = nullptr;
#define TAG WINPR_TAG("smartcard")
#define xstr(s) str(s)
#define str(s) #s
-#define SCARDAPI_STUB_CALL_LONG(_name, ...) \
- InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, NULL, NULL); \
- if (!g_SCardApi || !g_SCardApi->pfn##_name) \
- { \
- WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
- WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi), \
- WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi ? g_SCardApi->pfn##_name : NULL)); \
- return SCARD_E_NO_SERVICE; \
- } \
+#define SCARDAPI_STUB_CALL_LONG(_name, ...) \
+ InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, nullptr, nullptr); \
+ if (!g_SCardApi || !g_SCardApi->pfn##_name) \
+ { \
+ WLog_DBG( \
+ TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
+ WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi), \
+ WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi ? g_SCardApi->pfn##_name : nullptr)); \
+ return SCARD_E_NO_SERVICE; \
+ } \
return g_SCardApi->pfn##_name(__VA_ARGS__)
-#define SCARDAPI_STUB_CALL_HANDLE(_name) \
- InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, NULL, NULL); \
- if (!g_SCardApi || !g_SCardApi->pfn##_name) \
- { \
- WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
- WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi), \
- WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi ? g_SCardApi->pfn##_name : NULL)); \
- return NULL; \
- } \
+#define SCARDAPI_STUB_CALL_HANDLE(_name) \
+ InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, nullptr, nullptr); \
+ if (!g_SCardApi || !g_SCardApi->pfn##_name) \
+ { \
+ WLog_DBG( \
+ TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
+ WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi), \
+ WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi ? g_SCardApi->pfn##_name : nullptr)); \
+ return nullptr; \
+ } \
return g_SCardApi->pfn##_name()
-#define SCARDAPI_STUB_CALL_VOID(_name) \
- InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, NULL, NULL); \
- if (!g_SCardApi || !g_SCardApi->pfn##_name) \
- { \
- WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
- WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi), \
- WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi ? g_SCardApi->pfn##_name : NULL)); \
- return; \
- } \
+#define SCARDAPI_STUB_CALL_VOID(_name) \
+ InitOnceExecuteOnce(&g_Initialized, InitializeSCardApiStubs, nullptr, nullptr); \
+ if (!g_SCardApi || !g_SCardApi->pfn##_name) \
+ { \
+ WLog_DBG( \
+ TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
+ WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi), \
+ WINPR_CXX_COMPAT_CAST(const void*, g_SCardApi ? g_SCardApi->pfn##_name : nullptr)); \
+ return; \
+ } \
g_SCardApi->pfn##_name()
/**
@@ -1064,7 +1067,7 @@ WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState)
char* buffer = calloc(size, sizeof(char));
if (!buffer)
- return NULL;
+ return nullptr;
if (dwReaderState & SCARD_STATE_IGNORE)
winpr_str_append("SCARD_STATE_IGNORE", buffer, size, "|");
diff --git a/winpr/libwinpr/smartcard/smartcard_inspect.c b/winpr/libwinpr/smartcard/smartcard_inspect.c
index 6b3ffff74..1b731fa89 100644
--- a/winpr/libwinpr/smartcard/smartcard_inspect.c
+++ b/winpr/libwinpr/smartcard/smartcard_inspect.c
@@ -40,7 +40,7 @@
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
{ \
WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
- g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
+ g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : nullptr); \
status = SCARD_E_NO_SERVICE; \
} \
else \
@@ -50,8 +50,8 @@
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
{ \
WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
- g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
- status = NULL; \
+ g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : nullptr); \
+ status = nullptr; \
} \
else \
status = g_SCardApi->pfn##_name(__VA_ARGS__)
@@ -60,15 +60,15 @@
if (!g_SCardApi || !g_SCardApi->pfn##_name) \
{ \
WLog_DBG(TAG, "Missing function pointer g_SCardApi=%p->" xstr(pfn##_name) "=%p", \
- g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : NULL); \
+ g_SCardApi, g_SCardApi ? g_SCardApi->pfn##_name : nullptr); \
} \
else \
g_SCardApi->pfn##_name(__VA_ARGS__)
static const DWORD g_LogLevel = WLOG_DEBUG;
-static wLog* g_Log = NULL;
+static wLog* g_Log = nullptr;
-static const SCardApiFunctionTable* g_SCardApi = NULL;
+static const SCardApiFunctionTable* g_SCardApi = nullptr;
/**
* Standard Windows Smart Card API
@@ -599,7 +599,7 @@ static LONG WINAPI Inspect_SCardFreeMemory(SCARDCONTEXT hContext, LPVOID pvMem)
static HANDLE WINAPI Inspect_SCardAccessStartedEvent(void)
{
- HANDLE hEvent = NULL;
+ HANDLE hEvent = nullptr;
WLog_Print(g_Log, g_LogLevel, "SCardAccessStartedEvent {");
diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.c b/winpr/libwinpr/smartcard/smartcard_pcsc.c
index 1559418f0..95096a1b5 100644
--- a/winpr/libwinpr/smartcard/smartcard_pcsc.c
+++ b/winpr/libwinpr/smartcard/smartcard_pcsc.c
@@ -217,10 +217,10 @@ typedef struct
SCARDCONTEXT hSharedContext;
} PCSC_SCARDHANDLE;
-static HMODULE g_PCSCModule = NULL;
+static HMODULE g_PCSCModule = nullptr;
static PCSCFunctionTable g_PCSC = WINPR_C_ARRAY_INIT;
-static HANDLE g_StartedEvent = NULL;
+static HANDLE g_StartedEvent = nullptr;
static int g_StartedEventRefCount = 0;
static BOOL g_SCardAutoAllocate = FALSE;
@@ -230,9 +230,9 @@ static BOOL g_PnP_Notification = TRUE;
static unsigned int OSXVersion = 0;
#endif
-static wListDictionary* g_CardHandles = NULL;
-static wListDictionary* g_CardContexts = NULL;
-static wListDictionary* g_MemoryBlocks = NULL;
+static wListDictionary* g_CardHandles = nullptr;
+static wListDictionary* g_CardContexts = nullptr;
+static wListDictionary* g_MemoryBlocks = nullptr;
static const char SMARTCARD_PNP_NOTIFICATION_A[] = "\\\\?PnP?\\Notification";
@@ -251,7 +251,7 @@ static LONG WINAPI PCSC_SCardReleaseContext_Internal(SCARDCONTEXT hContext);
static LONG PCSC_SCard_LogError(const char* what)
{
- WLog_WARN(TAG, "Missing function pointer %s=NULL", what);
+ WLog_WARN(TAG, "Missing function pointer %s=nullptr", what);
return SCARD_E_UNSUPPORTED_FEATURE;
}
@@ -369,15 +369,15 @@ static DWORD PCSC_ConvertProtocolsFromWinSCard(DWORD dwProtocols)
static PCSC_SCARDCONTEXT* PCSC_GetCardContextData(SCARDCONTEXT hContext)
{
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
if (!g_CardContexts)
- return NULL;
+ return nullptr;
pContext = (PCSC_SCARDCONTEXT*)ListDictionary_GetItemValue(g_CardContexts, (void*)hContext);
if (!pContext)
- return NULL;
+ return nullptr;
return pContext;
}
@@ -392,11 +392,11 @@ static void pcsc_cache_item_free(void* ptr)
static PCSC_SCARDCONTEXT* PCSC_EstablishCardContext(SCARDCONTEXT hContext)
{
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
pContext = (PCSC_SCARDCONTEXT*)calloc(1, sizeof(PCSC_SCARDCONTEXT));
if (!pContext)
- return NULL;
+ return nullptr;
pContext->hContext = hContext;
@@ -430,12 +430,12 @@ errors:
DeleteCriticalSection(&(pContext->lock));
error_spinlock:
free(pContext);
- return NULL;
+ return nullptr;
}
static void PCSC_ReleaseCardContext(SCARDCONTEXT hContext)
{
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
pContext = PCSC_GetCardContextData(hContext);
if (!pContext)
@@ -456,7 +456,7 @@ static void PCSC_ReleaseCardContext(SCARDCONTEXT hContext)
static BOOL PCSC_LockCardContext(SCARDCONTEXT hContext)
{
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
pContext = PCSC_GetCardContextData(hContext);
if (!pContext)
@@ -471,7 +471,7 @@ static BOOL PCSC_LockCardContext(SCARDCONTEXT hContext)
static BOOL PCSC_UnlockCardContext(SCARDCONTEXT hContext)
{
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
pContext = PCSC_GetCardContextData(hContext);
if (!pContext)
@@ -486,22 +486,22 @@ static BOOL PCSC_UnlockCardContext(SCARDCONTEXT hContext)
static PCSC_SCARDHANDLE* PCSC_GetCardHandleData(SCARDHANDLE hCard)
{
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
if (!g_CardHandles)
- return NULL;
+ return nullptr;
pCard = (PCSC_SCARDHANDLE*)ListDictionary_GetItemValue(g_CardHandles, (void*)hCard);
if (!pCard)
- return NULL;
+ return nullptr;
return pCard;
}
static SCARDCONTEXT PCSC_GetCardContextFromHandle(SCARDHANDLE hCard)
{
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
pCard = PCSC_GetCardHandleData(hCard);
if (!pCard)
@@ -513,8 +513,8 @@ static SCARDCONTEXT PCSC_GetCardContextFromHandle(SCARDHANDLE hCard)
static BOOL PCSC_WaitForCardAccess(SCARDCONTEXT hContext, SCARDHANDLE hCard, BOOL shared)
{
BOOL status = TRUE;
- PCSC_SCARDHANDLE* pCard = NULL;
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
if (!hCard)
{
@@ -566,8 +566,8 @@ static BOOL PCSC_WaitForCardAccess(SCARDCONTEXT hContext, SCARDHANDLE hCard, BOO
static BOOL PCSC_ReleaseCardAccess(SCARDCONTEXT hContext, SCARDHANDLE hCard)
{
- PCSC_SCARDHANDLE* pCard = NULL;
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
if (!hCard)
{
@@ -614,20 +614,20 @@ static BOOL PCSC_ReleaseCardAccess(SCARDCONTEXT hContext, SCARDHANDLE hCard)
static PCSC_SCARDHANDLE* PCSC_ConnectCardHandle(SCARDCONTEXT hSharedContext, SCARDHANDLE hCard)
{
- PCSC_SCARDHANDLE* pCard = NULL;
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
pContext = PCSC_GetCardContextData(hSharedContext);
if (!pContext)
{
WLog_ERR(TAG, "PCSC_ConnectCardHandle: null pContext!");
- return NULL;
+ return nullptr;
}
pCard = (PCSC_SCARDHANDLE*)calloc(1, sizeof(PCSC_SCARDHANDLE));
if (!pCard)
- return NULL;
+ return nullptr;
pCard->hSharedContext = hSharedContext;
@@ -646,13 +646,13 @@ static PCSC_SCARDHANDLE* PCSC_ConnectCardHandle(SCARDCONTEXT hSharedContext, SCA
return pCard;
error:
free(pCard);
- return NULL;
+ return nullptr;
}
static void PCSC_DisconnectCardHandle(SCARDHANDLE hCard)
{
- PCSC_SCARDHANDLE* pCard = NULL;
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
pCard = PCSC_GetCardHandleData(hCard);
if (!pCard)
@@ -693,7 +693,7 @@ static void* PCSC_RemoveMemoryBlock(SCARDCONTEXT hContext, void* pvMem)
WINPR_UNUSED(hContext);
if (!g_MemoryBlocks)
- return NULL;
+ return nullptr;
return ListDictionary_Take(g_MemoryBlocks, pvMem);
}
@@ -791,7 +791,7 @@ static LONG WINAPI PCSC_SCardListReaderGroups_Internal(SCARDCONTEXT hContext, LP
if (pcchGroupsAlloc && !g_SCardAutoAllocate)
{
pcsc_cchGroups = 0;
- status = g_PCSC.pfnSCardListReaderGroups(hContext, NULL, &pcsc_cchGroups);
+ status = g_PCSC.pfnSCardListReaderGroups(hContext, nullptr, &pcsc_cchGroups);
if (status == SCARD_S_SUCCESS)
{
@@ -805,7 +805,7 @@ static LONG WINAPI PCSC_SCardListReaderGroups_Internal(SCARDCONTEXT hContext, LP
if (status != SCARD_S_SUCCESS)
{
free(tmp);
- tmp = NULL;
+ tmp = nullptr;
}
else
PCSC_AddMemoryBlock(hContext, tmp);
@@ -844,7 +844,7 @@ static LONG WINAPI PCSC_SCardListReaderGroupsA(SCARDCONTEXT hContext, LPSTR mszG
static LONG WINAPI PCSC_SCardListReaderGroupsW(SCARDCONTEXT hContext, LPWSTR mszGroups,
LPDWORD pcchGroups)
{
- LPSTR mszGroupsA = NULL;
+ LPSTR mszGroupsA = nullptr;
LPSTR* pMszGroupsA = &mszGroupsA;
LONG status = SCARD_S_SUCCESS;
@@ -886,7 +886,7 @@ static LONG WINAPI PCSC_SCardListReaders_Internal(SCARDCONTEXT hContext, LPCSTR
if (!g_PCSC.pfnSCardListReaders)
return PCSC_SCard_LogError("g_PCSC.pfnSCardListReaders");
- mszGroups = NULL; /* mszGroups is not supported by pcsc-lite */
+ mszGroups = nullptr; /* mszGroups is not supported by pcsc-lite */
if (*pcchReaders == SCARD_AUTOALLOCATE)
pcchReadersAlloc = TRUE;
@@ -896,7 +896,7 @@ static LONG WINAPI PCSC_SCardListReaders_Internal(SCARDCONTEXT hContext, LPCSTR
if (pcchReadersAlloc && !g_SCardAutoAllocate)
{
pcsc_cchReaders = 0;
- status = g_PCSC.pfnSCardListReaders(hContext, mszGroups, NULL, &pcsc_cchReaders);
+ status = g_PCSC.pfnSCardListReaders(hContext, mszGroups, nullptr, &pcsc_cchReaders);
if (status == SCARD_S_SUCCESS)
{
@@ -910,7 +910,7 @@ static LONG WINAPI PCSC_SCardListReaders_Internal(SCARDCONTEXT hContext, LPCSTR
if (status != SCARD_S_SUCCESS)
{
free(tmp);
- tmp = NULL;
+ tmp = nullptr;
}
else
PCSC_AddMemoryBlock(hContext, tmp);
@@ -938,7 +938,7 @@ static LONG WINAPI PCSC_SCardListReadersA(SCARDCONTEXT hContext, LPCSTR mszGroup
if (!hContext)
{
- status = PCSC_SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
+ status = PCSC_SCardEstablishContext(SCARD_SCOPE_SYSTEM, nullptr, nullptr, &hContext);
if (status != SCARD_S_SUCCESS)
return status;
@@ -965,8 +965,8 @@ static LONG WINAPI PCSC_SCardListReadersA(SCARDCONTEXT hContext, LPCSTR mszGroup
static LONG WINAPI PCSC_SCardListReadersW(SCARDCONTEXT hContext, LPCWSTR mszGroups,
LPWSTR mszReaders, LPDWORD pcchReaders)
{
- LPSTR mszGroupsA = NULL;
- LPSTR mszReadersA = NULL;
+ LPSTR mszGroupsA = nullptr;
+ LPSTR mszReadersA = nullptr;
LONG status = SCARD_S_SUCCESS;
BOOL nullCardContext = FALSE;
@@ -975,7 +975,7 @@ static LONG WINAPI PCSC_SCardListReadersW(SCARDCONTEXT hContext, LPCWSTR mszGrou
if (!hContext)
{
- status = PCSC_SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
+ status = PCSC_SCardEstablishContext(SCARD_SCOPE_SYSTEM, nullptr, nullptr, &hContext);
if (status != SCARD_S_SUCCESS)
return status;
@@ -988,7 +988,7 @@ static LONG WINAPI PCSC_SCardListReadersW(SCARDCONTEXT hContext, LPCWSTR mszGrou
if (mszGroups)
{
- mszGroupsA = ConvertWCharToUtf8Alloc(mszGroups, NULL);
+ mszGroupsA = ConvertWCharToUtf8Alloc(mszGroups, nullptr);
if (!mszGroupsA)
return SCARD_E_NO_MEMORY;
}
@@ -1058,16 +1058,16 @@ static const char* findCardByAtr(LPCBYTE pbAtr)
return knownAtrs[i].cardName;
}
- return NULL;
+ return nullptr;
}
static LONG WINAPI PCSC_SCardListCardsA(WINPR_ATTR_UNUSED SCARDCONTEXT hContext, LPCBYTE pbAtr,
LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount,
CHAR* mszCards, LPDWORD pcchCards)
{
- const char* cardName = NULL;
+ const char* cardName = nullptr;
DWORD outputLen = 1;
- CHAR* output = NULL;
+ CHAR* output = nullptr;
BOOL autoAllocate = 0;
if (!pbAtr || rgquidInterfaces || cguidInterfaceCount)
@@ -1118,9 +1118,9 @@ static LONG WINAPI PCSC_SCardListCardsW(WINPR_ATTR_UNUSED SCARDCONTEXT hContext,
LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount,
WCHAR* mszCards, LPDWORD pcchCards)
{
- const char* cardName = NULL;
+ const char* cardName = nullptr;
DWORD outputLen = 1;
- WCHAR* output = NULL;
+ WCHAR* output = nullptr;
BOOL autoAllocate = 0;
if (!pbAtr || rgquidInterfaces || cguidInterfaceCount)
@@ -1442,25 +1442,25 @@ static HANDLE WINAPI PCSC_SCardAccessStartedEvent(void)
LONG status = 0;
SCARDCONTEXT hContext = 0;
- status = PCSC_SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
+ status = PCSC_SCardEstablishContext(SCARD_SCOPE_SYSTEM, nullptr, nullptr, &hContext);
if (status != SCARD_S_SUCCESS)
- return NULL;
+ return nullptr;
status = PCSC_SCardReleaseContext(hContext);
if (status != SCARD_S_SUCCESS)
- return NULL;
+ return nullptr;
if (!g_StartedEvent)
{
- if (!(g_StartedEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
- return NULL;
+ if (!(g_StartedEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
+ return nullptr;
if (!SetEvent(g_StartedEvent))
{
(void)CloseHandle(g_StartedEvent);
- return NULL;
+ return nullptr;
}
}
@@ -1477,7 +1477,7 @@ static void WINAPI PCSC_SCardReleaseStartedEvent(void)
if (g_StartedEvent)
{
(void)CloseHandle(g_StartedEvent);
- g_StartedEvent = NULL;
+ g_StartedEvent = nullptr;
}
}
}
@@ -1530,9 +1530,9 @@ static LONG WINAPI PCSC_SCardGetStatusChange_Internal(SCARDCONTEXT hContext, DWO
LPSCARD_READERSTATEA rgReaderStates,
DWORD cReaders)
{
- INT64* map = NULL;
+ INT64* map = nullptr;
PCSC_DWORD cMappedReaders = 0;
- PCSC_SCARD_READERSTATE* states = NULL;
+ PCSC_SCARD_READERSTATE* states = nullptr;
PCSC_LONG status = SCARD_S_SUCCESS;
PCSC_DWORD pcsc_dwTimeout = (PCSC_DWORD)dwTimeout;
PCSC_DWORD pcsc_cReaders = (PCSC_DWORD)cReaders;
@@ -1643,7 +1643,7 @@ static LONG WINAPI PCSC_SCardGetStatusChangeA(SCARDCONTEXT hContext, DWORD dwTim
static LONG WINAPI PCSC_SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTimeout,
LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders)
{
- LPSCARD_READERSTATEA states = NULL;
+ LPSCARD_READERSTATEA states = nullptr;
LONG status = SCARD_S_SUCCESS;
if (!g_PCSC.pfnSCardGetStatusChange)
@@ -1665,7 +1665,7 @@ static LONG WINAPI PCSC_SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTim
const LPSCARD_READERSTATEW curReader = &rgReaderStates[index];
LPSCARD_READERSTATEA cur = &states[index];
- cur->szReader = ConvertWCharToUtf8Alloc(curReader->szReader, NULL);
+ cur->szReader = ConvertWCharToUtf8Alloc(curReader->szReader, nullptr);
cur->pvUserData = curReader->pvUserData;
cur->dwCurrentState = curReader->dwCurrentState;
cur->dwEventState = curReader->dwEventState;
@@ -1709,9 +1709,9 @@ static LONG WINAPI PCSC_SCardConnect_Internal(SCARDCONTEXT hContext, LPCSTR szRe
LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol)
{
BOOL shared = 0;
- const char* szReaderPCSC = NULL;
+ const char* szReaderPCSC = nullptr;
PCSC_LONG status = SCARD_S_SUCCESS;
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
PCSC_DWORD pcsc_dwShareMode = (PCSC_DWORD)dwShareMode;
PCSC_DWORD pcsc_dwPreferredProtocols = 0;
PCSC_DWORD pcsc_dwActiveProtocol = 0;
@@ -1774,7 +1774,7 @@ static LONG WINAPI PCSC_SCardConnectW(SCARDCONTEXT hContext, LPCWSTR szReader, D
DWORD dwPreferredProtocols, LPSCARDHANDLE phCard,
LPDWORD pdwActiveProtocol)
{
- LPSTR szReaderA = NULL;
+ LPSTR szReaderA = nullptr;
LONG status = SCARD_S_SUCCESS;
if (!PCSC_LockCardContext(hContext))
@@ -1782,7 +1782,7 @@ static LONG WINAPI PCSC_SCardConnectW(SCARDCONTEXT hContext, LPCWSTR szReader, D
if (szReader)
{
- szReaderA = ConvertWCharToUtf8Alloc(szReader, NULL);
+ szReaderA = ConvertWCharToUtf8Alloc(szReader, nullptr);
if (!szReaderA)
return SCARD_E_INSUFFICIENT_BUFFER;
}
@@ -1843,8 +1843,8 @@ static LONG WINAPI PCSC_SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition)
static LONG WINAPI PCSC_SCardBeginTransaction(SCARDHANDLE hCard)
{
PCSC_LONG status = SCARD_S_SUCCESS;
- PCSC_SCARDHANDLE* pCard = NULL;
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
if (!g_PCSC.pfnSCardBeginTransaction)
return PCSC_SCard_LogError("g_PCSC.pfnSCardBeginTransaction");
@@ -1871,8 +1871,8 @@ static LONG WINAPI PCSC_SCardBeginTransaction(SCARDHANDLE hCard)
static LONG WINAPI PCSC_SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition)
{
PCSC_LONG status = SCARD_S_SUCCESS;
- PCSC_SCARDHANDLE* pCard = NULL;
- PCSC_SCARDCONTEXT* pContext = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
+ PCSC_SCARDCONTEXT* pContext = nullptr;
PCSC_DWORD pcsc_dwDisposition = (PCSC_DWORD)dwDisposition;
if (!g_PCSC.pfnSCardEndTransaction)
@@ -1914,7 +1914,7 @@ static LONG WINAPI PCSC_SCardStatus_Internal(SCARDHANDLE hCard, LPSTR mszReaderN
LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen,
BOOL unicode)
{
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
SCARDCONTEXT hContext = 0;
PCSC_LONG status = 0;
PCSC_DWORD pcsc_cchReaderLen = 0;
@@ -1925,8 +1925,8 @@ static LONG WINAPI PCSC_SCardStatus_Internal(SCARDHANDLE hCard, LPSTR mszReaderN
BOOL allocateAtr = FALSE;
LPSTR readerNames = mszReaderNames;
LPBYTE atr = pbAtr;
- LPSTR tReader = NULL;
- LPBYTE tATR = NULL;
+ LPSTR tReader = nullptr;
+ LPBYTE tATR = nullptr;
if (!g_PCSC.pfnSCardStatus)
return PCSC_SCard_LogError("g_PCSC.pfnSCardStatus");
@@ -1942,8 +1942,8 @@ static LONG WINAPI PCSC_SCardStatus_Internal(SCARDHANDLE hCard, LPSTR mszReaderN
if (!hContext)
return SCARD_E_INVALID_VALUE;
- status =
- g_PCSC.pfnSCardStatus(hCard, NULL, &pcsc_cchReaderLen, NULL, NULL, NULL, &pcsc_cbAtrLen);
+ status = g_PCSC.pfnSCardStatus(hCard, nullptr, &pcsc_cchReaderLen, nullptr, nullptr, nullptr,
+ &pcsc_cbAtrLen);
if (status != STATUS_SUCCESS)
return PCSC_MapErrorCodeToWinSCard(status);
@@ -2027,7 +2027,7 @@ static LONG WINAPI PCSC_SCardStatus_Internal(SCARDHANDLE hCard, LPSTR mszReaderN
size_t size = 0;
WCHAR* tmp = ConvertMszUtf8NToWCharAlloc(tReader, pcsc_cchReaderLen + 1, &size);
- if (tmp == NULL)
+ if (tmp == nullptr)
{
status = ERROR_NOT_ENOUGH_MEMORY;
goto out_fail;
@@ -2075,9 +2075,9 @@ static LONG WINAPI PCSC_SCardState(SCARDHANDLE hCard, LPDWORD pdwState, LPDWORD
{
DWORD cchReaderLen = 0;
SCARDCONTEXT hContext = 0;
- LPSTR mszReaderNames = NULL;
+ LPSTR mszReaderNames = nullptr;
PCSC_LONG status = SCARD_S_SUCCESS;
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
DWORD pcsc_dwState = 0;
DWORD pcsc_dwProtocol = 0;
DWORD pcsc_cbAtrLen = 0;
@@ -2137,10 +2137,10 @@ static LONG WINAPI PCSC_SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pio
LPDWORD pcbRecvLength)
{
PCSC_LONG status = SCARD_S_SUCCESS;
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
PCSC_DWORD cbExtraBytes = 0;
- BYTE* pbExtraBytes = NULL;
- BYTE* pcsc_pbExtraBytes = NULL;
+ BYTE* pbExtraBytes = nullptr;
+ BYTE* pcsc_pbExtraBytes = nullptr;
PCSC_DWORD pcsc_cbSendLength = (PCSC_DWORD)cbSendLength;
PCSC_DWORD pcsc_cbRecvLength = 0;
union
@@ -2152,8 +2152,8 @@ static LONG WINAPI PCSC_SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pio
BYTE* pb;
} sendPci, recvPci, inRecvPci, inSendPci;
- sendPci.ps = NULL;
- recvPci.ps = NULL;
+ sendPci.ps = nullptr;
+ recvPci.ps = nullptr;
inRecvPci.lps = pioRecvPci;
inSendPci.lpcs = pioSendPci;
@@ -2185,8 +2185,8 @@ static LONG WINAPI PCSC_SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pio
* pcsc-lite cannot have a null pioSendPci parameter, unlike WinSCard.
* Query the current protocol and use default SCARD_IO_REQUEST for it.
*/
- status = g_PCSC.pfnSCardStatus(hCard, NULL, &cchReaderLen, &dwState, &dwProtocol, NULL,
- &cbAtrLen);
+ status = g_PCSC.pfnSCardStatus(hCard, nullptr, &cchReaderLen, &dwState, &dwProtocol,
+ nullptr, &cbAtrLen);
if (status == SCARD_S_SUCCESS)
{
@@ -2259,7 +2259,7 @@ static LONG WINAPI PCSC_SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pio
static LONG WINAPI PCSC_SCardGetTransmitCount(SCARDHANDLE hCard, LPDWORD pcTransmitCount)
{
WINPR_UNUSED(pcTransmitCount);
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
pCard = PCSC_GetCardHandleData(hCard);
@@ -2278,7 +2278,7 @@ static LONG WINAPI PCSC_SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPC
DWORD IoCtlDeviceType = 0;
BOOL getFeatureRequest = FALSE;
PCSC_LONG status = SCARD_S_SUCCESS;
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
PCSC_DWORD pcsc_dwControlCode = 0;
PCSC_DWORD pcsc_cbInBufferSize = (PCSC_DWORD)cbInBufferSize;
PCSC_DWORD pcsc_cbOutBufferSize = (PCSC_DWORD)cbOutBufferSize;
@@ -2344,7 +2344,7 @@ static LONG WINAPI PCSC_SCardGetAttrib_Internal(SCARDHANDLE hCard, DWORD dwAttrI
SCARDCONTEXT hContext = 0;
BOOL pcbAttrLenAlloc = FALSE;
PCSC_LONG status = SCARD_S_SUCCESS;
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
PCSC_DWORD pcsc_dwAttrId = (PCSC_DWORD)dwAttrId;
PCSC_DWORD pcsc_cbAttrLen = 0;
@@ -2377,7 +2377,7 @@ static LONG WINAPI PCSC_SCardGetAttrib_Internal(SCARDHANDLE hCard, DWORD dwAttrI
if (pcbAttrLenAlloc && !g_SCardAutoAllocate)
{
pcsc_cbAttrLen = 0;
- status = g_PCSC.pfnSCardGetAttrib(hCard, pcsc_dwAttrId, NULL, &pcsc_cbAttrLen);
+ status = g_PCSC.pfnSCardGetAttrib(hCard, pcsc_dwAttrId, nullptr, &pcsc_cbAttrLen);
if (status == SCARD_S_SUCCESS)
{
@@ -2391,7 +2391,7 @@ static LONG WINAPI PCSC_SCardGetAttrib_Internal(SCARDHANDLE hCard, DWORD dwAttrI
if (status != SCARD_S_SUCCESS)
{
free(tmp);
- tmp = NULL;
+ tmp = nullptr;
}
else
PCSC_AddMemoryBlock(hContext, tmp);
@@ -2411,8 +2411,8 @@ static LONG WINAPI PCSC_SCardGetAttrib_Internal(SCARDHANDLE hCard, DWORD dwAttrI
static LONG WINAPI PCSC_SCardGetAttrib_FriendlyName(SCARDHANDLE hCard, DWORD dwAttrId,
LPBYTE pbAttr, LPDWORD pcbAttrLen)
{
- char* namePCSC = NULL;
- char* pbAttrA = NULL;
+ char* namePCSC = nullptr;
+ char* pbAttrA = nullptr;
SCARDCONTEXT hContext = PCSC_GetCardContextFromHandle(hCard);
@@ -2428,7 +2428,7 @@ static LONG WINAPI PCSC_SCardGetAttrib_FriendlyName(SCARDHANDLE hCard, DWORD dwA
if (status != SCARD_S_SUCCESS)
{
- WCHAR* pbAttrW = NULL;
+ WCHAR* pbAttrW = nullptr;
*pcbAttrLen = SCARD_AUTOALLOCATE;
status = PCSC_SCardGetAttrib_Internal(hCard, SCARD_ATTR_DEVICE_FRIENDLY_NAME_W,
@@ -2437,7 +2437,7 @@ static LONG WINAPI PCSC_SCardGetAttrib_FriendlyName(SCARDHANDLE hCard, DWORD dwA
if (status != SCARD_S_SUCCESS)
return status;
- namePCSC = ConvertMszWCharNToUtf8Alloc(pbAttrW, *pcbAttrLen, NULL);
+ namePCSC = ConvertMszWCharNToUtf8Alloc(pbAttrW, *pcbAttrLen, nullptr);
PCSC_SCardFreeMemory_Internal(hContext, pbAttrW);
}
else
@@ -2519,7 +2519,7 @@ static LONG PCSC_ReadDeviceSystemNameGet(WINPR_ATTR_UNUSED SCARDCONTEXT hContext
PCSC_DWORD dwProtocol = 0;
const PCSC_LONG rc =
- g_PCSC.pfnSCardStatus(hCard, NULL, &cchReader, &dwState, &dwProtocol, NULL, &cbAtr);
+ g_PCSC.pfnSCardStatus(hCard, nullptr, &cchReader, &dwState, &dwProtocol, nullptr, &cbAtr);
if (rc != SCARD_S_SUCCESS)
return (LONG)rc;
@@ -2527,7 +2527,7 @@ static LONG PCSC_ReadDeviceSystemNameGet(WINPR_ATTR_UNUSED SCARDCONTEXT hContext
if (!tmp)
return SCARD_E_NO_MEMORY;
const PCSC_LONG rc2 =
- g_PCSC.pfnSCardStatus(hCard, tmp, &cchReader, &dwState, &dwProtocol, NULL, &cbAtr);
+ g_PCSC.pfnSCardStatus(hCard, tmp, &cchReader, &dwState, &dwProtocol, nullptr, &cbAtr);
if (rc2 != SCARD_S_SUCCESS)
{
free(tmp);
@@ -2558,7 +2558,7 @@ static LONG PCSC_ReadDeviceSystemNameGet(WINPR_ATTR_UNUSED SCARDCONTEXT hContext
static LONG PCSC_ReadDeviceSystemName(WINPR_ATTR_UNUSED SCARDCONTEXT hContext, SCARDHANDLE hCard,
DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen)
{
- BYTE* tmp = NULL;
+ BYTE* tmp = nullptr;
DWORD cbAttrLen = 0;
const LONG rc = PCSC_ReadDeviceSystemNameGet(hContext, hCard, dwAttrId, &tmp, &cbAttrLen);
if (rc != SCARD_S_SUCCESS)
@@ -2600,18 +2600,18 @@ static LONG WINAPI PCSC_SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE
BOOL pcbAttrLenAlloc = FALSE;
PCSC_LONG status = SCARD_S_SUCCESS;
- if (NULL == pcbAttrLen)
+ if (nullptr == pcbAttrLen)
return SCARD_E_INVALID_PARAMETER;
cbAttrLen = *pcbAttrLen;
if (*pcbAttrLen == SCARD_AUTOALLOCATE)
{
- if (NULL == pbAttr)
+ if (nullptr == pbAttr)
return SCARD_E_INVALID_PARAMETER;
pcbAttrLenAlloc = TRUE;
- *(BYTE**)pbAttr = NULL;
+ *(BYTE**)pbAttr = nullptr;
}
else
{
@@ -2642,7 +2642,7 @@ static LONG WINAPI PCSC_SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE
{
if (pbAttr)
{
- const char* vendorName = NULL;
+ const char* vendorName = nullptr;
/**
* pcsc-lite adds a null terminator to the vendor name,
@@ -2675,8 +2675,8 @@ static LONG WINAPI PCSC_SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE
PCSC_DWORD cbAtrLen = 0;
PCSC_DWORD dwProtocol = 0;
PCSC_DWORD cchReaderLen = 0;
- status = g_PCSC.pfnSCardStatus(hCard, NULL, &cchReaderLen, &dwState, &dwProtocol,
- NULL, &cbAtrLen);
+ status = g_PCSC.pfnSCardStatus(hCard, nullptr, &cchReaderLen, &dwState, &dwProtocol,
+ nullptr, &cbAtrLen);
if (status == SCARD_S_SUCCESS)
{
@@ -2779,7 +2779,7 @@ static LONG WINAPI PCSC_SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYT
DWORD cbAttrLen)
{
PCSC_LONG status = SCARD_S_SUCCESS;
- PCSC_SCARDHANDLE* pCard = NULL;
+ PCSC_SCARDHANDLE* pCard = nullptr;
PCSC_DWORD pcsc_dwAttrId = (PCSC_DWORD)dwAttrId;
PCSC_DWORD pcsc_cbAttrLen = (PCSC_DWORD)cbAttrLen;
@@ -2835,7 +2835,7 @@ static char* card_id_and_name_a(const UUID* CardIdentifier, LPCSTR LookupName)
size_t len = strlen(LookupName) + 34;
char* id = malloc(len);
if (!id)
- return NULL;
+ return nullptr;
(void)snprintf(id, len, "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X\\%s",
CardIdentifier->Data1, CardIdentifier->Data2, CardIdentifier->Data3,
@@ -2847,10 +2847,10 @@ static char* card_id_and_name_a(const UUID* CardIdentifier, LPCSTR LookupName)
static char* card_id_and_name_w(const UUID* CardIdentifier, LPCWSTR LookupName)
{
- char* res = NULL;
- char* tmp = ConvertWCharToUtf8Alloc(LookupName, NULL);
+ char* res = nullptr;
+ char* tmp = ConvertWCharToUtf8Alloc(LookupName, nullptr);
if (!tmp)
- return NULL;
+ return nullptr;
res = card_id_and_name_a(CardIdentifier, tmp);
free(tmp);
return res;
@@ -2860,7 +2860,7 @@ static LONG WINAPI PCSC_SCardReadCacheA(SCARDCONTEXT hContext, UUID* CardIdentif
DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data,
DWORD* DataLen)
{
- PCSC_CACHE_ITEM* data = NULL;
+ PCSC_CACHE_ITEM* data = nullptr;
PCSC_SCARDCONTEXT* ctx = PCSC_GetCardContextData(hContext);
if (!ctx)
return SCARD_E_INVALID_HANDLE;
@@ -2906,7 +2906,7 @@ static LONG WINAPI PCSC_SCardReadCacheW(SCARDCONTEXT hContext, UUID* CardIdentif
DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data,
DWORD* DataLen)
{
- PCSC_CACHE_ITEM* data = NULL;
+ PCSC_CACHE_ITEM* data = nullptr;
PCSC_SCARDCONTEXT* ctx = PCSC_GetCardContextData(hContext);
if (!ctx)
return SCARD_E_INVALID_HANDLE;
@@ -2953,9 +2953,9 @@ static LONG WINAPI PCSC_SCardWriteCacheA(SCARDCONTEXT hContext, UUID* CardIdenti
DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data,
DWORD DataLen)
{
- PCSC_CACHE_ITEM* data = NULL;
+ PCSC_CACHE_ITEM* data = nullptr;
PCSC_SCARDCONTEXT* ctx = PCSC_GetCardContextData(hContext);
- char* id = NULL;
+ char* id = nullptr;
if (!ctx)
return SCARD_E_FILE_NOT_FOUND;
@@ -3000,9 +3000,9 @@ static LONG WINAPI PCSC_SCardWriteCacheW(SCARDCONTEXT hContext, UUID* CardIdenti
DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data,
DWORD DataLen)
{
- PCSC_CACHE_ITEM* data = NULL;
+ PCSC_CACHE_ITEM* data = nullptr;
PCSC_SCARDCONTEXT* ctx = PCSC_GetCardContextData(hContext);
- char* id = NULL;
+ char* id = nullptr;
if (!ctx)
return SCARD_E_FILE_NOT_FOUND;
@@ -3148,18 +3148,18 @@ unsigned int determineMacOSXVersion(void)
{
int mib[2];
size_t len = 0;
- char* kernelVersion = NULL;
- char* tok = NULL;
+ char* kernelVersion = nullptr;
+ char* tok = nullptr;
unsigned int version = 0;
long majorVersion = 0;
long minorVersion = 0;
long patchVersion = 0;
int count = 0;
- char* context = NULL;
+ char* context = nullptr;
mib[0] = CTL_KERN;
mib[1] = KERN_OSRELEASE;
- if (sysctl(mib, 2, NULL, &len, NULL, 0) != 0)
+ if (sysctl(mib, 2, nullptr, &len, nullptr, 0) != 0)
return 0;
kernelVersion = calloc(len, sizeof(char));
@@ -3167,7 +3167,7 @@ unsigned int determineMacOSXVersion(void)
if (!kernelVersion)
return 0;
- if (sysctl(mib, 2, kernelVersion, &len, NULL, 0) != 0)
+ if (sysctl(mib, 2, kernelVersion, &len, nullptr, 0) != 0)
{
free(kernelVersion);
return 0;
@@ -3181,7 +3181,7 @@ unsigned int determineMacOSXVersion(void)
switch (count)
{
case 0:
- majorVersion = strtol(tok, NULL, 0);
+ majorVersion = strtol(tok, nullptr, 0);
if (errno != 0)
goto fail;
@@ -3189,7 +3189,7 @@ unsigned int determineMacOSXVersion(void)
break;
case 1:
- minorVersion = strtol(tok, NULL, 0);
+ minorVersion = strtol(tok, nullptr, 0);
if (errno != 0)
goto fail;
@@ -3197,7 +3197,7 @@ unsigned int determineMacOSXVersion(void)
break;
case 2:
- patchVersion = strtol(tok, NULL, 0);
+ patchVersion = strtol(tok, nullptr, 0);
if (errno != 0)
goto fail;
@@ -3205,7 +3205,7 @@ unsigned int determineMacOSXVersion(void)
break;
}
- tok = strtok_s(NULL, ".", &context);
+ tok = strtok_s(nullptr, ".", &context);
count++;
}
@@ -3443,7 +3443,7 @@ int PCSC_InitializeSCardApi(void)
WINSCARD_LOAD_PROC(g_PCSCModule, g_PCSC, SCardCancel);
WINSCARD_LOAD_PROC(g_PCSCModule, g_PCSC, SCardGetAttrib);
WINSCARD_LOAD_PROC(g_PCSCModule, g_PCSC, SCardSetAttrib);
- g_PCSC.pfnSCardFreeMemory = NULL;
+ g_PCSC.pfnSCardFreeMemory = nullptr;
#ifndef __APPLE__
WINSCARD_LOAD_PROC(g_PCSCModule, g_PCSC, SCardFreeMemory);
#endif
@@ -3452,7 +3452,7 @@ int PCSC_InitializeSCardApi(void)
g_SCardAutoAllocate = TRUE;
#ifdef DISABLE_PCSC_SCARD_AUTOALLOCATE
- g_PCSC.pfnSCardFreeMemory = NULL;
+ g_PCSC.pfnSCardFreeMemory = nullptr;
g_SCardAutoAllocate = FALSE;
#endif
#ifdef __APPLE__
diff --git a/winpr/libwinpr/smartcard/smartcard_windows.c b/winpr/libwinpr/smartcard/smartcard_windows.c
index 967a2a0d0..0ce5d9b6e 100644
--- a/winpr/libwinpr/smartcard/smartcard_windows.c
+++ b/winpr/libwinpr/smartcard/smartcard_windows.c
@@ -25,88 +25,88 @@
#include "smartcard_windows.h"
-static HMODULE g_WinSCardModule = NULL;
+static HMODULE g_WinSCardModule = nullptr;
static SCardApiFunctionTable Windows_SCardApiFunctionTable = {
0, /* dwVersion */
0, /* dwFlags */
- NULL, /* SCardEstablishContext */
- NULL, /* SCardReleaseContext */
- NULL, /* SCardIsValidContext */
- NULL, /* SCardListReaderGroupsA */
- NULL, /* SCardListReaderGroupsW */
- NULL, /* SCardListReadersA */
- NULL, /* SCardListReadersW */
- NULL, /* SCardListCardsA */
- NULL, /* SCardListCardsW */
- NULL, /* SCardListInterfacesA */
- NULL, /* SCardListInterfacesW */
- NULL, /* SCardGetProviderIdA */
- NULL, /* SCardGetProviderIdW */
- NULL, /* SCardGetCardTypeProviderNameA */
- NULL, /* SCardGetCardTypeProviderNameW */
- NULL, /* SCardIntroduceReaderGroupA */
- NULL, /* SCardIntroduceReaderGroupW */
- NULL, /* SCardForgetReaderGroupA */
- NULL, /* SCardForgetReaderGroupW */
- NULL, /* SCardIntroduceReaderA */
- NULL, /* SCardIntroduceReaderW */
- NULL, /* SCardForgetReaderA */
- NULL, /* SCardForgetReaderW */
- NULL, /* SCardAddReaderToGroupA */
- NULL, /* SCardAddReaderToGroupW */
- NULL, /* SCardRemoveReaderFromGroupA */
- NULL, /* SCardRemoveReaderFromGroupW */
- NULL, /* SCardIntroduceCardTypeA */
- NULL, /* SCardIntroduceCardTypeW */
- NULL, /* SCardSetCardTypeProviderNameA */
- NULL, /* SCardSetCardTypeProviderNameW */
- NULL, /* SCardForgetCardTypeA */
- NULL, /* SCardForgetCardTypeW */
- NULL, /* SCardFreeMemory */
- NULL, /* SCardAccessStartedEvent */
- NULL, /* SCardReleaseStartedEvent */
- NULL, /* SCardLocateCardsA */
- NULL, /* SCardLocateCardsW */
- NULL, /* SCardLocateCardsByATRA */
- NULL, /* SCardLocateCardsByATRW */
- NULL, /* SCardGetStatusChangeA */
- NULL, /* SCardGetStatusChangeW */
- NULL, /* SCardCancel */
- NULL, /* SCardConnectA */
- NULL, /* SCardConnectW */
- NULL, /* SCardReconnect */
- NULL, /* SCardDisconnect */
- NULL, /* SCardBeginTransaction */
- NULL, /* SCardEndTransaction */
- NULL, /* SCardCancelTransaction */
- NULL, /* SCardState */
- NULL, /* SCardStatusA */
- NULL, /* SCardStatusW */
- NULL, /* SCardTransmit */
- NULL, /* SCardGetTransmitCount */
- NULL, /* SCardControl */
- NULL, /* SCardGetAttrib */
- NULL, /* SCardSetAttrib */
- NULL, /* SCardUIDlgSelectCardA */
- NULL, /* SCardUIDlgSelectCardW */
- NULL, /* GetOpenCardNameA */
- NULL, /* GetOpenCardNameW */
- NULL, /* SCardDlgExtendedError */
- NULL, /* SCardReadCacheA */
- NULL, /* SCardReadCacheW */
- NULL, /* SCardWriteCacheA */
- NULL, /* SCardWriteCacheW */
- NULL, /* SCardGetReaderIconA */
- NULL, /* SCardGetReaderIconW */
- NULL, /* SCardGetDeviceTypeIdA */
- NULL, /* SCardGetDeviceTypeIdW */
- NULL, /* SCardGetReaderDeviceInstanceIdA */
- NULL, /* SCardGetReaderDeviceInstanceIdW */
- NULL, /* SCardListReadersWithDeviceInstanceIdA */
- NULL, /* SCardListReadersWithDeviceInstanceIdW */
- NULL /* SCardAudit */
+ nullptr, /* SCardEstablishContext */
+ nullptr, /* SCardReleaseContext */
+ nullptr, /* SCardIsValidContext */
+ nullptr, /* SCardListReaderGroupsA */
+ nullptr, /* SCardListReaderGroupsW */
+ nullptr, /* SCardListReadersA */
+ nullptr, /* SCardListReadersW */
+ nullptr, /* SCardListCardsA */
+ nullptr, /* SCardListCardsW */
+ nullptr, /* SCardListInterfacesA */
+ nullptr, /* SCardListInterfacesW */
+ nullptr, /* SCardGetProviderIdA */
+ nullptr, /* SCardGetProviderIdW */
+ nullptr, /* SCardGetCardTypeProviderNameA */
+ nullptr, /* SCardGetCardTypeProviderNameW */
+ nullptr, /* SCardIntroduceReaderGroupA */
+ nullptr, /* SCardIntroduceReaderGroupW */
+ nullptr, /* SCardForgetReaderGroupA */
+ nullptr, /* SCardForgetReaderGroupW */
+ nullptr, /* SCardIntroduceReaderA */
+ nullptr, /* SCardIntroduceReaderW */
+ nullptr, /* SCardForgetReaderA */
+ nullptr, /* SCardForgetReaderW */
+ nullptr, /* SCardAddReaderToGroupA */
+ nullptr, /* SCardAddReaderToGroupW */
+ nullptr, /* SCardRemoveReaderFromGroupA */
+ nullptr, /* SCardRemoveReaderFromGroupW */
+ nullptr, /* SCardIntroduceCardTypeA */
+ nullptr, /* SCardIntroduceCardTypeW */
+ nullptr, /* SCardSetCardTypeProviderNameA */
+ nullptr, /* SCardSetCardTypeProviderNameW */
+ nullptr, /* SCardForgetCardTypeA */
+ nullptr, /* SCardForgetCardTypeW */
+ nullptr, /* SCardFreeMemory */
+ nullptr, /* SCardAccessStartedEvent */
+ nullptr, /* SCardReleaseStartedEvent */
+ nullptr, /* SCardLocateCardsA */
+ nullptr, /* SCardLocateCardsW */
+ nullptr, /* SCardLocateCardsByATRA */
+ nullptr, /* SCardLocateCardsByATRW */
+ nullptr, /* SCardGetStatusChangeA */
+ nullptr, /* SCardGetStatusChangeW */
+ nullptr, /* SCardCancel */
+ nullptr, /* SCardConnectA */
+ nullptr, /* SCardConnectW */
+ nullptr, /* SCardReconnect */
+ nullptr, /* SCardDisconnect */
+ nullptr, /* SCardBeginTransaction */
+ nullptr, /* SCardEndTransaction */
+ nullptr, /* SCardCancelTransaction */
+ nullptr, /* SCardState */
+ nullptr, /* SCardStatusA */
+ nullptr, /* SCardStatusW */
+ nullptr, /* SCardTransmit */
+ nullptr, /* SCardGetTransmitCount */
+ nullptr, /* SCardControl */
+ nullptr, /* SCardGetAttrib */
+ nullptr, /* SCardSetAttrib */
+ nullptr, /* SCardUIDlgSelectCardA */
+ nullptr, /* SCardUIDlgSelectCardW */
+ nullptr, /* GetOpenCardNameA */
+ nullptr, /* GetOpenCardNameW */
+ nullptr, /* SCardDlgExtendedError */
+ nullptr, /* SCardReadCacheA */
+ nullptr, /* SCardReadCacheW */
+ nullptr, /* SCardWriteCacheA */
+ nullptr, /* SCardWriteCacheW */
+ nullptr, /* SCardGetReaderIconA */
+ nullptr, /* SCardGetReaderIconW */
+ nullptr, /* SCardGetDeviceTypeIdA */
+ nullptr, /* SCardGetDeviceTypeIdW */
+ nullptr, /* SCardGetReaderDeviceInstanceIdA */
+ nullptr, /* SCardGetReaderDeviceInstanceIdW */
+ nullptr, /* SCardListReadersWithDeviceInstanceIdA */
+ nullptr, /* SCardListReadersWithDeviceInstanceIdW */
+ nullptr /* SCardAudit */
};
const SCardApiFunctionTable* Windows_GetSCardApiFunctionTable(void)
diff --git a/winpr/libwinpr/smartcard/test/TestSmartCardListReaders.c b/winpr/libwinpr/smartcard/test/TestSmartCardListReaders.c
index 637200b4f..986dbf181 100644
--- a/winpr/libwinpr/smartcard/test/TestSmartCardListReaders.c
+++ b/winpr/libwinpr/smartcard/test/TestSmartCardListReaders.c
@@ -5,15 +5,15 @@
int TestSmartCardListReaders(int argc, char* argv[])
{
LONG lStatus = 0;
- LPSTR pReader = NULL;
+ LPSTR pReader = nullptr;
SCARDCONTEXT hSC = 0;
- LPSTR mszReaders = NULL;
+ LPSTR mszReaders = nullptr;
DWORD cchReaders = SCARD_AUTOALLOCATE;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- lStatus = SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, &hSC);
+ lStatus = SCardEstablishContext(SCARD_SCOPE_USER, nullptr, nullptr, &hSC);
if (lStatus != SCARD_S_SUCCESS)
{
@@ -22,7 +22,7 @@ int TestSmartCardListReaders(int argc, char* argv[])
return 0;
}
- lStatus = SCardListReadersA(hSC, NULL, (LPSTR)&mszReaders, &cchReaders);
+ lStatus = SCardListReadersA(hSC, nullptr, (LPSTR)&mszReaders, &cchReaders);
if (lStatus != SCARD_S_SUCCESS)
{
diff --git a/winpr/libwinpr/smartcard/test/TestSmartCardStatus.c b/winpr/libwinpr/smartcard/test/TestSmartCardStatus.c
index 011f0cec8..2a2481653 100644
--- a/winpr/libwinpr/smartcard/test/TestSmartCardStatus.c
+++ b/winpr/libwinpr/smartcard/test/TestSmartCardStatus.c
@@ -27,14 +27,14 @@ int TestSmartCardStatus(int argc, char* argv[])
SCARDHANDLE hCard;
DWORD dwActiveProtocol;
char name[100];
- char* aname = NULL;
- char* aatr = NULL;
+ char* aname = nullptr;
+ char* aatr = nullptr;
DWORD len;
BYTE atr[32];
DWORD atrlen = 32;
DWORD status = 0;
DWORD protocol = 0;
- err = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
+ err = SCardEstablishContext(SCARD_SCOPE_SYSTEM, nullptr, nullptr, &hContext);
if (err != SCARD_S_SUCCESS)
{
@@ -42,7 +42,7 @@ int TestSmartCardStatus(int argc, char* argv[])
return -1;
}
- err = SCardListReaders(hContext, "SCard$AllReaders", NULL, &cchReaders);
+ err = SCardListReaders(hContext, "SCard$AllReaders", nullptr, &cchReaders);
if (err != 0)
{
@@ -79,7 +79,7 @@ int TestSmartCardStatus(int argc, char* argv[])
free(mszReaders);
printf("# test 1 - get reader length\n");
- err = SCardStatus(hCard, NULL, &len, NULL, NULL, NULL, NULL);
+ err = SCardStatus(hCard, nullptr, &len, nullptr, nullptr, nullptr, nullptr);
if (err != SCARD_S_SUCCESS)
{
printf("SCardStatus: 0x%08x\n", err);
@@ -88,7 +88,7 @@ int TestSmartCardStatus(int argc, char* argv[])
printf("reader name length: %u\n", len);
printf("# test 2 - get reader name value\n");
- err = SCardStatus(hCard, name, &len, NULL, NULL, NULL, NULL);
+ err = SCardStatus(hCard, name, &len, nullptr, nullptr, nullptr, nullptr);
if (err != SCARD_S_SUCCESS)
{
printf("SCardStatus: 0x%08x\n", err);
@@ -124,7 +124,7 @@ int TestSmartCardStatus(int argc, char* argv[])
SCardFreeMemory(hContext, aatr);
printf("# test 5 - get status and protocol only\n");
- err = SCardStatus(hCard, NULL, NULL, &status, &protocol, NULL, NULL);
+ err = SCardStatus(hCard, nullptr, nullptr, &status, &protocol, nullptr, nullptr);
if (err != SCARD_S_SUCCESS)
{
printf("SCardStatus: 0x%08x\n", err);
@@ -135,7 +135,7 @@ int TestSmartCardStatus(int argc, char* argv[])
printf("# test 6 - get atr only auto allocated\n");
atrlen = SCARD_AUTOALLOCATE;
- err = SCardStatus(hCard, NULL, NULL, NULL, NULL, (LPBYTE)&aatr, &atrlen);
+ err = SCardStatus(hCard, nullptr, nullptr, nullptr, nullptr, (LPBYTE)&aatr, &atrlen);
if (err != SCARD_S_SUCCESS)
{
printf("SCardStatus: 0x%08x\n", err);
@@ -146,7 +146,7 @@ int TestSmartCardStatus(int argc, char* argv[])
printf("# test 7 - get atr only pre allocated\n");
atrlen = 32;
- err = SCardStatus(hCard, NULL, NULL, NULL, NULL, atr, &atrlen);
+ err = SCardStatus(hCard, nullptr, nullptr, nullptr, nullptr, atr, &atrlen);
if (err != SCARD_S_SUCCESS)
{
printf("SCardStatus: 0x%08x\n", err);
diff --git a/winpr/libwinpr/sspi/CredSSP/credssp.c b/winpr/libwinpr/sspi/CredSSP/credssp.c
index b2187ae7b..97b48e244 100644
--- a/winpr/libwinpr/sspi/CredSSP/credssp.c
+++ b/winpr/libwinpr/sspi/CredSSP/credssp.c
@@ -51,8 +51,8 @@ static SECURITY_STATUS SEC_ENTRY credssp_InitializeSecurityContextA(
WINPR_ATTR_UNUSED PSecBufferDesc pOutput, WINPR_ATTR_UNUSED PULONG pfContextAttr,
WINPR_ATTR_UNUSED PTimeStamp ptsExpiry)
{
- CREDSSP_CONTEXT* context = NULL;
- SSPI_CREDENTIALS* credentials = NULL;
+ CREDSSP_CONTEXT* context = nullptr;
+ SSPI_CREDENTIALS* credentials = nullptr;
/* behave like windows SSPIs that don't want empty context */
if (phContext && !phContext->dwLower && !phContext->dwUpper)
@@ -91,11 +91,11 @@ static SECURITY_STATUS SEC_ENTRY credssp_InitializeSecurityContextA(
CREDSSP_CONTEXT* credssp_ContextNew(void)
{
- CREDSSP_CONTEXT* context = NULL;
+ CREDSSP_CONTEXT* context = nullptr;
context = (CREDSSP_CONTEXT*)calloc(1, sizeof(CREDSSP_CONTEXT));
if (!context)
- return NULL;
+ return nullptr;
return context;
}
@@ -137,8 +137,8 @@ static SECURITY_STATUS SEC_ENTRY credssp_AcquireCredentialsHandleA(
WINPR_ATTR_UNUSED void* pvGetKeyArgument, WINPR_ATTR_UNUSED PCredHandle phCredential,
WINPR_ATTR_UNUSED PTimeStamp ptsExpiry)
{
- SSPI_CREDENTIALS* credentials = NULL;
- SEC_WINNT_AUTH_IDENTITY* identity = NULL;
+ SSPI_CREDENTIALS* credentials = nullptr;
+ SEC_WINNT_AUTH_IDENTITY* identity = nullptr;
if (fCredentialUse == SECPKG_CRED_OUTBOUND)
{
@@ -194,7 +194,7 @@ static SECURITY_STATUS SEC_ENTRY credssp_QueryCredentialsAttributesA(
static SECURITY_STATUS SEC_ENTRY credssp_FreeCredentialsHandle(PCredHandle phCredential)
{
- SSPI_CREDENTIALS* credentials = NULL;
+ SSPI_CREDENTIALS* credentials = nullptr;
if (!phCredential)
return SEC_E_INVALID_HANDLE;
@@ -246,66 +246,66 @@ static SECURITY_STATUS SEC_ENTRY credssp_VerifySignature(WINPR_ATTR_UNUSED PCtxt
const SecurityFunctionTableA CREDSSP_SecurityFunctionTableA = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
credssp_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
credssp_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
credssp_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
credssp_InitializeSecurityContextA, /* InitializeSecurityContext */
- NULL, /* AcceptSecurityContext */
- NULL, /* CompleteAuthToken */
- NULL, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* AcceptSecurityContext */
+ nullptr, /* CompleteAuthToken */
+ nullptr, /* DeleteSecurityContext */
+ nullptr, /* ApplyControlToken */
credssp_QueryContextAttributes, /* QueryContextAttributes */
- NULL, /* ImpersonateSecurityContext */
- NULL, /* RevertSecurityContext */
+ nullptr, /* ImpersonateSecurityContext */
+ nullptr, /* RevertSecurityContext */
credssp_MakeSignature, /* MakeSignature */
credssp_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
credssp_EncryptMessage, /* EncryptMessage */
credssp_DecryptMessage, /* DecryptMessage */
- NULL, /* SetContextAttributes */
- NULL, /* SetCredentialsAttributes */
+ nullptr, /* SetContextAttributes */
+ nullptr, /* SetCredentialsAttributes */
};
const SecurityFunctionTableW CREDSSP_SecurityFunctionTableW = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
credssp_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
credssp_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
credssp_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
credssp_InitializeSecurityContextW, /* InitializeSecurityContext */
- NULL, /* AcceptSecurityContext */
- NULL, /* CompleteAuthToken */
- NULL, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* AcceptSecurityContext */
+ nullptr, /* CompleteAuthToken */
+ nullptr, /* DeleteSecurityContext */
+ nullptr, /* ApplyControlToken */
credssp_QueryContextAttributes, /* QueryContextAttributes */
- NULL, /* ImpersonateSecurityContext */
- NULL, /* RevertSecurityContext */
+ nullptr, /* ImpersonateSecurityContext */
+ nullptr, /* RevertSecurityContext */
credssp_MakeSignature, /* MakeSignature */
credssp_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
credssp_EncryptMessage, /* EncryptMessage */
credssp_DecryptMessage, /* DecryptMessage */
- NULL, /* SetContextAttributes */
- NULL, /* SetCredentialsAttributes */
+ nullptr, /* SetContextAttributes */
+ nullptr, /* SetCredentialsAttributes */
};
const SecPkgInfoA CREDSSP_SecPkgInfoA = {
diff --git a/winpr/libwinpr/sspi/Kerberos/kerberos.c b/winpr/libwinpr/sspi/Kerberos/kerberos.c
index fcab46697..86339ec56 100644
--- a/winpr/libwinpr/sspi/Kerberos/kerberos.c
+++ b/winpr/libwinpr/sspi/Kerberos/kerberos.c
@@ -164,7 +164,7 @@ static void kerberos_ContextFree(KRB_CONTEXT* ctx, BOOL allocated)
return;
free(ctx->targetHost);
- ctx->targetHost = NULL;
+ ctx->targetHost = nullptr;
if (ctx->credentials)
{
@@ -186,11 +186,11 @@ static void kerberos_ContextFree(KRB_CONTEXT* ctx, BOOL allocated)
static KRB_CONTEXT* kerberos_ContextNew(KRB_CREDENTIALS* credentials)
{
- KRB_CONTEXT* context = NULL;
+ KRB_CONTEXT* context = nullptr;
context = (KRB_CONTEXT*)calloc(1, sizeof(KRB_CONTEXT));
if (!context)
- return NULL;
+ return nullptr;
context->credentials = credentials;
InterlockedIncrement(&credentials->refCount);
@@ -252,9 +252,9 @@ static char* get_realm_name(krb5_data realm, size_t* plen)
WINPR_ASSERT(plen);
*plen = 0;
if ((realm.length <= 0) || (!realm.data))
- return NULL;
+ return nullptr;
- char* name = NULL;
+ char* name = nullptr;
(void)winpr_asprintf(&name, plen, "krbtgt/%*s@%*s", realm.length, realm.data, realm.length,
realm.data);
return name;
@@ -267,9 +267,9 @@ static char* get_realm_name(Realm realm, size_t* plen)
WINPR_ASSERT(plen);
*plen = 0;
if (!realm)
- return NULL;
+ return nullptr;
- char* name = NULL;
+ char* name = nullptr;
(void)winpr_asprintf(&name, plen, "krbtgt/%s@%s", realm, realm);
return name;
}
@@ -305,15 +305,15 @@ static SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleA(
WINPR_ATTR_UNUSED PTimeStamp ptsExpiry)
{
#ifdef WITH_KRB5
- SEC_WINPR_KERBEROS_SETTINGS* krb_settings = NULL;
- KRB_CREDENTIALS* credentials = NULL;
- krb5_context ctx = NULL;
- krb5_ccache ccache = NULL;
- krb5_keytab keytab = NULL;
- krb5_principal principal = NULL;
- char* domain = NULL;
- char* username = NULL;
- char* password = NULL;
+ SEC_WINPR_KERBEROS_SETTINGS* krb_settings = nullptr;
+ KRB_CREDENTIALS* credentials = nullptr;
+ krb5_context ctx = nullptr;
+ krb5_ccache ccache = nullptr;
+ krb5_keytab keytab = nullptr;
+ krb5_principal principal = nullptr;
+ char* domain = nullptr;
+ char* username = nullptr;
+ char* password = nullptr;
BOOL own_ccache = FALSE;
const char* const default_ccache_type = "MEMORY";
@@ -387,7 +387,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleA(
{
if (own_ccache)
{
- if (krb_log_exec(krb5_cc_new_unique, ctx, default_ccache_type, 0, &ccache))
+ if (krb_log_exec(krb5_cc_new_unique, ctx, default_ccache_type, nullptr, &ccache))
goto cleanup;
}
else
@@ -421,7 +421,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleA(
{
if (own_ccache)
{
- if (krb_log_exec(krb5_cc_new_unique, ctx, default_ccache_type, 0, &ccache))
+ if (krb_log_exec(krb5_cc_new_unique, ctx, default_ccache_type, nullptr, &ccache))
goto cleanup;
}
else
@@ -527,18 +527,18 @@ static SECURITY_STATUS SEC_ENTRY kerberos_AcquireCredentialsHandleW(
PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = SEC_E_INSUFFICIENT_MEMORY;
- char* principal = NULL;
- char* package = NULL;
+ char* principal = nullptr;
+ char* package = nullptr;
if (pszPrincipal)
{
- principal = ConvertWCharToUtf8Alloc(pszPrincipal, NULL);
+ principal = ConvertWCharToUtf8Alloc(pszPrincipal, nullptr);
if (!principal)
goto fail;
}
if (pszPackage)
{
- package = ConvertWCharToUtf8Alloc(pszPackage, NULL);
+ package = ConvertWCharToUtf8Alloc(pszPackage, nullptr);
if (!package)
goto fail;
}
@@ -628,7 +628,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_QueryCredentialsAttributesA(PCredHandl
static BOOL kerberos_mk_tgt_token(SecBuffer* buf, int msg_type, char* sname, char* host,
const krb5_data* ticket)
{
- WinPrAsn1Encoder* enc = NULL;
+ WinPrAsn1Encoder* enc = nullptr;
WinPrAsn1_MemoryChunk data;
wStream s;
size_t len = 0;
@@ -751,7 +751,7 @@ static BOOL kerberos_rd_tgt_req_tag2(WinPrAsn1Decoder* dec, char* buf, size_t le
while (WinPrAsn1DecPeekTag(dec, &tag))
{
BOOL success = FALSE;
- char* lstr = NULL;
+ char* lstr = nullptr;
if (!WinPrAsn1DecReadGeneralString(dec, &lstr))
goto fail;
@@ -782,7 +782,7 @@ static BOOL kerberos_rd_tgt_req_tag3(WinPrAsn1Decoder* dec, char* buf, size_t le
{
/* realm [3] Realm */
BOOL rc = FALSE;
- WinPrAsn1_STRING str = NULL;
+ WinPrAsn1_STRING str = nullptr;
if (!WinPrAsn1DecReadGeneralString(dec, &str))
goto end;
@@ -803,7 +803,7 @@ static BOOL kerberos_rd_tgt_req(WinPrAsn1Decoder* dec, char** target)
if (!target)
return FALSE;
- *target = NULL;
+ *target = nullptr;
wStream s = WinPrAsn1DecGetStream(dec);
const size_t len = Stream_Length(&s);
@@ -882,7 +882,7 @@ static BOOL kerberos_rd_tgt_token(const sspi_gss_data* token, char** target, krb
WINPR_ASSERT(token);
if (target)
- *target = NULL;
+ *target = nullptr;
WinPrAsn1Decoder der = WinPrAsn1Decoder_init();
WinPrAsn1Decoder_InitMem(&der, WINPR_ASN1_DER, (BYTE*)token->data, token->length);
@@ -965,26 +965,26 @@ static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA(
WINPR_ATTR_UNUSED ULONG* pfContextAttr, WINPR_ATTR_UNUSED PTimeStamp ptsExpiry)
{
#ifdef WITH_KRB5
- PSecBuffer input_buffer = NULL;
- PSecBuffer output_buffer = NULL;
- PSecBuffer bindings_buffer = NULL;
- WINPR_DIGEST_CTX* md5 = NULL;
- char* target = NULL;
- char* sname = NULL;
- char* host = NULL;
+ PSecBuffer input_buffer = nullptr;
+ PSecBuffer output_buffer = nullptr;
+ PSecBuffer bindings_buffer = nullptr;
+ WINPR_DIGEST_CTX* md5 = nullptr;
+ char* target = nullptr;
+ char* sname = nullptr;
+ char* host = nullptr;
krb5_data input_token = WINPR_C_ARRAY_INIT;
krb5_data output_token = WINPR_C_ARRAY_INIT;
SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
WinPrAsn1_OID oid = WINPR_C_ARRAY_INIT;
uint16_t tok_id = 0;
- krb5_ap_rep_enc_part* reply = NULL;
+ krb5_ap_rep_enc_part* reply = nullptr;
krb5_flags ap_flags = AP_OPTS_USE_SUBKEY;
char cksum_contents[24] = WINPR_C_ARRAY_INIT;
krb5_data cksum = WINPR_C_ARRAY_INIT;
krb5_creds in_creds = WINPR_C_ARRAY_INIT;
- krb5_creds* creds = NULL;
+ krb5_creds* creds = nullptr;
BOOL isNewContext = FALSE;
- KRB_CONTEXT* context = NULL;
+ KRB_CONTEXT* context = nullptr;
KRB_CREDENTIALS* credentials = sspi_SecureHandleGetLowerPointer(phCredential);
/* behave like windows SSPIs that don't want empty context */
@@ -1079,7 +1079,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA(
{
case KERBEROS_STATE_TGT_REQ:
- if (!kerberos_mk_tgt_token(output_buffer, KRB_TGT_REQ, sname, host, NULL))
+ if (!kerberos_mk_tgt_token(output_buffer, KRB_TGT_REQ, sname, host, nullptr))
goto cleanup;
context->state = KERBEROS_STATE_TGT_REP;
@@ -1091,7 +1091,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA(
if (tok_id != TOK_ID_TGT_REP)
goto bad_token;
- if (!kerberos_rd_tgt_token(&input_token, NULL, &in_creds.second_ticket))
+ if (!kerberos_rd_tgt_token(&input_token, nullptr, &in_creds.second_ticket))
goto bad_token;
/* Continue to AP-REQ */
@@ -1285,11 +1285,11 @@ static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextW(
PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG* pfContextAttr, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- char* target_name = NULL;
+ char* target_name = nullptr;
if (pszTargetName)
{
- target_name = ConvertWCharToUtf8Alloc(pszTargetName, NULL);
+ target_name = ConvertWCharToUtf8Alloc(pszTargetName, nullptr);
if (!target_name)
return SEC_E_INSUFFICIENT_MEMORY;
}
@@ -1339,7 +1339,7 @@ static BOOL retrieveTgtForPrincipal(KRB_CREDENTIALS* credentials, krb5_principal
/* Get the TGT */
if (krb_log_exec(krb5_get_init_creds_keytab, credentials->ctx, creds, entry.principal,
- credentials->keytab, 0, NULL, NULL))
+ credentials->keytab, 0, nullptr, nullptr))
goto cleanup;
ret = TRUE;
@@ -1352,7 +1352,7 @@ static BOOL retrieveSomeTgt(KRB_CREDENTIALS* credentials, const char* target, kr
{
BOOL ret = TRUE;
krb5_principal target_princ = WINPR_C_ARRAY_INIT;
- char* default_realm = NULL;
+ char* default_realm = nullptr;
krb5_error_code rv =
krb_log_exec(krb5_parse_name_flags, credentials->ctx, target, 0, &target_princ);
@@ -1429,16 +1429,16 @@ static SECURITY_STATUS SEC_ENTRY kerberos_AcceptSecurityContext(
{
#ifdef WITH_KRB5
BOOL isNewContext = FALSE;
- PSecBuffer input_buffer = NULL;
- PSecBuffer output_buffer = NULL;
+ PSecBuffer input_buffer = nullptr;
+ PSecBuffer output_buffer = nullptr;
WinPrAsn1_OID oid = WINPR_C_ARRAY_INIT;
uint16_t tok_id = 0;
krb5_data input_token = WINPR_C_ARRAY_INIT;
krb5_data output_token = WINPR_C_ARRAY_INIT;
SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
krb5_flags ap_flags = 0;
- krb5glue_authenticator authenticator = NULL;
- char* target = NULL;
+ krb5glue_authenticator authenticator = nullptr;
+ char* target = nullptr;
krb5_keytab_entry entry = WINPR_C_ARRAY_INIT;
krb5_creds creds = WINPR_C_ARRAY_INIT;
@@ -1485,13 +1485,13 @@ static SECURITY_STATUS SEC_ENTRY kerberos_AcceptSecurityContext(
if (context->state == KERBEROS_STATE_TGT_REQ && tok_id == TOK_ID_TGT_REQ)
{
- if (!kerberos_rd_tgt_token(&input_token, &target, NULL))
+ if (!kerberos_rd_tgt_token(&input_token, &target, nullptr))
goto bad_token;
if (!retrieveSomeTgt(credentials, target, &creds))
goto cleanup;
- if (!kerberos_mk_tgt_token(output_buffer, KRB_TGT_REP, NULL, NULL, &creds.ticket))
+ if (!kerberos_mk_tgt_token(output_buffer, KRB_TGT_REP, nullptr, nullptr, &creds.ticket))
goto cleanup;
if (krb_log_exec(krb5_auth_con_init, credentials->ctx, &context->auth_ctx))
@@ -1505,8 +1505,8 @@ static SECURITY_STATUS SEC_ENTRY kerberos_AcceptSecurityContext(
}
else if (context->state == KERBEROS_STATE_AP_REQ && tok_id == TOK_ID_AP_REQ)
{
- if (krb_log_exec(krb5_rd_req, credentials->ctx, &context->auth_ctx, &input_token, NULL,
- credentials->keytab, &ap_flags, NULL))
+ if (krb_log_exec(krb5_rd_req, credentials->ctx, &context->auth_ctx, &input_token, nullptr,
+ credentials->keytab, &ap_flags, nullptr))
goto cleanup;
if (krb_log_exec(krb5_auth_con_setflags, credentials->ctx, context->auth_ctx,
@@ -1603,14 +1603,14 @@ bad_token:
static KRB_CONTEXT* get_context(PCtxtHandle phContext)
{
if (!phContext)
- return NULL;
+ return nullptr;
TCHAR* name = sspi_SecureHandleGetUpperPointer(phContext);
if (!name)
- return NULL;
+ return nullptr;
if (_tcsncmp(KERBEROS_SSP_NAME, name, ARRAYSIZE(KERBEROS_SSP_NAME)) != 0)
- return NULL;
+ return nullptr;
return sspi_SecureHandleGetLowerPointer(phContext);
}
@@ -1665,7 +1665,7 @@ static SECURITY_STATUS kerberos_ATTR_SIZES(KRB_CONTEXT* context, KRB_CREDENTIALS
UINT header = 0;
UINT pad = 0;
UINT trailer = 0;
- krb5glue_key key = NULL;
+ krb5glue_key key = nullptr;
WINPR_ASSERT(context);
WINPR_ASSERT(context->auth_ctx);
@@ -1728,7 +1728,7 @@ static SECURITY_STATUS kerberos_ATTR_AUTH_IDENTITY(KRB_CONTEXT* context,
WINPR_ASSERT(AuthIdentity);
*AuthIdentity = empty;
- krb5glue_authenticator authenticator = NULL;
+ krb5glue_authenticator authenticator = nullptr;
krb5_error_code rv = krb_log_exec(krb5_auth_con_getauthenticator, credentials->ctx,
context->auth_ctx, &authenticator);
if (rv)
@@ -1765,7 +1765,7 @@ static SECURITY_STATUS kerberos_ATTR_AUTH_IDENTITY(KRB_CONTEXT* context,
goto fail;
const char* name = *principal->name_string.val;
#else
- char* name = NULL;
+ char* name = nullptr;
rv = krb_log_exec(krb5_unparse_name_flags, credentials->ctx, authenticator->client,
KRB5_PRINCIPAL_UNPARSE_NO_REALM, &name);
if (rv)
@@ -1822,10 +1822,10 @@ static SECURITY_STATUS kerberos_ATTR_TICKET_LOGON(KRB_CONTEXT* context,
KERB_TICKET_LOGON* ticketLogon)
{
krb5_creds matchCred = WINPR_C_ARRAY_INIT;
- krb5_auth_context authContext = NULL;
+ krb5_auth_context authContext = nullptr;
krb5_flags getCredsFlags = KRB5_GC_CACHED;
BOOL firstRun = TRUE;
- krb5_creds* hostCred = NULL;
+ krb5_creds* hostCred = nullptr;
SECURITY_STATUS ret = SEC_E_INSUFFICIENT_MEMORY;
int rv = krb_log_exec(krb5_sname_to_principal, credentials->ctx, context->targetHost, "HOST",
KRB5_NT_SRV_HST, &matchCred.server);
@@ -1963,7 +1963,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_SetCredentialsAttributesX(
WINPR_ATTR_UNUSED BOOL unicode)
{
#ifdef WITH_KRB5
- KRB_CREDENTIALS* credentials = NULL;
+ KRB_CREDENTIALS* credentials = nullptr;
if (!phCredential)
return SEC_E_INVALID_HANDLE;
@@ -1993,7 +1993,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_SetCredentialsAttributesX(
if (credentials->kdc_url)
{
free(credentials->kdc_url);
- credentials->kdc_url = NULL;
+ credentials->kdc_url = nullptr;
}
if (kdc_settings->ProxyServerLength > 0)
@@ -2001,7 +2001,7 @@ static SECURITY_STATUS SEC_ENTRY kerberos_SetCredentialsAttributesX(
WCHAR* proxy = (WCHAR*)((BYTE*)pBuffer + kdc_settings->ProxyServerOffset);
credentials->kdc_url = ConvertWCharNToUtf8Alloc(
- proxy, kdc_settings->ProxyServerLength / sizeof(WCHAR), NULL);
+ proxy, kdc_settings->ProxyServerLength / sizeof(WCHAR), nullptr);
if (!credentials->kdc_url)
return SEC_E_INSUFFICIENT_MEMORY;
}
@@ -2042,11 +2042,11 @@ static SECURITY_STATUS SEC_ENTRY kerberos_EncryptMessage(WINPR_ATTR_UNUSED PCtxt
{
#ifdef WITH_KRB5
KRB_CONTEXT* context = get_context(phContext);
- PSecBuffer sig_buffer = NULL;
- PSecBuffer data_buffer = NULL;
- char* header = NULL;
+ PSecBuffer sig_buffer = nullptr;
+ PSecBuffer data_buffer = nullptr;
+ char* header = nullptr;
BYTE flags = 0;
- krb5glue_key key = NULL;
+ krb5glue_key key = nullptr;
krb5_keyusage usage = 0;
krb5_crypto_iov encrypt_iov[] = { { KRB5_CRYPTO_TYPE_HEADER, { 0 } },
{ KRB5_CRYPTO_TYPE_DATA, { 0 } },
@@ -2133,9 +2133,9 @@ static SECURITY_STATUS SEC_ENTRY kerberos_DecryptMessage(WINPR_ATTR_UNUSED PCtxt
{
#ifdef WITH_KRB5
KRB_CONTEXT* context = get_context(phContext);
- PSecBuffer sig_buffer = NULL;
- PSecBuffer data_buffer = NULL;
- krb5glue_key key = NULL;
+ PSecBuffer sig_buffer = nullptr;
+ PSecBuffer data_buffer = nullptr;
+ krb5glue_key key = nullptr;
krb5_keyusage usage = 0;
uint16_t tok_id = 0;
BYTE flags = 0;
@@ -2240,9 +2240,9 @@ static SECURITY_STATUS SEC_ENTRY kerberos_MakeSignature(WINPR_ATTR_UNUSED PCtxtH
{
#ifdef WITH_KRB5
KRB_CONTEXT* context = get_context(phContext);
- PSecBuffer sig_buffer = NULL;
- PSecBuffer data_buffer = NULL;
- krb5glue_key key = NULL;
+ PSecBuffer sig_buffer = nullptr;
+ PSecBuffer data_buffer = nullptr;
+ krb5glue_key key = nullptr;
krb5_keyusage usage = 0;
BYTE flags = 0;
krb5_crypto_iov iov[] = { { KRB5_CRYPTO_TYPE_DATA, { 0 } },
@@ -2311,9 +2311,9 @@ static SECURITY_STATUS SEC_ENTRY kerberos_VerifySignature(WINPR_ATTR_UNUSED PCtx
WINPR_ATTR_UNUSED ULONG* pfQOP)
{
#ifdef WITH_KRB5
- PSecBuffer sig_buffer = NULL;
- PSecBuffer data_buffer = NULL;
- krb5glue_key key = NULL;
+ PSecBuffer sig_buffer = nullptr;
+ PSecBuffer data_buffer = nullptr;
+ krb5glue_key key = nullptr;
krb5_keyusage usage = 0;
BYTE flags = 0;
uint16_t tok_id = 0;
@@ -2392,30 +2392,30 @@ static SECURITY_STATUS SEC_ENTRY kerberos_VerifySignature(WINPR_ATTR_UNUSED PCtx
const SecurityFunctionTableA KERBEROS_SecurityFunctionTableA = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
kerberos_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
kerberos_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
kerberos_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
kerberos_InitializeSecurityContextA, /* InitializeSecurityContext */
kerberos_AcceptSecurityContext, /* AcceptSecurityContext */
- NULL, /* CompleteAuthToken */
+ nullptr, /* CompleteAuthToken */
kerberos_DeleteSecurityContext, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* ApplyControlToken */
kerberos_QueryContextAttributesA, /* QueryContextAttributes */
- NULL, /* ImpersonateSecurityContext */
- NULL, /* RevertSecurityContext */
+ nullptr, /* ImpersonateSecurityContext */
+ nullptr, /* RevertSecurityContext */
kerberos_MakeSignature, /* MakeSignature */
kerberos_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
kerberos_EncryptMessage, /* EncryptMessage */
kerberos_DecryptMessage, /* DecryptMessage */
kerberos_SetContextAttributesA, /* SetContextAttributes */
@@ -2424,30 +2424,30 @@ const SecurityFunctionTableA KERBEROS_SecurityFunctionTableA = {
const SecurityFunctionTableW KERBEROS_SecurityFunctionTableW = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
kerberos_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
kerberos_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
kerberos_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
kerberos_InitializeSecurityContextW, /* InitializeSecurityContext */
kerberos_AcceptSecurityContext, /* AcceptSecurityContext */
- NULL, /* CompleteAuthToken */
+ nullptr, /* CompleteAuthToken */
kerberos_DeleteSecurityContext, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* ApplyControlToken */
kerberos_QueryContextAttributesW, /* QueryContextAttributes */
- NULL, /* ImpersonateSecurityContext */
- NULL, /* RevertSecurityContext */
+ nullptr, /* ImpersonateSecurityContext */
+ nullptr, /* RevertSecurityContext */
kerberos_MakeSignature, /* MakeSignature */
kerberos_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
kerberos_EncryptMessage, /* EncryptMessage */
kerberos_DecryptMessage, /* DecryptMessage */
kerberos_SetContextAttributesW, /* SetContextAttributes */
diff --git a/winpr/libwinpr/sspi/Kerberos/krb5glue.h b/winpr/libwinpr/sspi/Kerberos/krb5glue.h
index f0e5b355e..0711eabc0 100644
--- a/winpr/libwinpr/sspi/Kerberos/krb5glue.h
+++ b/winpr/libwinpr/sspi/Kerberos/krb5glue.h
@@ -36,9 +36,9 @@ typedef krb5_authenticator* krb5glue_authenticator;
#define krb5glue_crypto_length_iov(ctx, key, iov, size) \
krb5_c_crypto_length_iov(ctx, krb5_k_key_enctype(ctx, key), iov, size)
#define krb5glue_encrypt_iov(ctx, key, usage, iov, size) \
- krb5_k_encrypt_iov(ctx, key, usage, NULL, iov, size)
+ krb5_k_encrypt_iov(ctx, key, usage, nullptr, iov, size)
#define krb5glue_decrypt_iov(ctx, key, usage, iov, size) \
- krb5_k_decrypt_iov(ctx, key, usage, NULL, iov, size)
+ krb5_k_decrypt_iov(ctx, key, usage, nullptr, iov, size)
#define krb5glue_make_checksum_iov(ctx, key, usage, iov, size) \
krb5_k_make_checksum_iov(ctx, 0, key, usage, iov, size)
#define krb5glue_verify_checksum_iov(ctx, key, usage, iov, size, is_valid) \
@@ -65,11 +65,11 @@ krb5_error_code krb5glue_crypto_length(krb5_context ctx, krb5glue_key key, int t
unsigned int* size);
#define krb5glue_crypto_length_iov(ctx, key, iov, size) krb5_crypto_length_iov(ctx, key, iov, size)
#define krb5glue_encrypt_iov(ctx, key, usage, iov, size) \
- krb5_encrypt_iov_ivec(ctx, key, usage, iov, size, NULL)
+ krb5_encrypt_iov_ivec(ctx, key, usage, iov, size, nullptr)
#define krb5glue_decrypt_iov(ctx, key, usage, iov, size) \
- krb5_decrypt_iov_ivec(ctx, key, usage, iov, size, NULL)
+ krb5_decrypt_iov_ivec(ctx, key, usage, iov, size, nullptr)
#define krb5glue_make_checksum_iov(ctx, key, usage, iov, size) \
- krb5_create_checksum_iov(ctx, key, usage, iov, size, NULL)
+ krb5_create_checksum_iov(ctx, key, usage, iov, size, nullptr)
krb5_error_code krb5glue_verify_checksum_iov(krb5_context ctx, krb5glue_key key,
krb5_keyusage usage, krb5_crypto_iov* iov,
unsigned int iov_size, krb5_boolean* is_valid);
diff --git a/winpr/libwinpr/sspi/Kerberos/krb5glue_heimdal.c b/winpr/libwinpr/sspi/Kerberos/krb5glue_heimdal.c
index e9cb9f396..8e6b8646e 100644
--- a/winpr/libwinpr/sspi/Kerberos/krb5glue_heimdal.c
+++ b/winpr/libwinpr/sspi/Kerberos/krb5glue_heimdal.c
@@ -41,7 +41,7 @@ void krb5glue_keys_free(krb5_context ctx, struct krb5glue_keyset* keyset)
krb5_error_code krb5glue_update_keyset(krb5_context ctx, krb5_auth_context auth_ctx, BOOL acceptor,
struct krb5glue_keyset* keyset)
{
- krb5_keyblock* keyblock = NULL;
+ krb5_keyblock* keyblock = nullptr;
krb5_error_code rv = 0;
WINPR_ASSERT(ctx);
@@ -55,7 +55,7 @@ krb5_error_code krb5glue_update_keyset(krb5_context ctx, krb5_auth_context auth_
{
krb5_crypto_init(ctx, keyblock, ENCTYPE_NULL, &keyset->session_key);
krb5_free_keyblock(ctx, keyblock);
- keyblock = NULL;
+ keyblock = nullptr;
}
if (acceptor)
@@ -67,7 +67,7 @@ krb5_error_code krb5glue_update_keyset(krb5_context ctx, krb5_auth_context auth_
{
krb5_crypto_init(ctx, keyblock, ENCTYPE_NULL, &keyset->initiator_key);
krb5_free_keyblock(ctx, keyblock);
- keyblock = NULL;
+ keyblock = nullptr;
}
if (acceptor)
@@ -94,7 +94,7 @@ krb5_error_code krb5glue_verify_checksum_iov(krb5_context ctx, krb5glue_key key,
WINPR_ASSERT(key);
WINPR_ASSERT(is_valid);
- rv = krb5_verify_checksum_iov(ctx, key, usage, iov, iov_size, NULL);
+ rv = krb5_verify_checksum_iov(ctx, key, usage, iov, iov_size, nullptr);
*is_valid = (rv == 0);
return rv;
}
@@ -151,8 +151,8 @@ krb5_error_code krb5glue_get_init_creds(krb5_context ctx, krb5_principal princ,
{
krb5_error_code rv = 0;
krb5_deltat start_time = 0;
- krb5_get_init_creds_opt* gic_opt = NULL;
- krb5_init_creds_context creds_ctx = NULL;
+ krb5_get_init_creds_opt* gic_opt = nullptr;
+ krb5_init_creds_context creds_ctx = nullptr;
krb5_creds creds = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(ctx);
@@ -179,7 +179,7 @@ krb5_error_code krb5glue_get_init_creds(krb5_context ctx, krb5_principal princ,
{
if ((rv = krb5_get_init_creds_opt_set_pkinit(
ctx, gic_opt, princ, krb_settings->pkinitX509Identity,
- krb_settings->pkinitX509Anchors, NULL, NULL, 0, prompter, password,
+ krb_settings->pkinitX509Anchors, nullptr, nullptr, 0, prompter, password,
password)) != 0)
break;
}
@@ -192,7 +192,7 @@ krb5_error_code krb5glue_get_init_creds(krb5_context ctx, krb5_principal princ,
break;
if (krb_settings && krb_settings->armorCache)
{
- krb5_ccache armor_cc = NULL;
+ krb5_ccache armor_cc = nullptr;
if ((rv = krb5_cc_resolve(ctx, krb_settings->armorCache, &armor_cc)) != 0)
break;
if ((rv = krb5_init_creds_set_fast_ccache(ctx, creds_ctx, armor_cc)) != 0)
diff --git a/winpr/libwinpr/sspi/Kerberos/krb5glue_mit.c b/winpr/libwinpr/sspi/Kerberos/krb5glue_mit.c
index ae94a2bed..b0ff24b28 100644
--- a/winpr/libwinpr/sspi/Kerberos/krb5glue_mit.c
+++ b/winpr/libwinpr/sspi/Kerberos/krb5glue_mit.c
@@ -36,8 +36,8 @@
static char* create_temporary_file(void)
{
BYTE buffer[32];
- char* hex = NULL;
- char* path = NULL;
+ char* hex = nullptr;
+ char* path = nullptr;
winpr_RAND(buffer, sizeof(buffer));
hex = winpr_BinToHexString(buffer, sizeof(buffer), FALSE);
@@ -90,7 +90,7 @@ krb5_prompt_type krb5glue_get_prompt_type(krb5_context ctx, krb5_prompt prompts[
krb5_error_code krb5glue_log_error(krb5_context ctx, krb5_data* msg, const char* tag)
{
- krb5_error* error = NULL;
+ krb5_error* error = nullptr;
krb5_error_code rv = 0;
WINPR_ASSERT(ctx);
@@ -124,10 +124,10 @@ krb5_error_code krb5glue_get_init_creds(krb5_context ctx, krb5_principal princ,
{
krb5_error_code rv = 0;
krb5_deltat start_time = 0;
- krb5_get_init_creds_opt* gic_opt = NULL;
- krb5_init_creds_context creds_ctx = NULL;
+ krb5_get_init_creds_opt* gic_opt = nullptr;
+ krb5_init_creds_context creds_ctx = nullptr;
char* tmp_profile_path = create_temporary_file();
- profile_t profile = NULL;
+ profile_t profile = nullptr;
BOOL is_temp_ctx = FALSE;
WINPR_ASSERT(ctx);
@@ -177,8 +177,8 @@ krb5_error_code krb5glue_get_init_creds(krb5_context ctx, krb5_principal princ,
if (krb_settings->kdcUrl && (strnlen(krb_settings->kdcUrl, 2) > 0))
{
const char* names[4] = WINPR_C_ARRAY_INIT;
- char* realm = NULL;
- char* kdc_url = NULL;
+ char* realm = nullptr;
+ char* kdc_url = nullptr;
size_t size = 0;
if ((rv = krb5_get_profile(ctx, &profile)))
@@ -218,7 +218,7 @@ krb5_error_code krb5glue_get_init_creds(krb5_context ctx, krb5_principal princ,
goto cleanup;
profile_abandon(profile);
- profile = NULL;
+ profile = nullptr;
lrv = profile_init_path(tmp_profile_path, &profile);
if (lrv)
goto cleanup;
diff --git a/winpr/libwinpr/sspi/NTLM/ntlm.c b/winpr/libwinpr/sspi/NTLM/ntlm.c
index b262a5ef4..53eba1b93 100644
--- a/winpr/libwinpr/sspi/NTLM/ntlm.c
+++ b/winpr/libwinpr/sspi/NTLM/ntlm.c
@@ -108,21 +108,21 @@ static char* get_name(COMPUTER_NAME_FORMAT type)
{
DWORD nSize = 0;
- if (GetComputerNameExA(type, NULL, &nSize))
- return NULL;
+ if (GetComputerNameExA(type, nullptr, &nSize))
+ return nullptr;
if (GetLastError() != ERROR_MORE_DATA)
- return NULL;
+ return nullptr;
char* computerName = calloc(1, nSize);
if (!computerName)
- return NULL;
+ return nullptr;
if (!GetComputerNameExA(type, computerName, &nSize))
{
free(computerName);
- return NULL;
+ return nullptr;
}
return computerName;
@@ -131,7 +131,7 @@ static char* get_name(COMPUTER_NAME_FORMAT type)
static int ntlm_SetContextWorkstation(NTLM_CONTEXT* context, char* Workstation)
{
char* ws = Workstation;
- CHAR* computerName = NULL;
+ CHAR* computerName = nullptr;
WINPR_ASSERT(context);
@@ -161,7 +161,7 @@ static int ntlm_SetContextServicePrincipalNameW(NTLM_CONTEXT* context, LPWSTR Se
if (!ServicePrincipalName)
{
- context->ServicePrincipalName.Buffer = NULL;
+ context->ServicePrincipalName.Buffer = nullptr;
context->ServicePrincipalName.Length = 0;
return 1;
}
@@ -181,13 +181,13 @@ static int ntlm_SetContextTargetName(NTLM_CONTEXT* context, char* TargetName)
{
char* name = TargetName;
DWORD nSize = 0;
- CHAR* computerName = NULL;
+ CHAR* computerName = nullptr;
WINPR_ASSERT(context);
if (!name)
{
- if (GetComputerNameExA(ComputerNameNetBIOS, NULL, &nSize) ||
+ if (GetComputerNameExA(ComputerNameNetBIOS, nullptr, &nSize) ||
GetLastError() != ERROR_MORE_DATA)
return -1;
@@ -219,7 +219,7 @@ static int ntlm_SetContextTargetName(NTLM_CONTEXT* context, char* TargetName)
if (!context->TargetName.pvBuffer || (len > UINT16_MAX / sizeof(WCHAR)))
{
free(context->TargetName.pvBuffer);
- context->TargetName.pvBuffer = NULL;
+ context->TargetName.pvBuffer = nullptr;
if (!TargetName)
free(name);
@@ -237,14 +237,14 @@ static int ntlm_SetContextTargetName(NTLM_CONTEXT* context, char* TargetName)
static NTLM_CONTEXT* ntlm_ContextNew(void)
{
- HKEY hKey = 0;
+ HKEY hKey = nullptr;
DWORD dwType = 0;
DWORD dwSize = 0;
DWORD dwValue = 0;
NTLM_CONTEXT* context = (NTLM_CONTEXT*)calloc(1, sizeof(NTLM_CONTEXT));
if (!context)
- return NULL;
+ return nullptr;
context->NTLMv2 = TRUE;
context->UseMIC = FALSE;
@@ -264,38 +264,38 @@ static NTLM_CONTEXT* ntlm_ContextNew(void)
if (status == ERROR_SUCCESS)
{
- if (RegQueryValueEx(hKey, _T("NTLMv2"), NULL, &dwType, (BYTE*)&dwValue, &dwSize) ==
- ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, _T("NTLMv2"), nullptr, &dwType, (BYTE*)&dwValue,
+ &dwSize) == ERROR_SUCCESS)
context->NTLMv2 = dwValue ? 1 : 0;
- if (RegQueryValueEx(hKey, _T("UseMIC"), NULL, &dwType, (BYTE*)&dwValue, &dwSize) ==
- ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, _T("UseMIC"), nullptr, &dwType, (BYTE*)&dwValue,
+ &dwSize) == ERROR_SUCCESS)
context->UseMIC = dwValue ? 1 : 0;
- if (RegQueryValueEx(hKey, _T("SendVersionInfo"), NULL, &dwType, (BYTE*)&dwValue,
+ if (RegQueryValueEx(hKey, _T("SendVersionInfo"), nullptr, &dwType, (BYTE*)&dwValue,
&dwSize) == ERROR_SUCCESS)
context->SendVersionInfo = dwValue ? 1 : 0;
- if (RegQueryValueEx(hKey, _T("SendSingleHostData"), NULL, &dwType, (BYTE*)&dwValue,
- &dwSize) == ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, _T("SendSingleHostData"), nullptr, &dwType,
+ (BYTE*)&dwValue, &dwSize) == ERROR_SUCCESS)
context->SendSingleHostData = dwValue ? 1 : 0;
- if (RegQueryValueEx(hKey, _T("SendWorkstationName"), NULL, &dwType, (BYTE*)&dwValue,
- &dwSize) == ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, _T("SendWorkstationName"), nullptr, &dwType,
+ (BYTE*)&dwValue, &dwSize) == ERROR_SUCCESS)
context->SendWorkstationName = dwValue ? 1 : 0;
- if (RegQueryValueEx(hKey, _T("WorkstationName"), NULL, &dwType, NULL, &dwSize) ==
- ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, _T("WorkstationName"), nullptr, &dwType, nullptr,
+ &dwSize) == ERROR_SUCCESS)
{
char* workstation = (char*)malloc(dwSize + 1);
if (!workstation)
{
free(context);
- return NULL;
+ return nullptr;
}
- const LONG rc = RegQueryValueExA(hKey, "WorkstationName", NULL, &dwType,
+ const LONG rc = RegQueryValueExA(hKey, "WorkstationName", nullptr, &dwType,
(BYTE*)workstation, &dwSize);
if (rc != ERROR_SUCCESS)
WLog_WARN(TAG, "Key ''WorkstationName' not found");
@@ -305,7 +305,7 @@ static NTLM_CONTEXT* ntlm_ContextNew(void)
{
free(workstation);
free(context);
- return NULL;
+ return nullptr;
}
free(workstation);
@@ -327,8 +327,8 @@ static NTLM_CONTEXT* ntlm_ContextNew(void)
if (status == ERROR_SUCCESS)
{
- if (RegQueryValueEx(hKey, _T("SuppressExtendedProtection"), NULL, &dwType, (BYTE*)&dwValue,
- &dwSize) == ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, _T("SuppressExtendedProtection"), nullptr, &dwType,
+ (BYTE*)&dwValue, &dwSize) == ERROR_SUCCESS)
context->SuppressExtendedProtection = dwValue ? 1 : 0;
RegCloseKey(hKey);
@@ -370,7 +370,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(
SEC_GET_KEY_FN pGetKeyFn, void* pvGetKeyArgument, PCredHandle phCredential,
WINPR_ATTR_UNUSED PTimeStamp ptsExpiry)
{
- SEC_WINPR_NTLM_SETTINGS* settings = NULL;
+ SEC_WINPR_NTLM_SETTINGS* settings = nullptr;
if ((fCredentialUse != SECPKG_CRED_OUTBOUND) && (fCredentialUse != SECPKG_CRED_INBOUND) &&
(fCredentialUse != SECPKG_CRED_BOTH))
@@ -424,18 +424,18 @@ static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA(
PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = SEC_E_INSUFFICIENT_MEMORY;
- SEC_WCHAR* principal = NULL;
- SEC_WCHAR* package = NULL;
+ SEC_WCHAR* principal = nullptr;
+ SEC_WCHAR* package = nullptr;
if (pszPrincipal)
{
- principal = ConvertUtf8ToWCharAlloc(pszPrincipal, NULL);
+ principal = ConvertUtf8ToWCharAlloc(pszPrincipal, nullptr);
if (!principal)
goto fail;
}
if (pszPackage)
{
- package = ConvertUtf8ToWCharAlloc(pszPackage, NULL);
+ package = ConvertUtf8ToWCharAlloc(pszPackage, nullptr);
if (!package)
goto fail;
}
@@ -494,9 +494,9 @@ static SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
WINPR_ATTR_UNUSED PULONG pfContextAttr, WINPR_ATTR_UNUSED PTimeStamp ptsTimeStamp)
{
SECURITY_STATUS status = 0;
- SSPI_CREDENTIALS* credentials = NULL;
- PSecBuffer input_buffer = NULL;
- PSecBuffer output_buffer = NULL;
+ SSPI_CREDENTIALS* credentials = nullptr;
+ PSecBuffer input_buffer = nullptr;
+ PSecBuffer output_buffer = nullptr;
/* behave like windows SSPIs that don't want empty context */
if (phContext && !phContext->dwLower && !phContext->dwUpper)
@@ -522,7 +522,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
context->HashCallback = credentials->ntlmSettings.hashCallback;
context->HashCallbackArg = credentials->ntlmSettings.hashCallbackArg;
- ntlm_SetContextTargetName(context, NULL);
+ ntlm_SetContextTargetName(context, nullptr);
sspi_SecureHandleSetLowerPointer(phNewContext, context);
sspi_SecureHandleSetUpperPointer(phNewContext, (void*)NTLM_PACKAGE_NAME);
}
@@ -621,9 +621,9 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
WINPR_ATTR_UNUSED PULONG pfContextAttr, WINPR_ATTR_UNUSED PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- SSPI_CREDENTIALS* credentials = NULL;
- PSecBuffer input_buffer = NULL;
- PSecBuffer output_buffer = NULL;
+ SSPI_CREDENTIALS* credentials = nullptr;
+ PSecBuffer input_buffer = nullptr;
+ PSecBuffer output_buffer = nullptr;
/* behave like windows SSPIs that don't want empty context */
if (phContext && !phContext->dwLower && !phContext->dwUpper)
@@ -651,7 +651,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
if (context->Workstation.Length < 1)
{
- if (ntlm_SetContextWorkstation(context, NULL) < 0)
+ if (ntlm_SetContextWorkstation(context, nullptr) < 0)
{
ntlm_ContextFree(context);
return SEC_E_INTERNAL_ERROR;
@@ -748,11 +748,11 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA(
PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- SEC_WCHAR* pszTargetNameW = NULL;
+ SEC_WCHAR* pszTargetNameW = nullptr;
if (pszTargetName)
{
- pszTargetNameW = ConvertUtf8ToWCharAlloc(pszTargetName, NULL);
+ pszTargetNameW = ConvertUtf8ToWCharAlloc(pszTargetName, nullptr);
if (!pszTargetNameW)
return SEC_E_INTERNAL_ERROR;
}
@@ -775,8 +775,8 @@ static SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext(PCtxtHandle phContex
SECURITY_STATUS ntlm_computeProofValue(NTLM_CONTEXT* ntlm, SecBuffer* ntproof)
{
- BYTE* blob = NULL;
- SecBuffer* target = NULL;
+ BYTE* blob = nullptr;
+ SecBuffer* target = nullptr;
WINPR_ASSERT(ntlm);
WINPR_ASSERT(ntproof);
@@ -801,7 +801,7 @@ SECURITY_STATUS ntlm_computeProofValue(NTLM_CONTEXT* ntlm, SecBuffer* ntproof)
SECURITY_STATUS ntlm_computeMicValue(NTLM_CONTEXT* ntlm, SecBuffer* micvalue)
{
- BYTE* blob = NULL;
+ BYTE* blob = nullptr;
ULONG msgSize = 0;
WINPR_ASSERT(ntlm);
@@ -851,7 +851,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phCont
}
else if (ulAttribute == SECPKG_ATTR_AUTH_IDENTITY)
{
- SSPI_CREDENTIALS* credentials = NULL;
+ SSPI_CREDENTIALS* credentials = nullptr;
const SecPkgContext_AuthIdentity empty = WINPR_C_ARRAY_INIT;
SecPkgContext_AuthIdentity* AuthIdentity = (SecPkgContext_AuthIdentity*)pBuffer;
@@ -884,7 +884,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phCont
}
else if (ulAttribute == SECPKG_ATTR_AUTH_NTLM_RANDKEY)
{
- SecBuffer* randkey = NULL;
+ SecBuffer* randkey = nullptr;
randkey = (SecBuffer*)pBuffer;
if (!sspi_SecBufferAlloc(randkey, 16))
@@ -1089,8 +1089,8 @@ static SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle phContext,
BYTE digest[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
BYTE checksum[8] = WINPR_C_ARRAY_INIT;
ULONG version = 1;
- PSecBuffer data_buffer = NULL;
- PSecBuffer signature_buffer = NULL;
+ PSecBuffer data_buffer = nullptr;
+ PSecBuffer signature_buffer = nullptr;
NTLM_CONTEXT* context = (NTLM_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
if (!check_context(context))
return SEC_E_INVALID_HANDLE;
@@ -1183,8 +1183,8 @@ static SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle phContext, PSec
BYTE checksum[8] = WINPR_C_ARRAY_INIT;
UINT32 version = 1;
BYTE expected_signature[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
- PSecBuffer data_buffer = NULL;
- PSecBuffer signature_buffer = NULL;
+ PSecBuffer data_buffer = nullptr;
+ PSecBuffer signature_buffer = nullptr;
NTLM_CONTEXT* context = (NTLM_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
if (!check_context(context))
return SEC_E_INVALID_HANDLE;
@@ -1273,8 +1273,8 @@ static SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature(PCtxtHandle phContext,
WINPR_ATTR_UNUSED ULONG fQOP,
PSecBufferDesc pMessage, ULONG MessageSeqNo)
{
- PSecBuffer data_buffer = NULL;
- PSecBuffer sig_buffer = NULL;
+ PSecBuffer data_buffer = nullptr;
+ PSecBuffer sig_buffer = nullptr;
UINT32 seq_no = 0;
BYTE digest[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
BYTE checksum[8] = WINPR_C_ARRAY_INIT;
@@ -1323,8 +1323,8 @@ static SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
PSecBufferDesc pMessage, ULONG MessageSeqNo,
WINPR_ATTR_UNUSED PULONG pfQOP)
{
- PSecBuffer data_buffer = NULL;
- PSecBuffer sig_buffer = NULL;
+ PSecBuffer data_buffer = nullptr;
+ PSecBuffer sig_buffer = nullptr;
UINT32 seq_no = 0;
BYTE digest[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
BYTE checksum[8] = WINPR_C_ARRAY_INIT;
@@ -1373,30 +1373,30 @@ static SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
const SecurityFunctionTableA NTLM_SecurityFunctionTableA = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
ntlm_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
ntlm_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
ntlm_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
ntlm_InitializeSecurityContextA, /* InitializeSecurityContext */
ntlm_AcceptSecurityContext, /* AcceptSecurityContext */
- NULL, /* CompleteAuthToken */
+ nullptr, /* CompleteAuthToken */
ntlm_DeleteSecurityContext, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* ApplyControlToken */
ntlm_QueryContextAttributesA, /* QueryContextAttributes */
ntlm_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
ntlm_RevertSecurityContext, /* RevertSecurityContext */
ntlm_MakeSignature, /* MakeSignature */
ntlm_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
ntlm_EncryptMessage, /* EncryptMessage */
ntlm_DecryptMessage, /* DecryptMessage */
ntlm_SetContextAttributesA, /* SetContextAttributes */
@@ -1405,30 +1405,30 @@ const SecurityFunctionTableA NTLM_SecurityFunctionTableA = {
const SecurityFunctionTableW NTLM_SecurityFunctionTableW = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
ntlm_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
ntlm_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
ntlm_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
ntlm_InitializeSecurityContextW, /* InitializeSecurityContext */
ntlm_AcceptSecurityContext, /* AcceptSecurityContext */
- NULL, /* CompleteAuthToken */
+ nullptr, /* CompleteAuthToken */
ntlm_DeleteSecurityContext, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* ApplyControlToken */
ntlm_QueryContextAttributesW, /* QueryContextAttributes */
ntlm_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
ntlm_RevertSecurityContext, /* RevertSecurityContext */
ntlm_MakeSignature, /* MakeSignature */
ntlm_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
ntlm_EncryptMessage, /* EncryptMessage */
ntlm_DecryptMessage, /* DecryptMessage */
ntlm_SetContextAttributesW, /* SetContextAttributes */
@@ -1476,13 +1476,13 @@ char* ntlm_negotiate_flags_string(char* buffer, size_t size, UINT32 flags)
{
if (size - len < 1)
break;
- winpr_str_append("|", buffer, size, NULL);
+ winpr_str_append("|", buffer, size, nullptr);
len++;
}
if (size - len < flen)
break;
- winpr_str_append(str, buffer, size, NULL);
+ winpr_str_append(str, buffer, size, nullptr);
}
}
diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c b/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c
index 2103fd3fc..8c4609494 100644
--- a/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c
+++ b/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c
@@ -128,7 +128,7 @@ static inline BOOL ntlm_av_pair_get_id(const NTLM_AV_PAIR* pAvPair, size_t size,
ULONG ntlm_av_pair_list_length(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList)
{
size_t cbAvPair = 0;
- NTLM_AV_PAIR* pAvPair = NULL;
+ NTLM_AV_PAIR* pAvPair = nullptr;
pAvPair = ntlm_av_pair_get(pAvPairList, cbAvPairList, MsvAvEOL, &cbAvPair);
if (!pAvPair)
@@ -217,12 +217,12 @@ static NTLM_AV_PAIR* ntlm_av_pair_next(NTLM_AV_PAIR* pAvPair, size_t* pcbAvPair)
size_t offset = 0;
if (!pcbAvPair)
- return NULL;
+ return nullptr;
if (!ntlm_av_pair_check(pAvPair, *pcbAvPair))
- return NULL;
+ return nullptr;
if (!ntlm_av_pair_get_next_offset(pAvPair, *pcbAvPair, &offset))
- return NULL;
+ return nullptr;
*pcbAvPair -= offset;
return (NTLM_AV_PAIR*)((PBYTE)pAvPair + offset);
@@ -236,7 +236,7 @@ NTLM_AV_PAIR* ntlm_av_pair_get(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList, N
NTLM_AV_PAIR* pAvPair = pAvPairList;
if (!ntlm_av_pair_check(pAvPair, cbAvPair))
- pAvPair = NULL;
+ pAvPair = nullptr;
while (pAvPair && ntlm_av_pair_get_id(pAvPair, cbAvPair, &id))
{
@@ -244,7 +244,7 @@ NTLM_AV_PAIR* ntlm_av_pair_get(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList, N
break;
if (id == MsvAvEOL)
{
- pAvPair = NULL;
+ pAvPair = nullptr;
break;
}
@@ -263,7 +263,7 @@ static BOOL ntlm_av_pair_add(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList, NTL
PBYTE Value, UINT16 AvLen)
{
size_t cbAvPair = 0;
- NTLM_AV_PAIR* pAvPair = NULL;
+ NTLM_AV_PAIR* pAvPair = nullptr;
pAvPair = ntlm_av_pair_get(pAvPairList, cbAvPairList, MsvAvEOL, &cbAvPair);
@@ -275,7 +275,7 @@ static BOOL ntlm_av_pair_add(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList, NTL
ntlm_av_pair_set_len(pAvPair, AvLen);
if (AvLen)
{
- WINPR_ASSERT(Value != NULL);
+ WINPR_ASSERT(Value != nullptr);
CopyMemory(ntlm_av_pair_get_value_pointer(pAvPair), Value, AvLen);
}
@@ -331,21 +331,21 @@ static char* get_name(COMPUTER_NAME_FORMAT type)
{
DWORD nSize = 0;
- if (GetComputerNameExA(type, NULL, &nSize))
- return NULL;
+ if (GetComputerNameExA(type, nullptr, &nSize))
+ return nullptr;
if (GetLastError() != ERROR_MORE_DATA)
- return NULL;
+ return nullptr;
char* computerName = calloc(1, nSize);
if (!computerName)
- return NULL;
+ return nullptr;
if (!GetComputerNameExA(type, computerName, &nSize))
{
free(computerName);
- return NULL;
+ return nullptr;
}
return computerName;
@@ -371,7 +371,7 @@ static int ntlm_get_target_computer_name(PUNICODE_STRING pName,
if (!pName->Buffer || (len == 0) || (len > UINT16_MAX / sizeof(WCHAR)))
{
free(pName->Buffer);
- pName->Buffer = NULL;
+ pName->Buffer = nullptr;
return status;
}
@@ -387,7 +387,7 @@ static void ntlm_free_unicode_string(PUNICODE_STRING string)
if (string->Length > 0)
{
free(string->Buffer);
- string->Buffer = NULL;
+ string->Buffer = nullptr;
string->Length = 0;
string->MaximumLength = 0;
}
@@ -434,10 +434,10 @@ static BOOL ntlm_md5_update_uint32_be(WINPR_DIGEST_CTX* md5, UINT32 num)
static void ntlm_compute_channel_bindings(NTLM_CONTEXT* context)
{
- WINPR_DIGEST_CTX* md5 = NULL;
- BYTE* ChannelBindingToken = NULL;
+ WINPR_DIGEST_CTX* md5 = nullptr;
+ BYTE* ChannelBindingToken = nullptr;
UINT32 ChannelBindingTokenLength = 0;
- SEC_CHANNEL_BINDINGS* ChannelBindings = NULL;
+ SEC_CHANNEL_BINDINGS* ChannelBindings = nullptr;
WINPR_ASSERT(context);
@@ -504,7 +504,7 @@ BOOL ntlm_construct_challenge_target_info(NTLM_CONTEXT* context)
BOOL rc = FALSE;
ULONG AvPairsCount = 0;
ULONG AvPairsLength = 0;
- NTLM_AV_PAIR* pAvPairList = NULL;
+ NTLM_AV_PAIR* pAvPairList = nullptr;
size_t cbAvPairList = 0;
UNICODE_STRING NbDomainName = WINPR_C_ARRAY_INIT;
UNICODE_STRING NbComputerName = WINPR_C_ARRAY_INIT;
@@ -516,17 +516,17 @@ BOOL ntlm_construct_challenge_target_info(NTLM_CONTEXT* context)
if (ntlm_get_target_computer_name(&NbDomainName, ComputerNameNetBIOS) < 0)
goto fail;
- NbComputerName.Buffer = NULL;
+ NbComputerName.Buffer = nullptr;
if (ntlm_get_target_computer_name(&NbComputerName, ComputerNameNetBIOS) < 0)
goto fail;
- DnsDomainName.Buffer = NULL;
+ DnsDomainName.Buffer = nullptr;
if (ntlm_get_target_computer_name(&DnsDomainName, ComputerNameDnsDomain) < 0)
goto fail;
- DnsComputerName.Buffer = NULL;
+ DnsComputerName.Buffer = nullptr;
if (ntlm_get_target_computer_name(&DnsComputerName, ComputerNameDnsHostname) < 0)
goto fail;
@@ -580,14 +580,14 @@ BOOL ntlm_construct_authenticate_target_info(NTLM_CONTEXT* context)
{
ULONG AvPairsCount = 0;
size_t AvPairsValueLength = 0;
- NTLM_AV_PAIR* AvTimestamp = NULL;
- NTLM_AV_PAIR* AvNbDomainName = NULL;
- NTLM_AV_PAIR* AvNbComputerName = NULL;
- NTLM_AV_PAIR* AvDnsDomainName = NULL;
- NTLM_AV_PAIR* AvDnsComputerName = NULL;
- NTLM_AV_PAIR* AvDnsTreeName = NULL;
- NTLM_AV_PAIR* ChallengeTargetInfo = NULL;
- NTLM_AV_PAIR* AuthenticateTargetInfo = NULL;
+ NTLM_AV_PAIR* AvTimestamp = nullptr;
+ NTLM_AV_PAIR* AvNbDomainName = nullptr;
+ NTLM_AV_PAIR* AvNbComputerName = nullptr;
+ NTLM_AV_PAIR* AvDnsDomainName = nullptr;
+ NTLM_AV_PAIR* AvDnsComputerName = nullptr;
+ NTLM_AV_PAIR* AvDnsTreeName = nullptr;
+ NTLM_AV_PAIR* ChallengeTargetInfo = nullptr;
+ NTLM_AV_PAIR* AuthenticateTargetInfo = nullptr;
size_t cbAvTimestamp = 0;
size_t cbAvNbDomainName = 0;
size_t cbAvNbComputerName = 0;
@@ -792,8 +792,8 @@ BOOL ntlm_construct_authenticate_target_info(NTLM_CONTEXT* context)
if (context->NTLMv2)
{
- NTLM_AV_PAIR* AvEOL = NULL;
- AvEOL = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvEOL, NULL);
+ NTLM_AV_PAIR* AvEOL = nullptr;
+ AvEOL = ntlm_av_pair_get(ChallengeTargetInfo, cbChallengeTargetInfo, MsvAvEOL, nullptr);
if (!AvEOL)
goto fail;
diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c
index f375ab808..58041e71d 100644
--- a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c
+++ b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c
@@ -275,9 +275,9 @@ void ntlm_generate_timestamp(NTLM_CONTEXT* context)
static BOOL ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
{
BOOL rc = FALSE;
- WINPR_SAM* sam = NULL;
- WINPR_SAM_ENTRY* entry = NULL;
- SSPI_CREDENTIALS* credentials = NULL;
+ WINPR_SAM* sam = nullptr;
+ WINPR_SAM_ENTRY* entry = nullptr;
+ SSPI_CREDENTIALS* credentials = nullptr;
WINPR_ASSERT(context);
WINPR_ASSERT(hash);
@@ -295,7 +295,7 @@ static BOOL ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
if (!entry)
{
entry = SamLookupUserW(sam, (LPWSTR)credentials->identity.User,
- credentials->identity.UserLength * sizeof(WCHAR), NULL, 0);
+ credentials->identity.UserLength * sizeof(WCHAR), nullptr, 0);
}
if (!entry)
@@ -412,7 +412,7 @@ static int ntlm_convert_password_hash(NTLM_CONTEXT* context, BYTE* hash, size_t
static BOOL ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
{
- SSPI_CREDENTIALS* credentials = NULL;
+ SSPI_CREDENTIALS* credentials = nullptr;
WINPR_ASSERT(context);
WINPR_ASSERT(hash);
@@ -501,7 +501,7 @@ static BOOL ntlm_compute_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
SECURITY_STATUS ntlm_compute_lm_v2_response(NTLM_CONTEXT* context)
{
- BYTE* response = NULL;
+ BYTE* response = nullptr;
BYTE value[WINPR_MD5_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
WINPR_ASSERT(context);
@@ -763,7 +763,7 @@ static BOOL ntlm_generate_signing_key(BYTE* exported_session_key, const SecBuffe
{
BOOL rc = FALSE;
size_t length = 0;
- BYTE* value = NULL;
+ BYTE* value = nullptr;
WINPR_ASSERT(exported_session_key);
WINPR_ASSERT(sign_magic);
diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_message.c b/winpr/libwinpr/sspi/NTLM/ntlm_message.c
index dedcc54c5..ad53853a5 100644
--- a/winpr/libwinpr/sspi/NTLM/ntlm_message.c
+++ b/winpr/libwinpr/sspi/NTLM/ntlm_message.c
@@ -399,7 +399,7 @@ void ntlm_free_message_fields_buffer(NTLM_MESSAGE_FIELDS* fields)
free(fields->Buffer);
fields->Len = 0;
fields->MaxLen = 0;
- fields->Buffer = NULL;
+ fields->Buffer = nullptr;
fields->BufferOffset = 0;
}
}
@@ -492,10 +492,10 @@ static BOOL ntlm_write_message_integrity_check(wStream* s, size_t offset, const
SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buffer)
{
wStream sbuffer;
- wStream* s = NULL;
+ wStream* s = nullptr;
size_t length = 0;
const NTLM_NEGOTIATE_MESSAGE empty = WINPR_C_ARRAY_INIT;
- NTLM_NEGOTIATE_MESSAGE* message = NULL;
+ NTLM_NEGOTIATE_MESSAGE* message = nullptr;
WINPR_ASSERT(context);
WINPR_ASSERT(buffer);
@@ -566,10 +566,10 @@ SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buf
SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, SecBuffer* buffer)
{
wStream sbuffer;
- wStream* s = NULL;
+ wStream* s = nullptr;
size_t length = 0;
const NTLM_NEGOTIATE_MESSAGE empty = WINPR_C_ARRAY_INIT;
- NTLM_NEGOTIATE_MESSAGE* message = NULL;
+ NTLM_NEGOTIATE_MESSAGE* message = nullptr;
WINPR_ASSERT(context);
WINPR_ASSERT(buffer);
@@ -657,13 +657,13 @@ SECURITY_STATUS ntlm_read_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer buf
{
SECURITY_STATUS status = SEC_E_INVALID_TOKEN;
wStream sbuffer;
- wStream* s = NULL;
+ wStream* s = nullptr;
size_t length = 0;
size_t StartOffset = 0;
size_t PayloadOffset = 0;
- NTLM_AV_PAIR* AvTimestamp = NULL;
+ NTLM_AV_PAIR* AvTimestamp = nullptr;
const NTLM_CHALLENGE_MESSAGE empty = WINPR_C_ARRAY_INIT;
- NTLM_CHALLENGE_MESSAGE* message = NULL;
+ NTLM_CHALLENGE_MESSAGE* message = nullptr;
if (!context || !buffer)
return SEC_E_INTERNAL_ERROR;
@@ -754,7 +754,7 @@ SECURITY_STATUS ntlm_read_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer buf
if (context->ChallengeMessage.pvBuffer)
CopyMemory(context->ChallengeMessage.pvBuffer, Stream_Buffer(s) + StartOffset, length);
#if defined(WITH_DEBUG_NTLM)
- ntlm_print_challenge_message(&context->ChallengeMessage, message, NULL);
+ ntlm_print_challenge_message(&context->ChallengeMessage, message, nullptr);
#endif
/* AV_PAIRs */
@@ -821,11 +821,11 @@ fail:
SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, SecBuffer* buffer)
{
wStream sbuffer;
- wStream* s = NULL;
+ wStream* s = nullptr;
size_t length = 0;
UINT32 PayloadOffset = 0;
const NTLM_CHALLENGE_MESSAGE empty = WINPR_C_ARRAY_INIT;
- NTLM_CHALLENGE_MESSAGE* message = NULL;
+ NTLM_CHALLENGE_MESSAGE* message = nullptr;
WINPR_ASSERT(context);
WINPR_ASSERT(buffer);
@@ -933,14 +933,14 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
{
SECURITY_STATUS status = SEC_E_INVALID_TOKEN;
wStream sbuffer;
- wStream* s = NULL;
+ wStream* s = nullptr;
size_t length = 0;
UINT32 flags = 0;
- NTLM_AV_PAIR* AvFlags = NULL;
+ NTLM_AV_PAIR* AvFlags = nullptr;
size_t PayloadBufferOffset = 0;
const NTLM_AUTHENTICATE_MESSAGE empty = WINPR_C_ARRAY_INIT;
- NTLM_AUTHENTICATE_MESSAGE* message = NULL;
- SSPI_CREDENTIALS* credentials = NULL;
+ NTLM_AUTHENTICATE_MESSAGE* message = nullptr;
+ SSPI_CREDENTIALS* credentials = nullptr;
WINPR_ASSERT(context);
WINPR_ASSERT(buffer);
@@ -1082,7 +1082,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
status = SEC_E_INTERNAL_ERROR;
#if defined(WITH_DEBUG_NTLM)
- ntlm_print_authenticate_message(&context->AuthenticateMessage, message, flags, NULL);
+ ntlm_print_authenticate_message(&context->AuthenticateMessage, message, flags, nullptr);
#endif
if (message->UserName.Len > 0)
@@ -1221,12 +1221,12 @@ fail:
SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, SecBuffer* buffer)
{
wStream sbuffer;
- wStream* s = NULL;
+ wStream* s = nullptr;
size_t length = 0;
UINT32 PayloadBufferOffset = 0;
const NTLM_AUTHENTICATE_MESSAGE empty = WINPR_C_ARRAY_INIT;
- NTLM_AUTHENTICATE_MESSAGE* message = NULL;
- SSPI_CREDENTIALS* credentials = NULL;
+ NTLM_AUTHENTICATE_MESSAGE* message = nullptr;
+ SSPI_CREDENTIALS* credentials = nullptr;
WINPR_ASSERT(context);
WINPR_ASSERT(buffer);
diff --git a/winpr/libwinpr/sspi/Negotiate/negotiate.c b/winpr/libwinpr/sspi/Negotiate/negotiate.c
index be4ca6b01..0c8b2a1f8 100644
--- a/winpr/libwinpr/sspi/Negotiate/negotiate.c
+++ b/winpr/libwinpr/sspi/Negotiate/negotiate.c
@@ -141,18 +141,19 @@ typedef struct
SecBuffer mic;
} NegToken;
-static const NegToken empty_neg_token = { NOSTATE, FALSE, { 0, NULL },
- { 0, 0, NULL }, { 0, 0, NULL }, { 0, 0, NULL } };
+static const NegToken empty_neg_token = { NOSTATE, FALSE,
+ { 0, nullptr }, { 0, 0, nullptr },
+ { 0, 0, nullptr }, { 0, 0, nullptr } };
static NEGOTIATE_CONTEXT* negotiate_ContextNew(NEGOTIATE_CONTEXT* init_context)
{
- NEGOTIATE_CONTEXT* context = NULL;
+ NEGOTIATE_CONTEXT* context = nullptr;
WINPR_ASSERT(init_context);
context = calloc(1, sizeof(NEGOTIATE_CONTEXT));
if (!context)
- return NULL;
+ return nullptr;
if (init_context->spnego)
{
@@ -160,7 +161,7 @@ static NEGOTIATE_CONTEXT* negotiate_ContextNew(NEGOTIATE_CONTEXT* init_context)
if (!init_context->mechTypes.pvBuffer)
{
free(context);
- return NULL;
+ return nullptr;
}
}
@@ -213,7 +214,7 @@ static const Mech* negotiate_GetMechByOID(const WinPrAsn1_OID* oid)
if (sspi_gss_oid_compare(&testOid, MechTable[i].oid))
return &MechTable[i];
}
- return NULL;
+ return nullptr;
}
static PSecHandle negotiate_FindCredential(MechCred* creds, const Mech* mech)
@@ -221,7 +222,7 @@ static PSecHandle negotiate_FindCredential(MechCred* creds, const Mech* mech)
WINPR_ASSERT(creds);
if (!mech)
- return NULL;
+ return nullptr;
for (size_t i = 0; i < MECH_COUNT; i++)
{
@@ -231,11 +232,11 @@ static PSecHandle negotiate_FindCredential(MechCred* creds, const Mech* mech)
{
if (cred->valid)
return &cred->cred;
- return NULL;
+ return nullptr;
}
}
- return NULL;
+ return nullptr;
}
static BOOL negotiate_get_dword(HKEY hKey, const char* subkey, DWORD* pdwValue)
@@ -243,7 +244,7 @@ static BOOL negotiate_get_dword(HKEY hKey, const char* subkey, DWORD* pdwValue)
DWORD dwValue = 0;
DWORD dwType = 0;
DWORD dwSize = sizeof(dwValue);
- LONG rc = RegQueryValueExA(hKey, subkey, NULL, &dwType, (BYTE*)&dwValue, &dwSize);
+ LONG rc = RegQueryValueExA(hKey, subkey, nullptr, &dwType, (BYTE*)&dwValue, &dwSize);
if (rc != ERROR_SUCCESS)
return FALSE;
@@ -258,8 +259,8 @@ static BOOL negotiate_get_config_from_auth_package_list(void* pAuthData, BOOL* k
BOOL* u2u)
{
BOOL rc = FALSE;
- char* tok_ctx = NULL;
- char* PackageList = NULL;
+ char* tok_ctx = nullptr;
+ char* PackageList = nullptr;
if (!sspi_CopyAuthPackageListA((const SEC_WINNT_AUTH_IDENTITY_INFO*)pAuthData, &PackageList))
return FALSE;
@@ -306,7 +307,7 @@ static BOOL negotiate_get_config_from_auth_package_list(void* pAuthData, BOOL* k
WLog_WARN(TAG, "Unknown authentication package name: %s, ignoring", PackageName);
}
- tok_ptr = strtok_s(NULL, ",", &tok_ctx);
+ tok_ptr = strtok_s(nullptr, ",", &tok_ctx);
}
rc = TRUE;
@@ -317,7 +318,7 @@ fail:
static BOOL negotiate_get_config(void* pAuthData, BOOL* kerberos, BOOL* ntlm, BOOL* u2u)
{
- HKEY hKey = NULL;
+ HKEY hKey = nullptr;
WINPR_ASSERT(kerberos);
WINPR_ASSERT(ntlm);
@@ -377,7 +378,7 @@ static BOOL negotiate_write_neg_token(PSecBuffer output_buffer, NegToken* token)
WINPR_ASSERT(token);
BOOL ret = FALSE;
- WinPrAsn1Encoder* enc = NULL;
+ WinPrAsn1Encoder* enc = nullptr;
WinPrAsn1_MemoryChunk mechTypes = { token->mechTypes.cbBuffer, token->mechTypes.pvBuffer };
WinPrAsn1_OctetString mechToken = { token->mechToken.cbBuffer, token->mechToken.pvBuffer };
WinPrAsn1_OctetString mechListMic = { token->mic.cbBuffer, token->mic.pvBuffer };
@@ -636,7 +637,7 @@ static SECURITY_STATUS negotiate_mic_exchange(NEGOTIATE_CONTEXT* context, NegTok
{
mic_buffers[1] = input_token->mic;
- status = table->VerifySignature(&context->sub_context, &mic_buffer_desc, 0, 0);
+ status = table->VerifySignature(&context->sub_context, &mic_buffer_desc, 0, nullptr);
if (status != SEC_E_OK)
return status;
@@ -682,24 +683,24 @@ static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(
ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2,
PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
- NEGOTIATE_CONTEXT* context = NULL;
+ NEGOTIATE_CONTEXT* context = nullptr;
NEGOTIATE_CONTEXT init_context = NEGOTIATE_CONTEXT_init();
- MechCred* creds = NULL;
- PCtxtHandle sub_context = NULL;
- PCredHandle sub_cred = NULL;
+ MechCred* creds = nullptr;
+ PCtxtHandle sub_context = nullptr;
+ PCredHandle sub_cred = nullptr;
NegToken input_token = empty_neg_token;
NegToken output_token = empty_neg_token;
- PSecBuffer input_buffer = NULL;
- PSecBuffer output_buffer = NULL;
- PSecBuffer bindings_buffer = NULL;
+ PSecBuffer input_buffer = nullptr;
+ PSecBuffer output_buffer = nullptr;
+ PSecBuffer bindings_buffer = nullptr;
SecBuffer mech_input_buffers[2] = WINPR_C_ARRAY_INIT;
SecBufferDesc mech_input = { SECBUFFER_VERSION, 2, mech_input_buffers };
SecBufferDesc mech_output = { SECBUFFER_VERSION, 1, &output_token.mechToken };
SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
SECURITY_STATUS sub_status = SEC_E_INTERNAL_ERROR;
- WinPrAsn1Encoder* enc = NULL;
+ WinPrAsn1Encoder* enc = nullptr;
wStream s;
- const Mech* mech = NULL;
+ const Mech* mech = nullptr;
if (!phCredential || !SecIsValidHandle(phCredential))
return SEC_E_NO_CREDENTIALS;
@@ -756,7 +757,7 @@ static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(
WINPR_ASSERT(pkg->table_w->InitializeSecurityContextW);
sub_status = pkg->table_w->InitializeSecurityContextW(
- &cred->cred, NULL, pszTargetName, fContextReq | cred->mech->flags, Reserved1,
+ &cred->cred, nullptr, pszTargetName, fContextReq | cred->mech->flags, Reserved1,
TargetDataRep, &mech_input, Reserved2, &init_context.sub_context, &mech_output,
pfContextAttr, ptsExpiry);
@@ -863,7 +864,7 @@ static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(
/* Clean up the optimistic mech */
context->mech->pkg->table_w->DeleteSecurityContext(&context->sub_context);
- sub_context = NULL;
+ sub_context = nullptr;
context->mech = mech;
context->mic = TRUE;
@@ -911,7 +912,7 @@ static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextW(
status = context->mech->pkg->table_w->InitializeSecurityContextW(
sub_cred, sub_context, pszTargetName, fContextReq | context->mech->flags, Reserved1,
- TargetDataRep, input_token.mechToken.cbBuffer ? &mech_input : NULL, Reserved2,
+ TargetDataRep, input_token.mechToken.cbBuffer ? &mech_input : nullptr, Reserved2,
&context->sub_context, &mech_output, pfContextAttr, ptsExpiry);
if (IsSecurityStatusError(status))
@@ -972,11 +973,11 @@ static SECURITY_STATUS SEC_ENTRY negotiate_InitializeSecurityContextA(
PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- SEC_WCHAR* pszTargetNameW = NULL;
+ SEC_WCHAR* pszTargetNameW = nullptr;
if (pszTargetName)
{
- pszTargetNameW = ConvertUtf8ToWCharAlloc(pszTargetName, NULL);
+ pszTargetNameW = ConvertUtf8ToWCharAlloc(pszTargetName, nullptr);
if (!pszTargetNameW)
return SEC_E_INTERNAL_ERROR;
}
@@ -1009,15 +1010,15 @@ static const Mech* guessMech(PSecBuffer input_buffer, BOOL* spNego, WinPrAsn1_OI
input_buffer->cbBuffer);
if (!WinPrAsn1DecReadApp(&decoder, &tag, &appDecoder) || tag != 0)
- return NULL;
+ return nullptr;
if (!WinPrAsn1DecReadOID(&appDecoder, oid, FALSE))
- return NULL;
+ return nullptr;
if (sspi_gss_oid_compare(oid, &spnego_OID))
{
*spNego = TRUE;
- return NULL;
+ return nullptr;
}
return negotiate_GetMechByOID(oid);
@@ -1028,14 +1029,14 @@ static SECURITY_STATUS SEC_ENTRY negotiate_AcceptSecurityContext(
ULONG TargetDataRep, PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr,
PTimeStamp ptsTimeStamp)
{
- NEGOTIATE_CONTEXT* context = NULL;
+ NEGOTIATE_CONTEXT* context = nullptr;
NEGOTIATE_CONTEXT init_context = NEGOTIATE_CONTEXT_init();
- MechCred* creds = NULL;
- PCredHandle sub_cred = NULL;
+ MechCred* creds = nullptr;
+ PCredHandle sub_cred = nullptr;
NegToken input_token = empty_neg_token;
NegToken output_token = empty_neg_token;
- PSecBuffer input_buffer = NULL;
- PSecBuffer output_buffer = NULL;
+ PSecBuffer input_buffer = nullptr;
+ PSecBuffer output_buffer = nullptr;
SecBufferDesc mech_input = { SECBUFFER_VERSION, 1, &input_token.mechToken };
SecBufferDesc mech_output = { SECBUFFER_VERSION, 1, &output_token.mechToken };
SECURITY_STATUS status = SEC_E_INTERNAL_ERROR;
@@ -1043,7 +1044,7 @@ static SECURITY_STATUS SEC_ENTRY negotiate_AcceptSecurityContext(
WinPrAsn1Decoder dec2 = WinPrAsn1Decoder_init();
WinPrAsn1_tagId tag = 0;
WinPrAsn1_OID oid = WINPR_C_ARRAY_INIT;
- const Mech* first_mech = NULL;
+ const Mech* first_mech = nullptr;
if (!phCredential || !SecIsValidHandle(phCredential))
return SEC_E_NO_CREDENTIALS;
@@ -1115,7 +1116,7 @@ static SECURITY_STATUS SEC_ENTRY negotiate_AcceptSecurityContext(
sub_cred = negotiate_FindCredential(creds, init_context.mech);
status = init_context.mech->pkg->table->AcceptSecurityContext(
- sub_cred, NULL, init_context.spnego ? &mech_input : pInput, fContextReq,
+ sub_cred, nullptr, init_context.spnego ? &mech_input : pInput, fContextReq,
TargetDataRep, &init_context.sub_context,
init_context.spnego ? &mech_output : pOutput, pfContextAttr, ptsTimeStamp);
}
@@ -1127,7 +1128,7 @@ static SECURITY_STATUS SEC_ENTRY negotiate_AcceptSecurityContext(
init_context.mic = TRUE;
first_mech = init_context.mech;
- init_context.mech = NULL;
+ init_context.mech = nullptr;
output_token.mechToken.cbBuffer = 0;
}
@@ -1142,10 +1143,10 @@ static SECURITY_STATUS SEC_ENTRY negotiate_AcceptSecurityContext(
/* Microsoft may send two versions of the kerberos OID */
if (init_context.mech == first_mech)
- init_context.mech = NULL;
+ init_context.mech = nullptr;
if (init_context.mech && !negotiate_FindCredential(creds, init_context.mech))
- init_context.mech = NULL;
+ init_context.mech = nullptr;
}
if (!init_context.mech)
@@ -1263,7 +1264,7 @@ static SECURITY_STATUS SEC_ENTRY negotiate_AcceptSecurityContext(
static SECURITY_STATUS SEC_ENTRY negotiate_CompleteAuthToken(PCtxtHandle phContext,
PSecBufferDesc pToken)
{
- NEGOTIATE_CONTEXT* context = NULL;
+ NEGOTIATE_CONTEXT* context = nullptr;
SECURITY_STATUS status = SEC_E_OK;
context = (NEGOTIATE_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
@@ -1281,10 +1282,10 @@ static SECURITY_STATUS SEC_ENTRY negotiate_CompleteAuthToken(PCtxtHandle phConte
static SECURITY_STATUS SEC_ENTRY negotiate_DeleteSecurityContext(PCtxtHandle phContext)
{
- NEGOTIATE_CONTEXT* context = NULL;
+ NEGOTIATE_CONTEXT* context = nullptr;
SECURITY_STATUS status = SEC_E_OK;
context = (NEGOTIATE_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
- const SecPkg* pkg = NULL;
+ const SecPkg* pkg = nullptr;
if (!context)
return SEC_E_INVALID_HANDLE;
@@ -1391,7 +1392,7 @@ static SECURITY_STATUS SEC_ENTRY negotiate_SetCredentialsAttributesW(PCredHandle
ULONG ulAttribute,
void* pBuffer, ULONG cbBuffer)
{
- MechCred* creds = NULL;
+ MechCred* creds = nullptr;
BOOL success = FALSE;
SECURITY_STATUS secStatus = 0;
@@ -1425,7 +1426,7 @@ static SECURITY_STATUS SEC_ENTRY negotiate_SetCredentialsAttributesA(PCredHandle
ULONG ulAttribute,
void* pBuffer, ULONG cbBuffer)
{
- MechCred* creds = NULL;
+ MechCred* creds = nullptr;
BOOL success = FALSE;
SECURITY_STATUS secStatus = 0;
@@ -1676,30 +1677,30 @@ static SECURITY_STATUS SEC_ENTRY negotiate_VerifySignature(PCtxtHandle phContext
const SecurityFunctionTableA NEGOTIATE_SecurityFunctionTableA = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
negotiate_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
negotiate_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
negotiate_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
negotiate_InitializeSecurityContextA, /* InitializeSecurityContext */
negotiate_AcceptSecurityContext, /* AcceptSecurityContext */
negotiate_CompleteAuthToken, /* CompleteAuthToken */
negotiate_DeleteSecurityContext, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* ApplyControlToken */
negotiate_QueryContextAttributesA, /* QueryContextAttributes */
negotiate_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
negotiate_RevertSecurityContext, /* RevertSecurityContext */
negotiate_MakeSignature, /* MakeSignature */
negotiate_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
negotiate_EncryptMessage, /* EncryptMessage */
negotiate_DecryptMessage, /* DecryptMessage */
negotiate_SetContextAttributesA, /* SetContextAttributes */
@@ -1708,30 +1709,30 @@ const SecurityFunctionTableA NEGOTIATE_SecurityFunctionTableA = {
const SecurityFunctionTableW NEGOTIATE_SecurityFunctionTableW = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
negotiate_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
negotiate_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
negotiate_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
negotiate_InitializeSecurityContextW, /* InitializeSecurityContext */
negotiate_AcceptSecurityContext, /* AcceptSecurityContext */
negotiate_CompleteAuthToken, /* CompleteAuthToken */
negotiate_DeleteSecurityContext, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* ApplyControlToken */
negotiate_QueryContextAttributesW, /* QueryContextAttributes */
negotiate_ImpersonateSecurityContext, /* ImpersonateSecurityContext */
negotiate_RevertSecurityContext, /* RevertSecurityContext */
negotiate_MakeSignature, /* MakeSignature */
negotiate_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
negotiate_EncryptMessage, /* EncryptMessage */
negotiate_DecryptMessage, /* DecryptMessage */
negotiate_SetContextAttributesW, /* SetContextAttributes */
diff --git a/winpr/libwinpr/sspi/Negotiate/negotiate.h b/winpr/libwinpr/sspi/Negotiate/negotiate.h
index 23677095f..b22503b6b 100644
--- a/winpr/libwinpr/sspi/Negotiate/negotiate.h
+++ b/winpr/libwinpr/sspi/Negotiate/negotiate.h
@@ -52,7 +52,7 @@ static inline NEGOTIATE_CONTEXT NEGOTIATE_CONTEXT_init(void)
const NEGOTIATE_CONTEXT empty = { .state = NEGOTIATE_STATE_INITIAL,
.sub_context = { 0 },
.mechTypes = { 0 },
- .mech = NULL,
+ .mech = nullptr,
.mic = FALSE,
.spnego = FALSE };
return empty;
diff --git a/winpr/libwinpr/sspi/Schannel/schannel.c b/winpr/libwinpr/sspi/Schannel/schannel.c
index 034285b4e..328f1d7fb 100644
--- a/winpr/libwinpr/sspi/Schannel/schannel.c
+++ b/winpr/libwinpr/sspi/Schannel/schannel.c
@@ -33,18 +33,18 @@ static char* SCHANNEL_PACKAGE_NAME = "Schannel";
SCHANNEL_CONTEXT* schannel_ContextNew(void)
{
- SCHANNEL_CONTEXT* context = NULL;
+ SCHANNEL_CONTEXT* context = nullptr;
context = (SCHANNEL_CONTEXT*)calloc(1, sizeof(SCHANNEL_CONTEXT));
if (!context)
- return NULL;
+ return nullptr;
context->openssl = schannel_openssl_new();
if (!context->openssl)
{
free(context);
- return NULL;
+ return nullptr;
}
return context;
@@ -61,7 +61,7 @@ void schannel_ContextFree(SCHANNEL_CONTEXT* context)
static SCHANNEL_CREDENTIALS* schannel_CredentialsNew(void)
{
- SCHANNEL_CREDENTIALS* credentials = NULL;
+ SCHANNEL_CREDENTIALS* credentials = nullptr;
credentials = (SCHANNEL_CREDENTIALS*)calloc(1, sizeof(SCHANNEL_CREDENTIALS));
return credentials;
}
@@ -130,11 +130,11 @@ static SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleW(
WINPR_ATTR_UNUSED SEC_GET_KEY_FN pGetKeyFn, WINPR_ATTR_UNUSED void* pvGetKeyArgument,
PCredHandle phCredential, WINPR_ATTR_UNUSED PTimeStamp ptsExpiry)
{
- SCHANNEL_CREDENTIALS* credentials = NULL;
+ SCHANNEL_CREDENTIALS* credentials = nullptr;
if (fCredentialUse == SECPKG_CRED_OUTBOUND)
{
- SCHANNEL_CRED* cred = NULL;
+ SCHANNEL_CRED* cred = nullptr;
credentials = schannel_CredentialsNew();
credentials->fCredentialUse = fCredentialUse;
cred = (SCHANNEL_CRED*)pAuthData;
@@ -166,12 +166,12 @@ static SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleA(
PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- SEC_WCHAR* pszPrincipalW = NULL;
- SEC_WCHAR* pszPackageW = NULL;
+ SEC_WCHAR* pszPrincipalW = nullptr;
+ SEC_WCHAR* pszPackageW = nullptr;
if (pszPrincipal)
- pszPrincipalW = ConvertUtf8ToWCharAlloc(pszPrincipal, NULL);
+ pszPrincipalW = ConvertUtf8ToWCharAlloc(pszPrincipal, nullptr);
if (pszPackage)
- pszPackageW = ConvertUtf8ToWCharAlloc(pszPackage, NULL);
+ pszPackageW = ConvertUtf8ToWCharAlloc(pszPackage, nullptr);
status = schannel_AcquireCredentialsHandleW(pszPrincipalW, pszPackageW, fCredentialUse,
pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument,
@@ -183,7 +183,7 @@ static SECURITY_STATUS SEC_ENTRY schannel_AcquireCredentialsHandleA(
static SECURITY_STATUS SEC_ENTRY schannel_FreeCredentialsHandle(PCredHandle phCredential)
{
- SCHANNEL_CREDENTIALS* credentials = NULL;
+ SCHANNEL_CREDENTIALS* credentials = nullptr;
if (!phCredential)
return SEC_E_INVALID_HANDLE;
@@ -205,8 +205,8 @@ static SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextW(
WINPR_ATTR_UNUSED PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- SCHANNEL_CONTEXT* context = NULL;
- SCHANNEL_CREDENTIALS* credentials = NULL;
+ SCHANNEL_CONTEXT* context = nullptr;
+ SCHANNEL_CREDENTIALS* credentials = nullptr;
/* behave like windows SSPIs that don't want empty context */
if (phContext && !phContext->dwLower && !phContext->dwUpper)
@@ -239,11 +239,11 @@ static SECURITY_STATUS SEC_ENTRY schannel_InitializeSecurityContextA(
PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- SEC_WCHAR* pszTargetNameW = NULL;
+ SEC_WCHAR* pszTargetNameW = nullptr;
- if (pszTargetName != NULL)
+ if (pszTargetName != nullptr)
{
- pszTargetNameW = ConvertUtf8ToWCharAlloc(pszTargetName, NULL);
+ pszTargetNameW = ConvertUtf8ToWCharAlloc(pszTargetName, nullptr);
if (!pszTargetNameW)
return SEC_E_INSUFFICIENT_MEMORY;
}
@@ -262,7 +262,7 @@ static SECURITY_STATUS SEC_ENTRY schannel_AcceptSecurityContext(
WINPR_ATTR_UNUSED PTimeStamp ptsTimeStamp)
{
SECURITY_STATUS status = 0;
- SCHANNEL_CONTEXT* context = NULL;
+ SCHANNEL_CONTEXT* context = nullptr;
/* behave like windows SSPIs that don't want empty context */
if (phContext && !phContext->dwLower && !phContext->dwUpper)
@@ -289,7 +289,7 @@ static SECURITY_STATUS SEC_ENTRY schannel_AcceptSecurityContext(
static SECURITY_STATUS SEC_ENTRY schannel_DeleteSecurityContext(PCtxtHandle phContext)
{
- SCHANNEL_CONTEXT* context = NULL;
+ SCHANNEL_CONTEXT* context = nullptr;
context = (SCHANNEL_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
@@ -354,7 +354,7 @@ static SECURITY_STATUS SEC_ENTRY schannel_EncryptMessage(WINPR_ATTR_UNUSED PCtxt
WINPR_ATTR_UNUSED ULONG MessageSeqNo)
{
SECURITY_STATUS status = 0;
- SCHANNEL_CONTEXT* context = NULL;
+ SCHANNEL_CONTEXT* context = nullptr;
context = (SCHANNEL_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
@@ -370,7 +370,7 @@ static SECURITY_STATUS SEC_ENTRY schannel_DecryptMessage(PCtxtHandle phContext,
WINPR_ATTR_UNUSED ULONG* pfQOP)
{
SECURITY_STATUS status = 0;
- SCHANNEL_CONTEXT* context = NULL;
+ SCHANNEL_CONTEXT* context = nullptr;
context = (SCHANNEL_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
@@ -382,66 +382,66 @@ static SECURITY_STATUS SEC_ENTRY schannel_DecryptMessage(PCtxtHandle phContext,
const SecurityFunctionTableA SCHANNEL_SecurityFunctionTableA = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
schannel_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
schannel_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
schannel_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
schannel_InitializeSecurityContextA, /* InitializeSecurityContext */
schannel_AcceptSecurityContext, /* AcceptSecurityContext */
- NULL, /* CompleteAuthToken */
+ nullptr, /* CompleteAuthToken */
schannel_DeleteSecurityContext, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* ApplyControlToken */
schannel_QueryContextAttributes, /* QueryContextAttributes */
- NULL, /* ImpersonateSecurityContext */
- NULL, /* RevertSecurityContext */
+ nullptr, /* ImpersonateSecurityContext */
+ nullptr, /* RevertSecurityContext */
schannel_MakeSignature, /* MakeSignature */
schannel_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
schannel_EncryptMessage, /* EncryptMessage */
schannel_DecryptMessage, /* DecryptMessage */
- NULL, /* SetContextAttributes */
- NULL, /* SetCredentialsAttributes */
+ nullptr, /* SetContextAttributes */
+ nullptr, /* SetCredentialsAttributes */
};
const SecurityFunctionTableW SCHANNEL_SecurityFunctionTableW = {
3, /* dwVersion */
- NULL, /* EnumerateSecurityPackages */
+ nullptr, /* EnumerateSecurityPackages */
schannel_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
schannel_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
schannel_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
schannel_InitializeSecurityContextW, /* InitializeSecurityContext */
schannel_AcceptSecurityContext, /* AcceptSecurityContext */
- NULL, /* CompleteAuthToken */
+ nullptr, /* CompleteAuthToken */
schannel_DeleteSecurityContext, /* DeleteSecurityContext */
- NULL, /* ApplyControlToken */
+ nullptr, /* ApplyControlToken */
schannel_QueryContextAttributes, /* QueryContextAttributes */
- NULL, /* ImpersonateSecurityContext */
- NULL, /* RevertSecurityContext */
+ nullptr, /* ImpersonateSecurityContext */
+ nullptr, /* RevertSecurityContext */
schannel_MakeSignature, /* MakeSignature */
schannel_VerifySignature, /* VerifySignature */
- NULL, /* FreeContextBuffer */
- NULL, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
- NULL, /* ExportSecurityContext */
- NULL, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
- NULL, /* QuerySecurityContextToken */
+ nullptr, /* FreeContextBuffer */
+ nullptr, /* QuerySecurityPackageInfo */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
+ nullptr, /* ExportSecurityContext */
+ nullptr, /* ImportSecurityContext */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
+ nullptr, /* QuerySecurityContextToken */
schannel_EncryptMessage, /* EncryptMessage */
schannel_DecryptMessage, /* DecryptMessage */
- NULL, /* SetContextAttributes */
- NULL, /* SetCredentialsAttributes */
+ nullptr, /* SetContextAttributes */
+ nullptr, /* SetCredentialsAttributes */
};
const SecPkgInfoA SCHANNEL_SecPkgInfoA = {
diff --git a/winpr/libwinpr/sspi/Schannel/schannel_openssl.c b/winpr/libwinpr/sspi/Schannel/schannel_openssl.c
index 16c442138..231238ff1 100644
--- a/winpr/libwinpr/sspi/Schannel/schannel_openssl.c
+++ b/winpr/libwinpr/sspi/Schannel/schannel_openssl.c
@@ -79,23 +79,23 @@ static void schannel_context_cleanup(SCHANNEL_OPENSSL* context)
WINPR_ASSERT(context);
free(context->ReadBuffer);
- context->ReadBuffer = NULL;
+ context->ReadBuffer = nullptr;
if (context->bioWrite)
BIO_free_all(context->bioWrite);
- context->bioWrite = NULL;
+ context->bioWrite = nullptr;
if (context->bioRead)
BIO_free_all(context->bioRead);
- context->bioRead = NULL;
+ context->bioRead = nullptr;
if (context->ssl)
SSL_free(context->ssl);
- context->ssl = NULL;
+ context->ssl = nullptr;
if (context->ctx)
SSL_CTX_free(context->ctx);
- context->ctx = NULL;
+ context->ctx = nullptr;
}
static const SSL_METHOD* get_method(BOOL server)
@@ -366,7 +366,7 @@ SECURITY_STATUS schannel_openssl_client_process_tokens(SCHANNEL_OPENSSL* context
{
int status = 0;
int ssl_error = 0;
- PSecBuffer pBuffer = NULL;
+ PSecBuffer pBuffer = nullptr;
if (!context->connected)
{
@@ -435,7 +435,7 @@ SECURITY_STATUS schannel_openssl_server_process_tokens(SCHANNEL_OPENSSL* context
{
int status = 0;
int ssl_error = 0;
- PSecBuffer pBuffer = NULL;
+ PSecBuffer pBuffer = nullptr;
if (!context->connected)
{
@@ -503,9 +503,9 @@ SECURITY_STATUS schannel_openssl_encrypt_message(SCHANNEL_OPENSSL* context, PSec
{
int status = 0;
int ssl_error = 0;
- PSecBuffer pStreamBodyBuffer = NULL;
- PSecBuffer pStreamHeaderBuffer = NULL;
- PSecBuffer pStreamTrailerBuffer = NULL;
+ PSecBuffer pStreamBodyBuffer = nullptr;
+ PSecBuffer pStreamHeaderBuffer = nullptr;
+ PSecBuffer pStreamTrailerBuffer = nullptr;
pStreamHeaderBuffer = sspi_FindSecBuffer(pMessage, SECBUFFER_STREAM_HEADER);
pStreamBodyBuffer = sspi_FindSecBuffer(pMessage, SECBUFFER_DATA);
pStreamTrailerBuffer = sspi_FindSecBuffer(pMessage, SECBUFFER_STREAM_TRAILER);
@@ -552,9 +552,9 @@ SECURITY_STATUS schannel_openssl_decrypt_message(SCHANNEL_OPENSSL* context, PSec
{
int status = 0;
int length = 0;
- BYTE* buffer = NULL;
+ BYTE* buffer = nullptr;
int ssl_error = 0;
- PSecBuffer pBuffer = NULL;
+ PSecBuffer pBuffer = nullptr;
pBuffer = sspi_FindSecBuffer(pMessage, SECBUFFER_DATA);
if (!pBuffer)
@@ -587,10 +587,10 @@ SECURITY_STATUS schannel_openssl_decrypt_message(SCHANNEL_OPENSSL* context, PSec
SCHANNEL_OPENSSL* schannel_openssl_new(void)
{
- SCHANNEL_OPENSSL* context = NULL;
+ SCHANNEL_OPENSSL* context = nullptr;
context = (SCHANNEL_OPENSSL*)calloc(1, sizeof(SCHANNEL_OPENSSL));
- if (context != NULL)
+ if (context != nullptr)
{
winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT);
context->connected = FALSE;
@@ -647,7 +647,7 @@ SECURITY_STATUS schannel_openssl_decrypt_message(SCHANNEL_OPENSSL* context, PSec
SCHANNEL_OPENSSL* schannel_openssl_new(void)
{
- return NULL;
+ return nullptr;
}
void schannel_openssl_free(SCHANNEL_OPENSSL* context)
diff --git a/winpr/libwinpr/sspi/sspi.c b/winpr/libwinpr/sspi/sspi.c
index 93834a6d9..b7b7a2789 100644
--- a/winpr/libwinpr/sspi/sspi.c
+++ b/winpr/libwinpr/sspi/sspi.c
@@ -41,17 +41,17 @@ WINPR_PRAGMA_DIAG_POP
WINPR_PRAGMA_DIAG_PUSH
WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES
-static wLog* g_Log = NULL;
+static wLog* g_Log = nullptr;
static INIT_ONCE g_Initialized = INIT_ONCE_STATIC_INIT;
#if defined(WITH_NATIVE_SSPI)
-static HMODULE g_SspiModule = NULL;
+static HMODULE g_SspiModule = nullptr;
static SecurityFunctionTableW windows_SecurityFunctionTableW = WINPR_C_ARRAY_INIT;
static SecurityFunctionTableA windows_SecurityFunctionTableA = WINPR_C_ARRAY_INIT;
#endif
-static SecurityFunctionTableW* g_SspiW = NULL;
-static SecurityFunctionTableA* g_SspiA = NULL;
+static SecurityFunctionTableW* g_SspiW = nullptr;
+static SecurityFunctionTableA* g_SspiA = nullptr;
#if defined(WITH_NATIVE_SSPI)
static BOOL ShouldUseNativeSspi(void);
@@ -65,8 +65,8 @@ BOOL ShouldUseNativeSspi(void)
#ifdef _WIN32
LPCSTR sspi = "WINPR_NATIVE_SSPI";
DWORD nSize;
- char* env = NULL;
- nSize = GetEnvironmentVariableA(sspi, NULL, 0);
+ char* env = nullptr;
+ nSize = GetEnvironmentVariableA(sspi, nullptr, 0);
if (!nSize)
return TRUE;
@@ -96,8 +96,8 @@ BOOL ShouldUseNativeSspi(void)
#if defined(WITH_NATIVE_SSPI)
BOOL InitializeSspiModule_Native(void)
{
- SecurityFunctionTableW* pSspiW = NULL;
- SecurityFunctionTableA* pSspiA = NULL;
+ SecurityFunctionTableW* pSspiW = nullptr;
+ SecurityFunctionTableA* pSspiA = nullptr;
INIT_SECURITY_INTERFACE_W pInitSecurityInterfaceW;
INIT_SECURITY_INTERFACE_A pInitSecurityInterfaceA;
g_SspiModule = LoadLibraryA("secur32.dll");
@@ -490,14 +490,14 @@ BOOL IsSecurityStatusError(SECURITY_STATUS status)
SecurityFunctionTableW* SEC_ENTRY InitSecurityInterfaceExW(DWORD flags)
{
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, &flags, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, &flags, nullptr);
WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceExW");
return g_SspiW;
}
SecurityFunctionTableA* SEC_ENTRY InitSecurityInterfaceExA(DWORD flags)
{
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, &flags, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, &flags, nullptr);
WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceExA");
return g_SspiA;
}
@@ -512,7 +512,7 @@ SECURITY_STATUS SEC_ENTRY sspi_EnumerateSecurityPackagesW(ULONG* pcPackages,
PSecPkgInfoW* ppPackageInfo)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->EnumerateSecurityPackagesW))
{
@@ -531,7 +531,7 @@ SECURITY_STATUS SEC_ENTRY sspi_EnumerateSecurityPackagesA(ULONG* pcPackages,
PSecPkgInfoA* ppPackageInfo)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiA && g_SspiA->EnumerateSecurityPackagesA))
{
@@ -548,14 +548,14 @@ SECURITY_STATUS SEC_ENTRY sspi_EnumerateSecurityPackagesA(ULONG* pcPackages,
SecurityFunctionTableW* SEC_ENTRY sspi_InitSecurityInterfaceW(void)
{
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceW");
return g_SspiW;
}
SecurityFunctionTableA* SEC_ENTRY sspi_InitSecurityInterfaceA(void)
{
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
WLog_Print(g_Log, WLOG_DEBUG, "InitSecurityInterfaceA");
return g_SspiA;
}
@@ -564,7 +564,7 @@ SECURITY_STATUS SEC_ENTRY sspi_QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageNa
PSecPkgInfoW* ppPackageInfo)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->QuerySecurityPackageInfoW))
{
@@ -583,7 +583,7 @@ SECURITY_STATUS SEC_ENTRY sspi_QuerySecurityPackageInfoA(SEC_CHAR* pszPackageNam
PSecPkgInfoA* ppPackageInfo)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiA && g_SspiA->QuerySecurityPackageInfoA))
{
@@ -606,7 +606,7 @@ SECURITY_STATUS SEC_ENTRY sspi_AcquireCredentialsHandleW(
PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->AcquireCredentialsHandleW))
{
@@ -629,7 +629,7 @@ SECURITY_STATUS SEC_ENTRY sspi_AcquireCredentialsHandleA(
PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiA && g_SspiA->AcquireCredentialsHandleA))
{
@@ -650,7 +650,7 @@ SECURITY_STATUS SEC_ENTRY sspi_ExportSecurityContext(PCtxtHandle phContext, ULON
PSecBuffer pPackedContext, HANDLE* pToken)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->ExportSecurityContext))
{
@@ -668,7 +668,7 @@ SECURITY_STATUS SEC_ENTRY sspi_ExportSecurityContext(PCtxtHandle phContext, ULON
SECURITY_STATUS SEC_ENTRY sspi_FreeCredentialsHandle(PCredHandle phCredential)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->FreeCredentialsHandle))
{
@@ -688,7 +688,7 @@ SECURITY_STATUS SEC_ENTRY sspi_ImportSecurityContextW(SEC_WCHAR* pszPackage,
PCtxtHandle phContext)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->ImportSecurityContextW))
{
@@ -708,7 +708,7 @@ SECURITY_STATUS SEC_ENTRY sspi_ImportSecurityContextA(SEC_CHAR* pszPackage,
PCtxtHandle phContext)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiA && g_SspiA->ImportSecurityContextA))
{
@@ -727,7 +727,7 @@ SECURITY_STATUS SEC_ENTRY sspi_QueryCredentialsAttributesW(PCredHandle phCredent
ULONG ulAttribute, void* pBuffer)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->QueryCredentialsAttributesW))
{
@@ -746,7 +746,7 @@ SECURITY_STATUS SEC_ENTRY sspi_QueryCredentialsAttributesA(PCredHandle phCredent
ULONG ulAttribute, void* pBuffer)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiA && g_SspiA->QueryCredentialsAttributesA))
{
@@ -771,7 +771,7 @@ SECURITY_STATUS SEC_ENTRY sspi_AcceptSecurityContext(PCredHandle phCredential,
PTimeStamp ptsTimeStamp)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->AcceptSecurityContext))
{
@@ -791,7 +791,7 @@ SECURITY_STATUS SEC_ENTRY sspi_AcceptSecurityContext(PCredHandle phCredential,
SECURITY_STATUS SEC_ENTRY sspi_ApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->ApplyControlToken))
{
@@ -809,7 +809,7 @@ SECURITY_STATUS SEC_ENTRY sspi_ApplyControlToken(PCtxtHandle phContext, PSecBuff
SECURITY_STATUS SEC_ENTRY sspi_CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->CompleteAuthToken))
{
@@ -827,7 +827,7 @@ SECURITY_STATUS SEC_ENTRY sspi_CompleteAuthToken(PCtxtHandle phContext, PSecBuff
SECURITY_STATUS SEC_ENTRY sspi_DeleteSecurityContext(PCtxtHandle phContext)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->DeleteSecurityContext))
{
@@ -845,7 +845,7 @@ SECURITY_STATUS SEC_ENTRY sspi_DeleteSecurityContext(PCtxtHandle phContext)
SECURITY_STATUS SEC_ENTRY sspi_FreeContextBuffer(void* pvContextBuffer)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->FreeContextBuffer))
{
@@ -863,7 +863,7 @@ SECURITY_STATUS SEC_ENTRY sspi_FreeContextBuffer(void* pvContextBuffer)
SECURITY_STATUS SEC_ENTRY sspi_ImpersonateSecurityContext(PCtxtHandle phContext)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->ImpersonateSecurityContext))
{
@@ -884,7 +884,7 @@ SECURITY_STATUS SEC_ENTRY sspi_InitializeSecurityContextW(
PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->InitializeSecurityContextW))
{
@@ -907,7 +907,7 @@ SECURITY_STATUS SEC_ENTRY sspi_InitializeSecurityContextA(
PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiA && g_SspiA->InitializeSecurityContextA))
{
@@ -928,7 +928,7 @@ SECURITY_STATUS SEC_ENTRY sspi_QueryContextAttributesW(PCtxtHandle phContext, UL
void* pBuffer)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->QueryContextAttributesW))
{
@@ -947,7 +947,7 @@ SECURITY_STATUS SEC_ENTRY sspi_QueryContextAttributesA(PCtxtHandle phContext, UL
void* pBuffer)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiA && g_SspiA->QueryContextAttributesA))
{
@@ -965,7 +965,7 @@ SECURITY_STATUS SEC_ENTRY sspi_QueryContextAttributesA(PCtxtHandle phContext, UL
SECURITY_STATUS SEC_ENTRY sspi_QuerySecurityContextToken(PCtxtHandle phContext, HANDLE* phToken)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->QuerySecurityContextToken))
{
@@ -984,7 +984,7 @@ SECURITY_STATUS SEC_ENTRY sspi_SetContextAttributesW(PCtxtHandle phContext, ULON
void* pBuffer, ULONG cbBuffer)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->SetContextAttributesW))
{
@@ -1003,7 +1003,7 @@ SECURITY_STATUS SEC_ENTRY sspi_SetContextAttributesA(PCtxtHandle phContext, ULON
void* pBuffer, ULONG cbBuffer)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiA && g_SspiA->SetContextAttributesA))
{
@@ -1021,7 +1021,7 @@ SECURITY_STATUS SEC_ENTRY sspi_SetContextAttributesA(PCtxtHandle phContext, ULON
SECURITY_STATUS SEC_ENTRY sspi_RevertSecurityContext(PCtxtHandle phContext)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->RevertSecurityContext))
{
@@ -1042,7 +1042,7 @@ SECURITY_STATUS SEC_ENTRY sspi_DecryptMessage(PCtxtHandle phContext, PSecBufferD
ULONG MessageSeqNo, PULONG pfQOP)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->DecryptMessage))
{
@@ -1061,7 +1061,7 @@ SECURITY_STATUS SEC_ENTRY sspi_EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
PSecBufferDesc pMessage, ULONG MessageSeqNo)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->EncryptMessage))
{
@@ -1080,7 +1080,7 @@ SECURITY_STATUS SEC_ENTRY sspi_MakeSignature(PCtxtHandle phContext, ULONG fQOP,
PSecBufferDesc pMessage, ULONG MessageSeqNo)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->MakeSignature))
{
@@ -1099,7 +1099,7 @@ SECURITY_STATUS SEC_ENTRY sspi_VerifySignature(PCtxtHandle phContext, PSecBuffer
ULONG MessageSeqNo, PULONG pfQOP)
{
SECURITY_STATUS status = 0;
- InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, NULL, NULL);
+ InitOnceExecuteOnce(&g_Initialized, InitializeSspiModuleInt, nullptr, nullptr);
if (!(g_SspiW && g_SspiW->VerifySignature))
{
diff --git a/winpr/libwinpr/sspi/sspi_gss.c b/winpr/libwinpr/sspi/sspi_gss.c
index cfd0b0599..c401bae58 100644
--- a/winpr/libwinpr/sspi/sspi_gss.c
+++ b/winpr/libwinpr/sspi/sspi_gss.c
@@ -30,7 +30,7 @@
BOOL sspi_gss_wrap_token(SecBuffer* buf, const WinPrAsn1_OID* oid, uint16_t tok_id,
const sspi_gss_data* token)
{
- WinPrAsn1Encoder* enc = NULL;
+ WinPrAsn1Encoder* enc = nullptr;
BYTE tok_id_buf[2];
WinPrAsn1_MemoryChunk mc = { 2, tok_id_buf };
wStream s;
@@ -90,7 +90,7 @@ BOOL sspi_gss_unwrap_token(const SecBuffer* buf, WinPrAsn1_OID* oid, uint16_t* t
WinPrAsn1Decoder dec2 = WinPrAsn1Decoder_init();
WinPrAsn1_tagId tag = 0;
wStream sbuffer = WINPR_C_ARRAY_INIT;
- wStream* s = NULL;
+ wStream* s = nullptr;
WINPR_ASSERT(buf);
WINPR_ASSERT(oid);
diff --git a/winpr/libwinpr/sspi/sspi_winpr.c b/winpr/libwinpr/sspi/sspi_winpr.c
index d0cd7a2a2..6737dae56 100644
--- a/winpr/libwinpr/sspi/sspi_winpr.c
+++ b/winpr/libwinpr/sspi/sspi_winpr.c
@@ -99,7 +99,7 @@ static CONTEXT_BUFFER_ALLOC_TABLE ContextBufferAllocTable = WINPR_C_ARRAY_INIT;
static int sspi_ContextBufferAllocTableNew(void)
{
size_t size = 0;
- ContextBufferAllocTable.entries = NULL;
+ ContextBufferAllocTable.entries = nullptr;
ContextBufferAllocTable.cEntries = 0;
ContextBufferAllocTable.cMaxEntries = 4;
size = sizeof(CONTEXT_BUFFER_ALLOC_ENTRY) * ContextBufferAllocTable.cMaxEntries;
@@ -114,7 +114,7 @@ static int sspi_ContextBufferAllocTableNew(void)
static int sspi_ContextBufferAllocTableGrow(void)
{
size_t size = 0;
- CONTEXT_BUFFER_ALLOC_ENTRY* entries = NULL;
+ CONTEXT_BUFFER_ALLOC_ENTRY* entries = nullptr;
ContextBufferAllocTable.cEntries = 0;
ContextBufferAllocTable.cMaxEntries *= 2;
size = sizeof(CONTEXT_BUFFER_ALLOC_ENTRY) * ContextBufferAllocTable.cMaxEntries;
@@ -144,12 +144,12 @@ static void sspi_ContextBufferAllocTableFree(void)
ContextBufferAllocTable.cEntries = ContextBufferAllocTable.cMaxEntries = 0;
free(ContextBufferAllocTable.entries);
- ContextBufferAllocTable.entries = NULL;
+ ContextBufferAllocTable.entries = nullptr;
}
void* sspi_ContextBufferAlloc(UINT32 allocatorIndex, size_t size)
{
- void* contextBuffer = NULL;
+ void* contextBuffer = nullptr;
for (UINT32 index = 0; index < ContextBufferAllocTable.cMaxEntries; index++)
{
@@ -158,7 +158,7 @@ void* sspi_ContextBufferAlloc(UINT32 allocatorIndex, size_t size)
contextBuffer = calloc(1, size);
if (!contextBuffer)
- return NULL;
+ return nullptr;
ContextBufferAllocTable.cEntries++;
ContextBufferAllocTable.entries[index].contextBuffer = contextBuffer;
@@ -170,7 +170,7 @@ void* sspi_ContextBufferAlloc(UINT32 allocatorIndex, size_t size)
/* no available entry was found, the table needs to be grown */
if (sspi_ContextBufferAllocTableGrow() < 0)
- return NULL;
+ return nullptr;
/* the next call to sspi_ContextBufferAlloc() should now succeed */
return sspi_ContextBufferAlloc(allocatorIndex, size);
@@ -178,7 +178,7 @@ void* sspi_ContextBufferAlloc(UINT32 allocatorIndex, size_t size)
SSPI_CREDENTIALS* sspi_CredentialsNew(void)
{
- SSPI_CREDENTIALS* credentials = NULL;
+ SSPI_CREDENTIALS* credentials = nullptr;
credentials = (SSPI_CREDENTIALS*)calloc(1, sizeof(SSPI_CREDENTIALS));
return credentials;
}
@@ -224,12 +224,12 @@ void sspi_CredentialsFree(SSPI_CREDENTIALS* credentials)
void* sspi_SecBufferAlloc(PSecBuffer SecBuffer, ULONG size)
{
if (!SecBuffer)
- return NULL;
+ return nullptr;
SecBuffer->pvBuffer = calloc(1, size);
if (!SecBuffer->pvBuffer)
- return NULL;
+ return nullptr;
SecBuffer->cbBuffer = size;
return SecBuffer->pvBuffer;
@@ -244,7 +244,7 @@ void sspi_SecBufferFree(PSecBuffer SecBuffer)
memset(SecBuffer->pvBuffer, 0, SecBuffer->cbBuffer);
free(SecBuffer->pvBuffer);
- SecBuffer->pvBuffer = NULL;
+ SecBuffer->pvBuffer = nullptr;
SecBuffer->cbBuffer = 0;
}
@@ -253,7 +253,7 @@ SecHandle* sspi_SecureHandleAlloc(void)
SecHandle* handle = (SecHandle*)calloc(1, sizeof(SecHandle));
if (!handle)
- return NULL;
+ return nullptr;
SecInvalidateHandle(handle);
return handle;
@@ -261,10 +261,10 @@ SecHandle* sspi_SecureHandleAlloc(void)
void* sspi_SecureHandleGetLowerPointer(SecHandle* handle)
{
- void* pointer = NULL;
+ void* pointer = nullptr;
if (!handle || !SecIsValidHandle(handle) || !handle->dwLower)
- return NULL;
+ return nullptr;
pointer = (void*)~((size_t)handle->dwLower);
return pointer;
@@ -289,10 +289,10 @@ void sspi_SecureHandleSetLowerPointer(SecHandle* handle, void* pointer)
void* sspi_SecureHandleGetUpperPointer(SecHandle* handle)
{
- void* pointer = NULL;
+ void* pointer = nullptr;
if (!handle || !SecIsValidHandle(handle) || !handle->dwUpper)
- return NULL;
+ return nullptr;
pointer = (void*)~((size_t)handle->dwUpper);
return pointer;
@@ -324,7 +324,7 @@ static BOOL copy(WCHAR** dst, ULONG* dstLen, const WCHAR* what, size_t len)
WINPR_ASSERT(dst);
WINPR_ASSERT(dstLen);
- *dst = NULL;
+ *dst = nullptr;
*dstLen = 0;
if (len > UINT32_MAX)
@@ -380,9 +380,9 @@ int sspi_SetAuthIdentityA(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, c
size_t unicodeUserLenW = 0;
size_t unicodeDomainLenW = 0;
size_t unicodePasswordLenW = 0;
- LPWSTR unicodeUser = NULL;
- LPWSTR unicodeDomain = NULL;
- LPWSTR unicodePassword = NULL;
+ LPWSTR unicodeUser = nullptr;
+ LPWSTR unicodeDomain = nullptr;
+ LPWSTR unicodePassword = nullptr;
if (user)
unicodeUser = ConvertUtf8ToWCharAlloc(user, &unicodeUserLenW);
@@ -590,12 +590,12 @@ BOOL sspi_CopyAuthIdentityFieldsA(const SEC_WINNT_AUTH_IDENTITY_INFO* identity,
char** pDomain, char** pPassword)
{
BOOL success = FALSE;
- const char* UserA = NULL;
- const char* DomainA = NULL;
- const char* PasswordA = NULL;
- const WCHAR* UserW = NULL;
- const WCHAR* DomainW = NULL;
- const WCHAR* PasswordW = NULL;
+ const char* UserA = nullptr;
+ const char* DomainA = nullptr;
+ const char* PasswordA = nullptr;
+ const WCHAR* UserW = nullptr;
+ const WCHAR* DomainW = nullptr;
+ const WCHAR* PasswordW = nullptr;
UINT32 UserLength = 0;
UINT32 DomainLength = 0;
UINT32 PasswordLength = 0;
@@ -603,7 +603,7 @@ BOOL sspi_CopyAuthIdentityFieldsA(const SEC_WINNT_AUTH_IDENTITY_INFO* identity,
if (!identity || !pUser || !pDomain || !pPassword)
return FALSE;
- *pUser = *pDomain = *pPassword = NULL;
+ *pUser = *pDomain = *pPassword = nullptr;
UINT32 identityFlags = sspi_GetAuthIdentityFlags(identity);
@@ -653,21 +653,21 @@ BOOL sspi_CopyAuthIdentityFieldsA(const SEC_WINNT_AUTH_IDENTITY_INFO* identity,
if (UserW && (UserLength > 0))
{
- *pUser = ConvertWCharNToUtf8Alloc(UserW, UserLength, NULL);
+ *pUser = ConvertWCharNToUtf8Alloc(UserW, UserLength, nullptr);
if (!(*pUser))
goto cleanup;
}
if (DomainW && (DomainLength > 0))
{
- *pDomain = ConvertWCharNToUtf8Alloc(DomainW, DomainLength, NULL);
+ *pDomain = ConvertWCharNToUtf8Alloc(DomainW, DomainLength, nullptr);
if (!(*pDomain))
goto cleanup;
}
if (PasswordW && (PasswordLength > 0))
{
- *pPassword = ConvertWCharNToUtf8Alloc(PasswordW, PasswordLength, NULL);
+ *pPassword = ConvertWCharNToUtf8Alloc(PasswordW, PasswordLength, nullptr);
if (!(*pPassword))
goto cleanup;
}
@@ -683,12 +683,12 @@ BOOL sspi_CopyAuthIdentityFieldsW(const SEC_WINNT_AUTH_IDENTITY_INFO* identity,
WCHAR** pDomain, WCHAR** pPassword)
{
BOOL success = FALSE;
- const char* UserA = NULL;
- const char* DomainA = NULL;
- const char* PasswordA = NULL;
- const WCHAR* UserW = NULL;
- const WCHAR* DomainW = NULL;
- const WCHAR* PasswordW = NULL;
+ const char* UserA = nullptr;
+ const char* DomainA = nullptr;
+ const char* PasswordA = nullptr;
+ const WCHAR* UserW = nullptr;
+ const WCHAR* DomainW = nullptr;
+ const WCHAR* PasswordW = nullptr;
UINT32 UserLength = 0;
UINT32 DomainLength = 0;
UINT32 PasswordLength = 0;
@@ -696,7 +696,7 @@ BOOL sspi_CopyAuthIdentityFieldsW(const SEC_WINNT_AUTH_IDENTITY_INFO* identity,
if (!identity || !pUser || !pDomain || !pPassword)
return FALSE;
- *pUser = *pDomain = *pPassword = NULL;
+ *pUser = *pDomain = *pPassword = nullptr;
UINT32 identityFlags = sspi_GetAuthIdentityFlags(identity);
@@ -711,7 +711,7 @@ BOOL sspi_CopyAuthIdentityFieldsW(const SEC_WINNT_AUTH_IDENTITY_INFO* identity,
if (UserA && (UserLength > 0))
{
- WCHAR* ptr = ConvertUtf8NToWCharAlloc(UserA, UserLength, NULL);
+ WCHAR* ptr = ConvertUtf8NToWCharAlloc(UserA, UserLength, nullptr);
*pUser = ptr;
if (!ptr)
@@ -720,7 +720,7 @@ BOOL sspi_CopyAuthIdentityFieldsW(const SEC_WINNT_AUTH_IDENTITY_INFO* identity,
if (DomainA && (DomainLength > 0))
{
- WCHAR* ptr = ConvertUtf8NToWCharAlloc(DomainA, DomainLength, NULL);
+ WCHAR* ptr = ConvertUtf8NToWCharAlloc(DomainA, DomainLength, nullptr);
*pDomain = ptr;
if (!ptr)
goto cleanup;
@@ -728,7 +728,7 @@ BOOL sspi_CopyAuthIdentityFieldsW(const SEC_WINNT_AUTH_IDENTITY_INFO* identity,
if (PasswordA && (PasswordLength > 0))
{
- WCHAR* ptr = ConvertUtf8NToWCharAlloc(PasswordA, PasswordLength, NULL);
+ WCHAR* ptr = ConvertUtf8NToWCharAlloc(PasswordA, PasswordLength, nullptr);
*pPassword = ptr;
if (!ptr)
@@ -781,9 +781,9 @@ BOOL sspi_CopyAuthPackageListA(const SEC_WINNT_AUTH_IDENTITY_INFO* identity, cha
{
UINT32 version = 0;
UINT32 identityFlags = 0;
- char* PackageList = NULL;
- const char* PackageListA = NULL;
- const WCHAR* PackageListW = NULL;
+ char* PackageList = nullptr;
+ const char* PackageListA = nullptr;
+ const WCHAR* PackageListW = nullptr;
UINT32 PackageListLength = 0;
UINT32 PackageListOffset = 0;
const void* pAuthData = (const void*)identity;
@@ -825,7 +825,7 @@ BOOL sspi_CopyAuthPackageListA(const SEC_WINNT_AUTH_IDENTITY_INFO* identity, cha
}
if (PackageListW && (PackageListLength > 0))
- PackageList = ConvertWCharNToUtf8Alloc(PackageListW, PackageListLength, NULL);
+ PackageList = ConvertWCharNToUtf8Alloc(PackageListW, PackageListLength, nullptr);
}
if (PackageList)
@@ -842,12 +842,12 @@ int sspi_CopyAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity,
{
int status = 0;
UINT32 identityFlags = 0;
- const char* UserA = NULL;
- const char* DomainA = NULL;
- const char* PasswordA = NULL;
- const WCHAR* UserW = NULL;
- const WCHAR* DomainW = NULL;
- const WCHAR* PasswordW = NULL;
+ const char* UserA = nullptr;
+ const char* DomainA = nullptr;
+ const char* PasswordA = nullptr;
+ const WCHAR* UserW = nullptr;
+ const WCHAR* DomainW = nullptr;
+ const WCHAR* PasswordW = nullptr;
UINT32 UserLength = 0;
UINT32 DomainLength = 0;
UINT32 PasswordLength = 0;
@@ -943,7 +943,7 @@ int sspi_CopyAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity,
PSecBuffer sspi_FindSecBuffer(PSecBufferDesc pMessage, ULONG BufferType)
{
- PSecBuffer pSecBuffer = NULL;
+ PSecBuffer pSecBuffer = nullptr;
for (UINT32 index = 0; index < pMessage->cBuffers; index++)
{
@@ -991,7 +991,7 @@ void sspi_GlobalInit(void)
{
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
DWORD flags = 0;
- InitOnceExecuteOnce(&once, sspi_init, &flags, NULL);
+ InitOnceExecuteOnce(&once, sspi_init, &flags, nullptr);
}
void sspi_GlobalFinish(void)
@@ -1011,7 +1011,7 @@ static const SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const
}
}
- return NULL;
+ return nullptr;
}
static const SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const SEC_WCHAR* Name)
@@ -1026,21 +1026,21 @@ static const SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const
}
}
- return NULL;
+ return nullptr;
}
static const SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameA(const SEC_CHAR* Name)
{
- SEC_WCHAR* NameW = NULL;
- const SecurityFunctionTableW* table = NULL;
+ SEC_WCHAR* NameW = nullptr;
+ const SecurityFunctionTableW* table = nullptr;
if (!Name)
- return NULL;
+ return nullptr;
- NameW = ConvertUtf8ToWCharAlloc(Name, NULL);
+ NameW = ConvertUtf8ToWCharAlloc(Name, nullptr);
if (!NameW)
- return NULL;
+ return nullptr;
table = sspi_GetSecurityFunctionTableWByNameW(NameW);
free(NameW);
@@ -1062,7 +1062,7 @@ void sspi_ContextBufferFree(void* contextBuffer)
allocatorIndex = ContextBufferAllocTable.entries[index].allocatorIndex;
ContextBufferAllocTable.cEntries--;
ContextBufferAllocTable.entries[index].allocatorIndex = 0;
- ContextBufferAllocTable.entries[index].contextBuffer = NULL;
+ ContextBufferAllocTable.entries[index].contextBuffer = nullptr;
switch (allocatorIndex)
{
@@ -1192,7 +1192,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoW(SEC_WCHAR* pszP
}
}
- *(ppPackageInfo) = NULL;
+ *(ppPackageInfo) = nullptr;
return SEC_E_SECPKG_NOT_FOUND;
}
@@ -1230,7 +1230,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoA(SEC_CHAR* pszPa
}
}
- *(ppPackageInfo) = NULL;
+ *(ppPackageInfo) = nullptr;
return SEC_E_SECPKG_NOT_FOUND;
}
@@ -1253,7 +1253,7 @@ static SECURITY_STATUS log_status_(const char* what, SECURITY_STATUS status, con
if (IsSecurityStatusError(status))
{
const DWORD level = WLOG_WARN;
- static wLog* log = NULL;
+ static wLog* log = nullptr;
if (!log)
log = WLog_Get(TAG);
@@ -1319,9 +1319,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_ExportSecurityContext(PCtxtHandle phConte
PSecBuffer pPackedContext,
HANDLE* pToken)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1344,9 +1344,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_ExportSecurityContext(PCtxtHandle phConte
static SECURITY_STATUS SEC_ENTRY winpr_FreeCredentialsHandle(PCredHandle phCredential)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
@@ -1371,9 +1371,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_ImportSecurityContextW(SEC_WCHAR* pszPack
PSecBuffer pPackedContext,
HANDLE pToken, PCtxtHandle phContext)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1398,9 +1398,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_ImportSecurityContextA(SEC_CHAR* pszPacka
PSecBuffer pPackedContext,
HANDLE pToken, PCtxtHandle phContext)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1424,9 +1424,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_ImportSecurityContextA(SEC_CHAR* pszPacka
static SECURITY_STATUS SEC_ENTRY winpr_QueryCredentialsAttributesW(PCredHandle phCredential,
ULONG ulAttribute, void* pBuffer)
{
- SEC_WCHAR* Name = NULL;
+ SEC_WCHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_WCHAR*)sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
@@ -1450,9 +1450,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_QueryCredentialsAttributesW(PCredHandle p
static SECURITY_STATUS SEC_ENTRY winpr_QueryCredentialsAttributesA(PCredHandle phCredential,
ULONG ulAttribute, void* pBuffer)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
@@ -1477,9 +1477,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_SetCredentialsAttributesW(PCredHandle phC
ULONG ulAttribute, void* pBuffer,
ULONG cbBuffer)
{
- SEC_WCHAR* Name = NULL;
+ SEC_WCHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_WCHAR*)sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
@@ -1504,9 +1504,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_SetCredentialsAttributesA(PCredHandle phC
ULONG ulAttribute, void* pBuffer,
ULONG cbBuffer)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
@@ -1534,9 +1534,9 @@ winpr_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext, PSe
ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext,
PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
@@ -1562,9 +1562,9 @@ winpr_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext, PSe
static SECURITY_STATUS SEC_ENTRY winpr_ApplyControlToken(PCtxtHandle phContext,
PSecBufferDesc pInput)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1588,9 +1588,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_ApplyControlToken(PCtxtHandle phContext,
static SECURITY_STATUS SEC_ENTRY winpr_CompleteAuthToken(PCtxtHandle phContext,
PSecBufferDesc pToken)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1644,9 +1644,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_FreeContextBuffer(void* pvContextBuffer)
static SECURITY_STATUS SEC_ENTRY winpr_ImpersonateSecurityContext(PCtxtHandle phContext)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1672,9 +1672,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_InitializeSecurityContextW(
ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2,
PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
@@ -1702,9 +1702,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_InitializeSecurityContextA(
ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2,
PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phCredential);
if (!Name)
@@ -1731,9 +1731,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_InitializeSecurityContextA(
static SECURITY_STATUS SEC_ENTRY winpr_QueryContextAttributesW(PCtxtHandle phContext,
ULONG ulAttribute, void* pBuffer)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1757,9 +1757,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_QueryContextAttributesW(PCtxtHandle phCon
static SECURITY_STATUS SEC_ENTRY winpr_QueryContextAttributesA(PCtxtHandle phContext,
ULONG ulAttribute, void* pBuffer)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1783,9 +1783,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_QueryContextAttributesA(PCtxtHandle phCon
static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityContextToken(PCtxtHandle phContext,
HANDLE* phToken)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1810,9 +1810,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_SetContextAttributesW(PCtxtHandle phConte
ULONG ulAttribute, void* pBuffer,
ULONG cbBuffer)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1837,9 +1837,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_SetContextAttributesA(PCtxtHandle phConte
ULONG ulAttribute, void* pBuffer,
ULONG cbBuffer)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1862,9 +1862,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_SetContextAttributesA(PCtxtHandle phConte
static SECURITY_STATUS SEC_ENTRY winpr_RevertSecurityContext(PCtxtHandle phContext)
{
- SEC_CHAR* Name = NULL;
+ SEC_CHAR* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableW* table = NULL;
+ const SecurityFunctionTableW* table = nullptr;
Name = (SEC_CHAR*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1892,9 +1892,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_DecryptMessage(PCtxtHandle phContext,
PSecBufferDesc pMessage, ULONG MessageSeqNo,
PULONG pfQOP)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1919,9 +1919,9 @@ static SECURITY_STATUS SEC_ENTRY winpr_DecryptMessage(PCtxtHandle phContext,
static SECURITY_STATUS SEC_ENTRY winpr_EncryptMessage(PCtxtHandle phContext, ULONG fQOP,
PSecBufferDesc pMessage, ULONG MessageSeqNo)
{
- char* Name = NULL;
+ char* Name = nullptr;
SECURITY_STATUS status = 0;
- const SecurityFunctionTableA* table = NULL;
+ const SecurityFunctionTableA* table = nullptr;
Name = (char*)sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
@@ -1999,7 +1999,7 @@ static SecurityFunctionTableA winpr_SecurityFunctionTableA = {
winpr_QueryCredentialsAttributesA, /* QueryCredentialsAttributes */
winpr_AcquireCredentialsHandleA, /* AcquireCredentialsHandle */
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
winpr_InitializeSecurityContextA, /* InitializeSecurityContext */
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
winpr_CompleteAuthToken, /* CompleteAuthToken */
@@ -2012,12 +2012,12 @@ static SecurityFunctionTableA winpr_SecurityFunctionTableA = {
winpr_VerifySignature, /* VerifySignature */
winpr_FreeContextBuffer, /* FreeContextBuffer */
winpr_QuerySecurityPackageInfoA, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
winpr_ExportSecurityContext, /* ExportSecurityContext */
winpr_ImportSecurityContextA, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
winpr_EncryptMessage, /* EncryptMessage */
winpr_DecryptMessage, /* DecryptMessage */
@@ -2031,7 +2031,7 @@ static SecurityFunctionTableW winpr_SecurityFunctionTableW = {
winpr_QueryCredentialsAttributesW, /* QueryCredentialsAttributes */
winpr_AcquireCredentialsHandleW, /* AcquireCredentialsHandle */
winpr_FreeCredentialsHandle, /* FreeCredentialsHandle */
- NULL, /* Reserved2 */
+ nullptr, /* Reserved2 */
winpr_InitializeSecurityContextW, /* InitializeSecurityContext */
winpr_AcceptSecurityContext, /* AcceptSecurityContext */
winpr_CompleteAuthToken, /* CompleteAuthToken */
@@ -2044,12 +2044,12 @@ static SecurityFunctionTableW winpr_SecurityFunctionTableW = {
winpr_VerifySignature, /* VerifySignature */
winpr_FreeContextBuffer, /* FreeContextBuffer */
winpr_QuerySecurityPackageInfoW, /* QuerySecurityPackageInfo */
- NULL, /* Reserved3 */
- NULL, /* Reserved4 */
+ nullptr, /* Reserved3 */
+ nullptr, /* Reserved4 */
winpr_ExportSecurityContext, /* ExportSecurityContext */
winpr_ImportSecurityContextW, /* ImportSecurityContext */
- NULL, /* AddCredentials */
- NULL, /* Reserved8 */
+ nullptr, /* AddCredentials */
+ nullptr, /* Reserved8 */
winpr_QuerySecurityContextToken, /* QuerySecurityContextToken */
winpr_EncryptMessage, /* EncryptMessage */
winpr_DecryptMessage, /* DecryptMessage */
diff --git a/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c b/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c
index 36e91c868..4cd6555bb 100644
--- a/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c
+++ b/winpr/libwinpr/sspi/test/TestAcquireCredentialsHandle.c
@@ -15,7 +15,7 @@ int TestAcquireCredentialsHandle(int argc, char* argv[])
CredHandle credentials = WINPR_C_ARRAY_INIT;
TimeStamp expiration;
SEC_WINNT_AUTH_IDENTITY identity;
- SecurityFunctionTable* table = NULL;
+ SecurityFunctionTable* table = nullptr;
SecPkgCredentials_Names credential_names;
WINPR_UNUSED(argc);
@@ -34,8 +34,9 @@ int TestAcquireCredentialsHandle(int argc, char* argv[])
identity.DomainLength = strlen(test_Domain);
identity.PasswordLength = strlen(test_Password);
identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
- status = table->AcquireCredentialsHandle(NULL, NTLM_SSP_NAME, SECPKG_CRED_OUTBOUND, NULL,
- &identity, NULL, NULL, &credentials, &expiration);
+ status =
+ table->AcquireCredentialsHandle(nullptr, NTLM_SSP_NAME, SECPKG_CRED_OUTBOUND, nullptr,
+ &identity, nullptr, nullptr, &credentials, &expiration);
if (status != SEC_E_OK)
goto fail;
diff --git a/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c b/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c
index 9de23c09e..fe0dcf1d7 100644
--- a/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c
+++ b/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c
@@ -9,8 +9,8 @@ int TestEnumerateSecurityPackages(int argc, char* argv[])
{
ULONG cPackages = 0;
SECURITY_STATUS status = 0;
- SecPkgInfo* pPackageInfo = NULL;
- SecurityFunctionTable* table = NULL;
+ SecPkgInfo* pPackageInfo = nullptr;
+ SecurityFunctionTable* table = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
diff --git a/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c b/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c
index d10108578..dffc46cfa 100644
--- a/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c
+++ b/winpr/libwinpr/sspi/test/TestInitializeSecurityContext.c
@@ -13,16 +13,16 @@ int TestInitializeSecurityContext(int argc, char* argv[])
int rc = -1;
UINT32 cbMaxLen = 0;
UINT32 fContextReq = 0;
- void* output_buffer = NULL;
+ void* output_buffer = nullptr;
CtxtHandle context;
ULONG pfContextAttr = 0;
SECURITY_STATUS status = 0;
CredHandle credentials = WINPR_C_ARRAY_INIT;
TimeStamp expiration;
- PSecPkgInfo pPackageInfo = NULL;
+ PSecPkgInfo pPackageInfo = nullptr;
SEC_WINNT_AUTH_IDENTITY identity = WINPR_C_ARRAY_INIT;
- SecurityFunctionTable* table = NULL;
- PSecBuffer p_SecBuffer = NULL;
+ SecurityFunctionTable* table = nullptr;
+ PSecBuffer p_SecBuffer = nullptr;
SecBuffer output_SecBuffer;
SecBufferDesc output_SecBuffer_desc;
@@ -51,8 +51,9 @@ int TestInitializeSecurityContext(int argc, char* argv[])
identity.DomainLength = strlen(test_Domain);
identity.PasswordLength = strlen(test_Password);
identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
- status = table->AcquireCredentialsHandle(NULL, NTLM_SSP_NAME, SECPKG_CRED_OUTBOUND, NULL,
- &identity, NULL, NULL, &credentials, &expiration);
+ status =
+ table->AcquireCredentialsHandle(nullptr, NTLM_SSP_NAME, SECPKG_CRED_OUTBOUND, nullptr,
+ &identity, nullptr, nullptr, &credentials, &expiration);
if (status != SEC_E_OK)
{
@@ -76,9 +77,9 @@ int TestInitializeSecurityContext(int argc, char* argv[])
output_SecBuffer.cbBuffer = cbMaxLen;
output_SecBuffer.BufferType = SECBUFFER_TOKEN;
output_SecBuffer.pvBuffer = output_buffer;
- status = table->InitializeSecurityContext(&credentials, NULL, NULL, fContextReq, 0, 0, NULL, 0,
- &context, &output_SecBuffer_desc, &pfContextAttr,
- &expiration);
+ status = table->InitializeSecurityContext(&credentials, nullptr, nullptr, fContextReq, 0, 0,
+ nullptr, 0, &context, &output_SecBuffer_desc,
+ &pfContextAttr, &expiration);
if (status != SEC_I_CONTINUE_NEEDED)
{
diff --git a/winpr/libwinpr/sspi/test/TestNTLM.c b/winpr/libwinpr/sspi/test/TestNTLM.c
index f5e43bc35..e1d82163a 100644
--- a/winpr/libwinpr/sspi/test/TestNTLM.c
+++ b/winpr/libwinpr/sspi/test/TestNTLM.c
@@ -163,8 +163,8 @@ static int test_ntlm_client_init(TEST_NTLM_CLIENT* ntlm, const char* user, const
}
ntlm->cbMaxToken = ntlm->pPackageInfo->cbMaxToken;
- status = ntlm->table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME, SECPKG_CRED_OUTBOUND,
- NULL, &ntlm->identity, NULL, NULL,
+ status = ntlm->table->AcquireCredentialsHandle(nullptr, NTLM_PACKAGE_NAME, SECPKG_CRED_OUTBOUND,
+ nullptr, &ntlm->identity, nullptr, nullptr,
&ntlm->credentials, &ntlm->expiration);
if (status != SEC_E_OK)
@@ -195,7 +195,7 @@ static void test_ntlm_client_uninit(TEST_NTLM_CLIENT* ntlm)
if (ntlm->outputBuffer[0].pvBuffer)
{
free(ntlm->outputBuffer[0].pvBuffer);
- ntlm->outputBuffer[0].pvBuffer = NULL;
+ ntlm->outputBuffer[0].pvBuffer = nullptr;
}
free(ntlm->identity.User);
@@ -289,7 +289,7 @@ static int test_ntlm_client_authenticate(TEST_NTLM_CLIENT* ntlm)
if (ntlm->outputBuffer[0].pvBuffer)
{
free(ntlm->outputBuffer[0].pvBuffer);
- ntlm->outputBuffer[0].pvBuffer = NULL;
+ ntlm->outputBuffer[0].pvBuffer = nullptr;
}
ntlm->outputBufferDesc.ulVersion = SECBUFFER_VERSION;
@@ -317,9 +317,9 @@ static int test_ntlm_client_authenticate(TEST_NTLM_CLIENT* ntlm)
}
status = ntlm->table->InitializeSecurityContext(
- &ntlm->credentials, (ntlm->haveContext) ? &ntlm->context : NULL,
- (ntlm->ServicePrincipalName) ? ntlm->ServicePrincipalName : NULL, ntlm->fContextReq, 0,
- SECURITY_NATIVE_DREP, (ntlm->haveInputBuffer) ? &ntlm->inputBufferDesc : NULL, 0,
+ &ntlm->credentials, (ntlm->haveContext) ? &ntlm->context : nullptr,
+ (ntlm->ServicePrincipalName) ? ntlm->ServicePrincipalName : nullptr, ntlm->fContextReq, 0,
+ SECURITY_NATIVE_DREP, (ntlm->haveInputBuffer) ? &ntlm->inputBufferDesc : nullptr, 0,
&ntlm->context, &ntlm->outputBufferDesc, &ntlm->pfContextAttr, &ntlm->expiration);
if (IsSecurityStatusError(status))
@@ -356,7 +356,7 @@ static TEST_NTLM_CLIENT* test_ntlm_client_new(void)
TEST_NTLM_CLIENT* ntlm = (TEST_NTLM_CLIENT*)calloc(1, sizeof(TEST_NTLM_CLIENT));
if (!ntlm)
- return NULL;
+ return nullptr;
return ntlm;
}
@@ -392,9 +392,9 @@ static int test_ntlm_server_init(TEST_NTLM_SERVER* ntlm)
}
ntlm->cbMaxToken = ntlm->pPackageInfo->cbMaxToken;
- status = ntlm->table->AcquireCredentialsHandle(NULL, NTLM_PACKAGE_NAME, SECPKG_CRED_INBOUND,
- NULL, NULL, NULL, NULL, &ntlm->credentials,
- &ntlm->expiration);
+ status = ntlm->table->AcquireCredentialsHandle(nullptr, NTLM_PACKAGE_NAME, SECPKG_CRED_INBOUND,
+ nullptr, nullptr, nullptr, nullptr,
+ &ntlm->credentials, &ntlm->expiration);
if (status != SEC_E_OK)
{
@@ -427,7 +427,7 @@ static void test_ntlm_server_uninit(TEST_NTLM_SERVER* ntlm)
if (ntlm->outputBuffer[0].pvBuffer)
{
free(ntlm->outputBuffer[0].pvBuffer);
- ntlm->outputBuffer[0].pvBuffer = NULL;
+ ntlm->outputBuffer[0].pvBuffer = nullptr;
}
free(ntlm->identity.User);
@@ -468,7 +468,7 @@ static int test_ntlm_server_authenticate(const struct test_input_t* targ, TEST_N
return -1;
status = ntlm->table->AcceptSecurityContext(
- &ntlm->credentials, ntlm->haveContext ? &ntlm->context : NULL, &ntlm->inputBufferDesc,
+ &ntlm->credentials, ntlm->haveContext ? &ntlm->context : nullptr, &ntlm->inputBufferDesc,
ntlm->fContextReq, SECURITY_NATIVE_DREP, &ntlm->context, &ntlm->outputBufferDesc,
&ntlm->pfContextAttr, &ntlm->expiration);
@@ -508,7 +508,7 @@ static TEST_NTLM_SERVER* test_ntlm_server_new(void)
TEST_NTLM_SERVER* ntlm = (TEST_NTLM_SERVER*)calloc(1, sizeof(TEST_NTLM_SERVER));
if (!ntlm)
- return NULL;
+ return nullptr;
return ntlm;
}
@@ -525,7 +525,7 @@ static void test_ntlm_server_free(TEST_NTLM_SERVER* ntlm)
static BOOL test_default(const struct test_input_t* arg)
{
BOOL rc = FALSE;
- PSecBuffer pSecBuffer = NULL;
+ PSecBuffer pSecBuffer = nullptr;
WINPR_ASSERT(arg);
@@ -776,7 +776,7 @@ int TestNTLM(int argc, char* argv[])
FALSE, TRUE },
{ TEST_NTLM_USER, TEST_NTLM_DOMAIN, "", TEST_EMPTY_PWD_NTLM_HASH,
TEST_EMPTY_PWD_NTLM_V2_HASH, TRUE, TRUE },
- { TEST_NTLM_USER, TEST_NTLM_DOMAIN, NULL, TEST_EMPTY_PWD_NTLM_HASH,
+ { TEST_NTLM_USER, TEST_NTLM_DOMAIN, nullptr, TEST_EMPTY_PWD_NTLM_HASH,
TEST_EMPTY_PWD_NTLM_V2_HASH, TRUE, FALSE }
};
diff --git a/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c b/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c
index 5d1ca0079..140118e1e 100644
--- a/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c
+++ b/winpr/libwinpr/sspi/test/TestQuerySecurityPackageInfo.c
@@ -8,8 +8,8 @@ int TestQuerySecurityPackageInfo(int argc, char* argv[])
{
int rc = 0;
SECURITY_STATUS status = 0;
- SecPkgInfo* pPackageInfo = NULL;
- SecurityFunctionTable* table = NULL;
+ SecPkgInfo* pPackageInfo = nullptr;
+ SecurityFunctionTable* table = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
diff --git a/winpr/libwinpr/sspi/test/TestSchannel.c b/winpr/libwinpr/sspi/test/TestSchannel.c
index 3c46846ad..4c7c16a19 100644
--- a/winpr/libwinpr/sspi/test/TestSchannel.c
+++ b/winpr/libwinpr/sspi/test/TestSchannel.c
@@ -15,10 +15,10 @@
static BOOL g_ClientWait = FALSE;
static BOOL g_ServerWait = FALSE;
-static HANDLE g_ClientReadPipe = NULL;
-static HANDLE g_ClientWritePipe = NULL;
-static HANDLE g_ServerReadPipe = NULL;
-static HANDLE g_ServerWritePipe = NULL;
+static HANDLE g_ClientReadPipe = nullptr;
+static HANDLE g_ClientWritePipe = nullptr;
+static HANDLE g_ServerReadPipe = nullptr;
+static HANDLE g_ServerWritePipe = nullptr;
static const BYTE test_localhost_crt[1029] = {
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49,
@@ -240,7 +240,7 @@ static int schannel_send(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle
Buffers[2].pvBuffer = pMessageBuffer + length;
Buffers[2].cbBuffer = StreamSizes.cbTrailer;
Buffers[2].BufferType = SECBUFFER_STREAM_TRAILER;
- Buffers[3].pvBuffer = NULL;
+ Buffers[3].pvBuffer = nullptr;
Buffers[3].cbBuffer = 0;
Buffers[3].BufferType = SECBUFFER_EMPTY;
Message.ulVersion = SECBUFFER_VERSION;
@@ -264,7 +264,7 @@ static int schannel_send(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle
printf("Client > Server (%" PRIu32 ")\n", ioBufferLength);
winpr_HexDump("sspi.test", WLOG_DEBUG, ioBuffer, ioBufferLength);
- if (!WriteFile(hPipe, ioBuffer, ioBufferLength, &NumberOfBytesWritten, NULL))
+ if (!WriteFile(hPipe, ioBuffer, ioBufferLength, &NumberOfBytesWritten, nullptr))
{
printf("schannel_send: failed to write to pipe\n");
return -1;
@@ -290,7 +290,7 @@ static int schannel_recv(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle
if (!ioBuffer)
return -1;
- if (!ReadFile(hPipe, ioBuffer, ioBufferLength, &NumberOfBytesRead, NULL))
+ if (!ReadFile(hPipe, ioBuffer, ioBufferLength, &NumberOfBytesRead, nullptr))
{
printf("schannel_recv: failed to read from pipe\n");
return -1;
@@ -299,19 +299,19 @@ static int schannel_recv(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle
Buffers[0].pvBuffer = ioBuffer;
Buffers[0].cbBuffer = NumberOfBytesRead;
Buffers[0].BufferType = SECBUFFER_DATA;
- Buffers[1].pvBuffer = NULL;
+ Buffers[1].pvBuffer = nullptr;
Buffers[1].cbBuffer = 0;
Buffers[1].BufferType = SECBUFFER_EMPTY;
- Buffers[2].pvBuffer = NULL;
+ Buffers[2].pvBuffer = nullptr;
Buffers[2].cbBuffer = 0;
Buffers[2].BufferType = SECBUFFER_EMPTY;
- Buffers[3].pvBuffer = NULL;
+ Buffers[3].pvBuffer = nullptr;
Buffers[3].cbBuffer = 0;
Buffers[3].BufferType = SECBUFFER_EMPTY;
Message.ulVersion = SECBUFFER_VERSION;
Message.cBuffers = 4;
Message.pBuffers = Buffers;
- status = table->DecryptMessage(phContext, &Message, 0, NULL);
+ status = table->DecryptMessage(phContext, &Message, 0, nullptr);
printf("DecryptMessage status: 0x%08" PRIX32 "\n", status);
printf("DecryptMessage output: cBuffers: %" PRIu32 " [0]: %" PRIu32 " / %" PRIu32
" [1]: %" PRIu32 " / %" PRIu32 " [2]: %" PRIu32 " / %" PRIu32 " [3]: %" PRIu32
@@ -379,43 +379,43 @@ static DWORD WINAPI schannel_test_server_thread(LPVOID arg)
if (!hCertStore)
{
printf("Error opening system store\n");
- // return NULL;
+ // return nullptr;
}
#ifdef CERT_FIND_HAS_PRIVATE_KEY
pCertContext = CertFindCertificateInStore(hCertStore, X509_ASN_ENCODING, 0,
- CERT_FIND_HAS_PRIVATE_KEY, NULL, NULL);
+ CERT_FIND_HAS_PRIVATE_KEY, nullptr, nullptr);
#else
- pCertContext =
- CertFindCertificateInStore(hCertStore, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, NULL);
+ pCertContext = CertFindCertificateInStore(hCertStore, X509_ASN_ENCODING, 0, CERT_FIND_ANY,
+ nullptr, nullptr);
#endif
if (!pCertContext)
{
printf("Error finding certificate in store\n");
- // return NULL;
+ // return nullptr;
}
cchNameString =
- CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0);
+ CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, nullptr, nullptr, 0);
pszNameString = (LPTSTR)malloc(cchNameString * sizeof(TCHAR));
if (!pszNameString)
{
printf("Memory allocation failed\n");
return 0;
}
- cchNameString = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL,
+ cchNameString = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, nullptr,
pszNameString, cchNameString);
_tprintf(_T("Certificate Name: %s\n"), pszNameString);
cred.dwVersion = SCHANNEL_CRED_VERSION;
cred.cCreds = 1;
cred.paCred = &pCertContext;
cred.cSupportedAlgs = 0;
- cred.palgSupportedAlgs = NULL;
+ cred.palgSupportedAlgs = nullptr;
cred.grbitEnabledProtocols = SP_PROT_TLS1_SERVER;
cred.dwFlags = SCH_CRED_NO_SYSTEM_MAPPER;
- status = table->AcquireCredentialsHandle(NULL, SCHANNEL_NAME, SECPKG_CRED_INBOUND, NULL, &cred,
- NULL, NULL, &credentials, NULL);
+ status = table->AcquireCredentialsHandle(nullptr, SCHANNEL_NAME, SECPKG_CRED_INBOUND, nullptr,
+ &cred, nullptr, nullptr, &credentials, nullptr);
if (status != SEC_E_OK)
{
@@ -445,10 +445,10 @@ static DWORD WINAPI schannel_test_server_thread(LPVOID arg)
{
if (g_ServerWait)
{
- if (!ReadFile(g_ServerReadPipe, lpTokenIn, cbMaxToken, &NumberOfBytesRead, NULL))
+ if (!ReadFile(g_ServerReadPipe, lpTokenIn, cbMaxToken, &NumberOfBytesRead, nullptr))
{
printf("Failed to read from server pipe\n");
- return NULL;
+ return nullptr;
}
}
else
@@ -463,7 +463,7 @@ static DWORD WINAPI schannel_test_server_thread(LPVOID arg)
SecBuffer_in[0].pvBuffer = lpTokenIn;
SecBuffer_in[0].cbBuffer = NumberOfBytesRead;
SecBuffer_in[1].BufferType = SECBUFFER_EMPTY;
- SecBuffer_in[1].pvBuffer = NULL;
+ SecBuffer_in[1].pvBuffer = nullptr;
SecBuffer_in[1].cbBuffer = 0;
SecBufferDesc_in.ulVersion = SECBUFFER_VERSION;
SecBufferDesc_in.cBuffers = 2;
@@ -475,14 +475,14 @@ static DWORD WINAPI schannel_test_server_thread(LPVOID arg)
SecBufferDesc_out.cBuffers = 1;
SecBufferDesc_out.pBuffers = SecBuffer_out;
status = table->AcceptSecurityContext(
- &credentials, SecIsValidHandle(&context) ? &context : NULL, &SecBufferDesc_in,
+ &credentials, SecIsValidHandle(&context) ? &context : nullptr, &SecBufferDesc_in,
fContextReq, 0, &context, &SecBufferDesc_out, &fContextAttr, &expiry);
if ((status != SEC_E_OK) && (status != SEC_I_CONTINUE_NEEDED) &&
(status != SEC_E_INCOMPLETE_MESSAGE))
{
printf("AcceptSecurityContext unexpected status: 0x%08" PRIX32 "\n", status);
- return NULL;
+ return nullptr;
}
NumberOfBytesWritten = 0;
@@ -524,10 +524,10 @@ static DWORD WINAPI schannel_test_server_thread(LPVOID arg)
pSecBuffer->cbBuffer);
if (!WriteFile(g_ClientWritePipe, pSecBuffer->pvBuffer, pSecBuffer->cbBuffer,
- &NumberOfBytesWritten, NULL))
+ &NumberOfBytesWritten, nullptr))
{
printf("failed to write to client pipe\n");
- return NULL;
+ return nullptr;
}
}
}
@@ -551,7 +551,7 @@ static DWORD WINAPI schannel_test_server_thread(LPVOID arg)
static int dump_test_certificate_files(void)
{
FILE* fp;
- char* fullpath = NULL;
+ char* fullpath = nullptr;
int ret = -1;
/*
@@ -567,7 +567,7 @@ static int dump_test_certificate_files(void)
if (fwrite((void*)test_localhost_crt, sizeof(test_localhost_crt), 1, fp) != 1)
goto out_fail;
fclose(fp);
- fp = NULL;
+ fp = nullptr;
}
free(fullpath);
@@ -618,19 +618,19 @@ int TestSchannel(int argc, char* argv[])
SecInvalidateHandle(&context);
SecInvalidateHandle(&credentials);
- if (!CreatePipe(&g_ClientReadPipe, &g_ClientWritePipe, NULL, 0))
+ if (!CreatePipe(&g_ClientReadPipe, &g_ClientWritePipe, nullptr, 0))
{
printf("Failed to create client pipe\n");
return -1;
}
- if (!CreatePipe(&g_ServerReadPipe, &g_ServerWritePipe, NULL, 0))
+ if (!CreatePipe(&g_ServerReadPipe, &g_ServerWritePipe, nullptr, 0))
{
printf("Failed to create server pipe\n");
return -1;
}
- if (!(thread = CreateThread(NULL, 0, schannel_test_server_thread, NULL, 0, NULL)))
+ if (!(thread = CreateThread(nullptr, 0, schannel_test_server_thread, nullptr, 0, nullptr)))
{
printf("Failed to create server thread\n");
return -1;
@@ -648,15 +648,15 @@ int TestSchannel(int argc, char* argv[])
cbMaxToken = pPackageInfo->cbMaxToken;
cred.dwVersion = SCHANNEL_CRED_VERSION;
cred.cCreds = 0;
- cred.paCred = NULL;
+ cred.paCred = nullptr;
cred.cSupportedAlgs = 0;
- cred.palgSupportedAlgs = NULL;
+ cred.palgSupportedAlgs = nullptr;
cred.grbitEnabledProtocols = SP_PROT_SSL3TLS1_CLIENTS;
cred.dwFlags = SCH_CRED_NO_DEFAULT_CREDS;
cred.dwFlags |= SCH_CRED_MANUAL_CRED_VALIDATION;
cred.dwFlags |= SCH_CRED_NO_SERVERNAME_CHECK;
- status = table->AcquireCredentialsHandle(NULL, SCHANNEL_NAME, SECPKG_CRED_OUTBOUND, NULL, &cred,
- NULL, NULL, &credentials, NULL);
+ status = table->AcquireCredentialsHandle(nullptr, SCHANNEL_NAME, SECPKG_CRED_OUTBOUND, nullptr,
+ &cred, nullptr, nullptr, &credentials, nullptr);
if (status != SEC_E_OK)
{
@@ -738,7 +738,7 @@ int TestSchannel(int argc, char* argv[])
SecBufferDesc SecBufferDesc_out = WINPR_C_ARRAY_INIT;
if (g_ClientWait)
{
- if (!ReadFile(g_ClientReadPipe, lpTokenIn, cbMaxToken, &NumberOfBytesRead, NULL))
+ if (!ReadFile(g_ClientReadPipe, lpTokenIn, cbMaxToken, &NumberOfBytesRead, nullptr))
{
printf("failed to read from server pipe\n");
return -1;
@@ -754,7 +754,7 @@ int TestSchannel(int argc, char* argv[])
SecBuffer_in[0].BufferType = SECBUFFER_TOKEN;
SecBuffer_in[0].pvBuffer = lpTokenIn;
SecBuffer_in[0].cbBuffer = NumberOfBytesRead;
- SecBuffer_in[1].pvBuffer = NULL;
+ SecBuffer_in[1].pvBuffer = nullptr;
SecBuffer_in[1].cbBuffer = 0;
SecBuffer_in[1].BufferType = SECBUFFER_EMPTY;
SecBufferDesc_in.ulVersion = SECBUFFER_VERSION;
@@ -767,7 +767,7 @@ int TestSchannel(int argc, char* argv[])
SecBufferDesc_out.cBuffers = 1;
SecBufferDesc_out.pBuffers = SecBuffer_out;
status = table->InitializeSecurityContext(
- &credentials, SecIsValidHandle(&context) ? &context : NULL, _T("localhost"),
+ &credentials, SecIsValidHandle(&context) ? &context : nullptr, _T("localhost"),
fContextReq, 0, 0, &SecBufferDesc_in, 0, &context, &SecBufferDesc_out, &fContextAttr,
&expiry);
@@ -807,7 +807,7 @@ int TestSchannel(int argc, char* argv[])
pSecBuffer->cbBuffer);
if (!WriteFile(g_ServerWritePipe, pSecBuffer->pvBuffer, pSecBuffer->cbBuffer,
- &NumberOfBytesWritten, NULL))
+ &NumberOfBytesWritten, nullptr))
{
printf("failed to write to server pipe\n");
return -1;
diff --git a/winpr/libwinpr/sspicli/sspicli.c b/winpr/libwinpr/sspicli/sspicli.c
index aedccd7b9..a2ee09ff2 100644
--- a/winpr/libwinpr/sspicli/sspicli.c
+++ b/winpr/libwinpr/sspicli/sspicli.c
@@ -107,24 +107,24 @@ BOOL LogonUserCloseHandle(HANDLE handle)
static HANDLE_OPS ops = { LogonUserIsHandled,
LogonUserCloseHandle,
LogonUserGetFd,
- NULL, /* CleanupHandle */
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL };
+ nullptr, /* CleanupHandle */
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr };
BOOL LogonUserA(LPCSTR lpszUsername, LPCSTR lpszDomain, WINPR_ATTR_UNUSED LPCSTR lpszPassword,
WINPR_ATTR_UNUSED DWORD dwLogonType, WINPR_ATTR_UNUSED DWORD dwLogonProvider,
@@ -166,7 +166,7 @@ BOOL LogonUserA(LPCSTR lpszUsername, LPCSTR lpszDomain, WINPR_ATTR_UNUSED LPCSTR
{
struct passwd pwd = WINPR_C_ARRAY_INIT;
- struct passwd* pw = NULL;
+ struct passwd* pw = nullptr;
const int rc = getpwnam_r(lpszUsername, &pwd, buf,
WINPR_ASSERTING_INT_CAST(size_t, buflen), &pw);
free(buf);
@@ -230,13 +230,13 @@ BOOL GetUserNameExA(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG
{
int rc = 0;
struct passwd pwd = WINPR_C_ARRAY_INIT;
- struct passwd* result = NULL;
+ struct passwd* result = nullptr;
uid_t uid = getuid();
rc = getpwuid_r(uid, &pwd, lpNameBuffer, *nSize, &result);
if (rc != 0)
return FALSE;
- if (result == NULL)
+ if (result == nullptr)
return FALSE;
}
#elif defined(WINPR_HAVE_GETLOGIN_R)
@@ -278,7 +278,7 @@ BOOL GetUserNameExA(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG
BOOL GetUserNameExW(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)
{
BOOL rc = FALSE;
- char* name = NULL;
+ char* name = nullptr;
WINPR_ASSERT(nSize);
WINPR_ASSERT(lpNameBuffer);
diff --git a/winpr/libwinpr/synch/barrier.c b/winpr/libwinpr/synch/barrier.c
index 1fd839ac6..16c243abe 100644
--- a/winpr/libwinpr/synch/barrier.c
+++ b/winpr/libwinpr/synch/barrier.c
@@ -46,7 +46,7 @@
#ifdef _WIN32
-static HMODULE g_Kernel32 = NULL;
+static HMODULE g_Kernel32 = nullptr;
static BOOL g_NativeBarrier = FALSE;
static INIT_ONCE g_InitOnce = INIT_ONCE_STATIC_INIT;
@@ -56,9 +56,9 @@ typedef BOOL(WINAPI* fnEnterSynchronizationBarrier)(LPSYNCHRONIZATION_BARRIER lp
DWORD dwFlags);
typedef BOOL(WINAPI* fnDeleteSynchronizationBarrier)(LPSYNCHRONIZATION_BARRIER lpBarrier);
-static fnInitializeSynchronizationBarrier pfnInitializeSynchronizationBarrier = NULL;
-static fnEnterSynchronizationBarrier pfnEnterSynchronizationBarrier = NULL;
-static fnDeleteSynchronizationBarrier pfnDeleteSynchronizationBarrier = NULL;
+static fnInitializeSynchronizationBarrier pfnInitializeSynchronizationBarrier = nullptr;
+static fnEnterSynchronizationBarrier pfnEnterSynchronizationBarrier = nullptr;
+static fnDeleteSynchronizationBarrier pfnDeleteSynchronizationBarrier = nullptr;
static BOOL CALLBACK InitOnce_Barrier(PINIT_ONCE once, PVOID param, PVOID* context)
{
@@ -90,11 +90,11 @@ BOOL WINAPI winpr_InitializeSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpB
LONG lTotalThreads, LONG lSpinCount)
{
SYSTEM_INFO sysinfo;
- HANDLE hEvent0 = NULL;
- HANDLE hEvent1 = NULL;
+ HANDLE hEvent0 = nullptr;
+ HANDLE hEvent1 = nullptr;
#ifdef _WIN32
- InitOnceExecuteOnce(&g_InitOnce, InitOnce_Barrier, NULL, NULL);
+ InitOnceExecuteOnce(&g_InitOnce, InitOnce_Barrier, nullptr, nullptr);
if (g_NativeBarrier)
return pfnInitializeSynchronizationBarrier(lpBarrier, lTotalThreads, lSpinCount);
@@ -111,10 +111,10 @@ BOOL WINAPI winpr_InitializeSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpB
if (lSpinCount == -1)
lSpinCount = 2000;
- if (!(hEvent0 = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(hEvent0 = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
return FALSE;
- if (!(hEvent1 = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(hEvent1 = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
(void)CloseHandle(hEvent0);
return FALSE;
@@ -137,8 +137,8 @@ BOOL WINAPI winpr_InitializeSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpB
BOOL WINAPI winpr_EnterSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarrier, DWORD dwFlags)
{
LONG remainingThreads = 0;
- HANDLE hCurrentEvent = NULL;
- HANDLE hDormantEvent = NULL;
+ HANDLE hCurrentEvent = nullptr;
+ HANDLE hDormantEvent = nullptr;
#ifdef _WIN32
if (g_NativeBarrier)
diff --git a/winpr/libwinpr/synch/critical.c b/winpr/libwinpr/synch/critical.c
index 3e3be9e9a..6239399b5 100644
--- a/winpr/libwinpr/synch/critical.c
+++ b/winpr/libwinpr/synch/critical.c
@@ -68,11 +68,11 @@ BOOL InitializeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection, DWORD dwS
WLog_WARN(TAG, "Flags unimplemented");
}
- lpCriticalSection->DebugInfo = NULL;
+ lpCriticalSection->DebugInfo = nullptr;
lpCriticalSection->LockCount = -1;
lpCriticalSection->SpinCount = 0;
lpCriticalSection->RecursionCount = 0;
- lpCriticalSection->OwningThread = NULL;
+ lpCriticalSection->OwningThread = nullptr;
lpCriticalSection->LockSemaphore = (winpr_sem_t*)malloc(sizeof(winpr_sem_t));
if (!lpCriticalSection->LockSemaphore)
@@ -239,7 +239,7 @@ VOID LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
if (--lpCriticalSection->RecursionCount < 1)
{
/* Last recursion, clear owner, unlock and if there are other waiting threads ... */
- lpCriticalSection->OwningThread = NULL;
+ lpCriticalSection->OwningThread = nullptr;
if (InterlockedDecrement(&lpCriticalSection->LockCount) >= 0)
{
@@ -260,9 +260,9 @@ VOID DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
lpCriticalSection->LockCount = -1;
lpCriticalSection->SpinCount = 0;
lpCriticalSection->RecursionCount = 0;
- lpCriticalSection->OwningThread = NULL;
+ lpCriticalSection->OwningThread = nullptr;
- if (lpCriticalSection->LockSemaphore != NULL)
+ if (lpCriticalSection->LockSemaphore != nullptr)
{
#if defined __APPLE__
semaphore_destroy(mach_task_self(), *((winpr_sem_t*)lpCriticalSection->LockSemaphore));
@@ -270,7 +270,7 @@ VOID DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
sem_destroy((winpr_sem_t*)lpCriticalSection->LockSemaphore);
#endif
free(lpCriticalSection->LockSemaphore);
- lpCriticalSection->LockSemaphore = NULL;
+ lpCriticalSection->LockSemaphore = nullptr;
}
}
diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c
index 947c72383..62556bf95 100644
--- a/winpr/libwinpr/synch/event.c
+++ b/winpr/libwinpr/synch/event.c
@@ -50,11 +50,11 @@
#define TAG WINPR_TAG("synch.event")
#if defined(WITH_DEBUG_EVENTS)
-static wArrayList* global_event_list = NULL;
+static wArrayList* global_event_list = nullptr;
static void dump_event(WINPR_EVENT* event, size_t index)
{
- char** msg = NULL;
+ char** msg = nullptr;
size_t used = 0;
WLog_DBG(TAG, "Event handle created still not closed! [%" PRIuz ", %p]", index, event);
@@ -211,7 +211,7 @@ static BOOL EventCloseHandle_(WINPR_EVENT* event)
if (ArrayList_Count(global_event_list) < 1)
{
ArrayList_Free(global_event_list);
- global_event_list = NULL;
+ global_event_list = nullptr;
}
}
@@ -232,39 +232,22 @@ static BOOL EventCloseHandle(HANDLE handle)
return EventCloseHandle_(event);
}
-static HANDLE_OPS ops = { EventIsHandled,
- EventCloseHandle,
- EventGetFd,
- NULL, /* CleanupHandle */
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL };
+static HANDLE_OPS ops = { EventIsHandled, EventCloseHandle, EventGetFd, nullptr, /* CleanupHandle */
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr };
HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState,
LPCWSTR lpName)
{
- HANDLE handle = NULL;
- char* name = NULL;
+ HANDLE handle = nullptr;
+ char* name = nullptr;
if (lpName)
{
- name = ConvertWCharToUtf8Alloc(lpName, NULL);
+ name = ConvertWCharToUtf8Alloc(lpName, nullptr);
if (!name)
- return NULL;
+ return nullptr;
}
handle = CreateEventA(lpEventAttributes, bManualReset, bInitialState, name);
@@ -281,7 +264,7 @@ HANDLE CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset,
WLog_WARN(TAG, "[%s] does not support lpEventAttributes", lpName);
if (!event)
- return NULL;
+ return nullptr;
if (lpName)
event->name = strdup(lpName);
@@ -316,7 +299,7 @@ HANDLE CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset,
return (HANDLE)event;
fail:
EventCloseHandle_(event);
- return NULL;
+ return nullptr;
}
HANDLE CreateEventExW(LPSECURITY_ATTRIBUTES lpEventAttributes, LPCWSTR lpName, DWORD dwFlags,
@@ -367,7 +350,7 @@ HANDLE OpenEventW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName)
WINPR_UNUSED(bInheritHandle);
WINPR_UNUSED(lpName);
WLog_ERR(TAG, "not implemented");
- return NULL;
+ return nullptr;
}
HANDLE OpenEventA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName)
@@ -377,14 +360,14 @@ HANDLE OpenEventA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName)
WINPR_UNUSED(bInheritHandle);
WINPR_UNUSED(lpName);
WLog_ERR(TAG, "not implemented");
- return NULL;
+ return nullptr;
}
BOOL SetEvent(HANDLE hEvent)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_EVENT* event = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_EVENT* event = nullptr;
if (!winpr_Handle_GetInfo(hEvent, &Type, &Object) || Type != HANDLE_TYPE_EVENT)
{
@@ -400,8 +383,8 @@ BOOL SetEvent(HANDLE hEvent)
BOOL ResetEvent(HANDLE hEvent)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_EVENT* event = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_EVENT* event = nullptr;
if (!winpr_Handle_GetInfo(hEvent, &Type, &Object) || Type != HANDLE_TYPE_EVENT)
{
@@ -421,8 +404,8 @@ HANDLE CreateFileDescriptorEventW(WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpEven
int FileDescriptor, ULONG mode)
{
#ifndef _WIN32
- WINPR_EVENT* event = NULL;
- HANDLE handle = NULL;
+ WINPR_EVENT* event = nullptr;
+ HANDLE handle = nullptr;
event = (WINPR_EVENT*)calloc(1, sizeof(WINPR_EVENT));
if (event)
@@ -439,7 +422,7 @@ HANDLE CreateFileDescriptorEventW(WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpEven
return handle;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -460,7 +443,7 @@ HANDLE CreateWaitObjectEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManu
return CreateFileDescriptorEventW(lpEventAttributes, bManualReset, bInitialState,
(int)(ULONG_PTR)pObject, WINPR_FD_READ);
#else
- HANDLE hEvent = NULL;
+ HANDLE hEvent = nullptr;
DuplicateHandle(GetCurrentProcess(), pObject, GetCurrentProcess(), &hEvent, 0, FALSE,
DUPLICATE_SAME_ACCESS);
return hEvent;
@@ -490,8 +473,8 @@ int SetEventFileDescriptor(HANDLE hEvent, int FileDescriptor, ULONG mode)
{
#ifndef _WIN32
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_EVENT* event = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_EVENT* event = nullptr;
if (!winpr_Handle_GetInfo(hEvent, &Type, &Object) || Type != HANDLE_TYPE_EVENT)
{
@@ -528,7 +511,7 @@ void* GetEventWaitObject(HANDLE hEvent)
{
#ifndef _WIN32
int fd = 0;
- void* obj = NULL;
+ void* obj = nullptr;
fd = GetEventFileDescriptor(hEvent);
obj = ((void*)(long)fd);
return obj;
diff --git a/winpr/libwinpr/synch/mutex.c b/winpr/libwinpr/synch/mutex.c
index ee8eac508..25da4e1cd 100644
--- a/winpr/libwinpr/synch/mutex.c
+++ b/winpr/libwinpr/synch/mutex.c
@@ -71,7 +71,7 @@ BOOL MutexCloseHandle(HANDLE handle)
{
size_t used = 0;
void* stack = winpr_backtrace(20);
- char** msg = NULL;
+ char** msg = nullptr;
if (stack)
msg = winpr_backtrace_symbols(stack, &used);
@@ -97,38 +97,21 @@ BOOL MutexCloseHandle(HANDLE handle)
return TRUE;
}
-static HANDLE_OPS ops = { MutexIsHandled,
- MutexCloseHandle,
- MutexGetFd,
- NULL, /* CleanupHandle */
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL };
+static HANDLE_OPS ops = { MutexIsHandled, MutexCloseHandle, MutexGetFd, nullptr, /* CleanupHandle */
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr };
HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCWSTR lpName)
{
- HANDLE handle = NULL;
- char* name = NULL;
+ HANDLE handle = nullptr;
+ char* name = nullptr;
if (lpName)
{
- name = ConvertWCharToUtf8Alloc(lpName, NULL);
+ name = ConvertWCharToUtf8Alloc(lpName, nullptr);
if (!name)
- return NULL;
+ return nullptr;
}
handle = CreateMutexA(lpMutexAttributes, bInitialOwner, name);
@@ -138,8 +121,8 @@ HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner,
HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCSTR lpName)
{
- HANDLE handle = NULL;
- WINPR_MUTEX* mutex = NULL;
+ HANDLE handle = nullptr;
+ WINPR_MUTEX* mutex = nullptr;
mutex = (WINPR_MUTEX*)calloc(1, sizeof(WINPR_MUTEX));
if (lpMutexAttributes)
@@ -159,7 +142,7 @@ HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner,
pthread_mutex_lock(&mutex->mutex);
if (lpName)
- mutex->name = strdup(lpName); /* Non runtime relevant information, skip NULL check */
+ mutex->name = strdup(lpName); /* Non runtime relevant information, skip nullptr check */
}
return handle;
@@ -207,7 +190,7 @@ HANDLE OpenMutexA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName)
WINPR_UNUSED(bInheritHandle);
WINPR_UNUSED(lpName);
WLog_ERR(TAG, "TODO: Implement");
- return NULL;
+ return nullptr;
}
HANDLE OpenMutexW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName)
@@ -217,13 +200,13 @@ HANDLE OpenMutexW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName)
WINPR_UNUSED(bInheritHandle);
WINPR_UNUSED(lpName);
WLog_ERR(TAG, "TODO: Implement");
- return NULL;
+ return nullptr;
}
BOOL ReleaseMutex(HANDLE hMutex)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
+ WINPR_HANDLE* Object = nullptr;
if (!winpr_Handle_GetInfo(hMutex, &Type, &Object))
return FALSE;
diff --git a/winpr/libwinpr/synch/pollset.c b/winpr/libwinpr/synch/pollset.c
index 72222dac5..0384cf018 100644
--- a/winpr/libwinpr/synch/pollset.c
+++ b/winpr/libwinpr/synch/pollset.c
@@ -89,7 +89,7 @@ BOOL pollset_add(WINPR_POLL_SET* set, int fd, ULONG mode)
{
WINPR_ASSERT(set);
#ifdef WINPR_HAVE_POLL_H
- struct pollfd* item = NULL;
+ struct pollfd* item = nullptr;
if (set->fillIndex == set->size)
return FALSE;
@@ -176,12 +176,12 @@ int pollset_poll(WINPR_POLL_SET* set, DWORD dwMilliseconds)
struct timeval staticTimeout;
struct timeval* timeout;
- fd_set* rset = NULL;
- fd_set* wset = NULL;
+ fd_set* rset = nullptr;
+ fd_set* wset = nullptr;
if (dwMilliseconds == INFINITE)
{
- timeout = NULL;
+ timeout = nullptr;
}
else
{
@@ -204,7 +204,7 @@ int pollset_poll(WINPR_POLL_SET* set, DWORD dwMilliseconds)
memcpy(wset, &set->wset_base, sizeof(*wset));
}
- ret = select(set->maxFd + 1, rset, wset, NULL, timeout);
+ ret = select(set->maxFd + 1, rset, wset, nullptr, timeout);
if (ret >= 0)
return ret;
diff --git a/winpr/libwinpr/synch/semaphore.c b/winpr/libwinpr/synch/semaphore.c
index d4e48ad18..df486cc73 100644
--- a/winpr/libwinpr/synch/semaphore.c
+++ b/winpr/libwinpr/synch/semaphore.c
@@ -108,38 +108,38 @@ static HANDLE_OPS ops = { SemaphoreIsHandled,
SemaphoreCloseHandle,
SemaphoreGetFd,
SemaphoreCleanupHandle,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL };
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr };
HANDLE CreateSemaphoreW(WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
LONG lInitialCount, WINPR_ATTR_UNUSED LONG lMaximumCount,
WINPR_ATTR_UNUSED LPCWSTR lpName)
{
- HANDLE handle = NULL;
- WINPR_SEMAPHORE* semaphore = NULL;
+ HANDLE handle = nullptr;
+ WINPR_SEMAPHORE* semaphore = nullptr;
semaphore = (WINPR_SEMAPHORE*)calloc(1, sizeof(WINPR_SEMAPHORE));
if (!semaphore)
- return NULL;
+ return nullptr;
semaphore->pipe_fd[0] = -1;
semaphore->pipe_fd[1] = -1;
- semaphore->sem = (winpr_sem_t*)NULL;
+ semaphore->sem = (winpr_sem_t*)nullptr;
semaphore->common.ops = &ops;
#ifdef WINPR_PIPE_SEMAPHORE
@@ -147,7 +147,7 @@ HANDLE CreateSemaphoreW(WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpSemaphoreAttri
{
WLog_ERR(TAG, "failed to create semaphore");
free(semaphore);
- return NULL;
+ return nullptr;
}
while (lInitialCount > 0)
@@ -157,7 +157,7 @@ HANDLE CreateSemaphoreW(WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpSemaphoreAttri
close(semaphore->pipe_fd[0]);
close(semaphore->pipe_fd[1]);
free(semaphore);
- return NULL;
+ return nullptr;
}
lInitialCount--;
@@ -170,7 +170,7 @@ HANDLE CreateSemaphoreW(WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpSemaphoreAttri
{
WLog_ERR(TAG, "failed to allocate semaphore memory");
free(semaphore);
- return NULL;
+ return nullptr;
}
#if defined __APPLE__
@@ -184,7 +184,7 @@ HANDLE CreateSemaphoreW(WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpSemaphoreAttri
WLog_ERR(TAG, "failed to create semaphore");
free(semaphore->sem);
free(semaphore);
- return NULL;
+ return nullptr;
}
#endif
@@ -196,29 +196,29 @@ HANDLE CreateSemaphoreW(WINPR_ATTR_UNUSED LPSECURITY_ATTRIBUTES lpSemaphoreAttri
HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount,
LONG lMaximumCount, WINPR_ATTR_UNUSED LPCSTR lpName)
{
- return CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, NULL);
+ return CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, nullptr);
}
HANDLE OpenSemaphoreW(WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
WINPR_ATTR_UNUSED BOOL bInheritHandle, WINPR_ATTR_UNUSED LPCWSTR lpName)
{
WLog_ERR(TAG, "not implemented");
- return NULL;
+ return nullptr;
}
HANDLE OpenSemaphoreA(WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
WINPR_ATTR_UNUSED BOOL bInheritHandle, WINPR_ATTR_UNUSED LPCSTR lpName)
{
WLog_ERR(TAG, "not implemented");
- return NULL;
+ return nullptr;
}
BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount,
WINPR_ATTR_UNUSED LPLONG lpPreviousCount)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_SEMAPHORE* semaphore = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_SEMAPHORE* semaphore = nullptr;
if (!winpr_Handle_GetInfo(hSemaphore, &Type, &Object))
return FALSE;
diff --git a/winpr/libwinpr/synch/test/TestSynchAPC.c b/winpr/libwinpr/synch/test/TestSynchAPC.c
index 5f343857f..ccf1a6ca4 100644
--- a/winpr/libwinpr/synch/test/TestSynchAPC.c
+++ b/winpr/libwinpr/synch/test/TestSynchAPC.c
@@ -99,7 +99,7 @@ static DWORD /*WINAPI*/ closeHandleTest(LPVOID lpThreadParameter)
int TestSynchAPC(int argc, char* argv[])
{
- HANDLE thread = NULL;
+ HANDLE thread = nullptr;
UserApcArg userApcArg;
userApcArg.error = FALSE;
@@ -124,7 +124,7 @@ int TestSynchAPC(int argc, char* argv[])
userApcArg.called = FALSE;
/* test that the APC is cleaned up even when not called */
- thread = CreateThread(NULL, 0, uncleanThread, &userApcArg, 0, NULL);
+ thread = CreateThread(nullptr, 0, uncleanThread, &userApcArg, 0, nullptr);
if (!thread)
return 10;
(void)WaitForSingleObject(thread, INFINITE);
@@ -134,7 +134,7 @@ int TestSynchAPC(int argc, char* argv[])
return 11;
/* test a remote APC queuing */
- thread = CreateThread(NULL, 0, cleanThread, &userApcArg, 0, NULL);
+ thread = CreateThread(nullptr, 0, cleanThread, &userApcArg, 0, nullptr);
if (!thread)
return 20;
diff --git a/winpr/libwinpr/synch/test/TestSynchBarrier.c b/winpr/libwinpr/synch/test/TestSynchBarrier.c
index 835ce7058..baa264d80 100644
--- a/winpr/libwinpr/synch/test/TestSynchBarrier.c
+++ b/winpr/libwinpr/synch/test/TestSynchBarrier.c
@@ -9,7 +9,7 @@
#include "../synch.h"
static SYNCHRONIZATION_BARRIER gBarrier;
-static HANDLE gStartEvent = NULL;
+static HANDLE gStartEvent = nullptr;
static LONG gErrorCount = 0;
#define MAX_SLEEP_MS 22
@@ -100,7 +100,7 @@ static BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLo
goto fail;
}
- if (!(gStartEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(gStartEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
printf("%s: CreateEvent failed with error 0x%08x", __func__, GetLastError());
goto fail;
@@ -109,7 +109,7 @@ static BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLo
DWORD i = 0;
for (; i < dwThreads; i++)
{
- threads[i] = CreateThread(NULL, 0, test_synch_barrier_thread, &p, 0, NULL);
+ threads[i] = CreateThread(nullptr, 0, test_synch_barrier_thread, &p, 0, nullptr);
if (!threads[i])
{
printf("%s: CreateThread failed for thread #%" PRIu32 " with error 0x%08x\n", __func__,
diff --git a/winpr/libwinpr/synch/test/TestSynchCritical.c b/winpr/libwinpr/synch/test/TestSynchCritical.c
index b44a70a1e..24be16e59 100644
--- a/winpr/libwinpr/synch/test/TestSynchCritical.c
+++ b/winpr/libwinpr/synch/test/TestSynchCritical.c
@@ -111,9 +111,9 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg)
DWORD dwPreviousSpinCount = 0;
DWORD dwSpinCount = 0;
DWORD dwSpinCountExpected = 0;
- HANDLE hMainThread = NULL;
- HANDLE* hThreads = NULL;
- HANDLE hThread = NULL;
+ HANDLE hMainThread = nullptr;
+ HANDLE* hThreads = nullptr;
+ HANDLE hThread = nullptr;
DWORD dwThreadCount = 0;
DWORD dwThreadExitCode = 0;
BOOL bTest1Running = 0;
@@ -203,7 +203,7 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg)
critical.RecursionCount, i);
goto fail;
}
- if (critical.OwningThread != (i ? hMainThread : NULL))
+ if (critical.OwningThread != (i ? hMainThread : nullptr))
{
printf("CriticalSection failure: Could not verify section ownership (loop index=%d).\n",
i);
@@ -237,8 +237,8 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg)
bTest1Running = TRUE;
for (int i = 0; i < (int)dwThreadCount; i++)
{
- if (!(hThreads[i] =
- CreateThread(NULL, 0, TestSynchCritical_Test1, &bTest1Running, 0, NULL)))
+ if (!(hThreads[i] = CreateThread(nullptr, 0, TestSynchCritical_Test1, &bTest1Running, 0,
+ nullptr)))
{
printf("CriticalSection failure: Failed to create test_1 thread #%d\n", i);
goto fail;
@@ -291,7 +291,7 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg)
goto fail;
}
/* This thread tries to call TryEnterCriticalSection which must fail */
- if (!(hThread = CreateThread(NULL, 0, TestSynchCritical_Test2, NULL, 0, NULL)))
+ if (!(hThread = CreateThread(nullptr, 0, TestSynchCritical_Test2, nullptr, 0, nullptr)))
{
printf("CriticalSection failure: Failed to create test_2 thread\n");
goto fail;
@@ -321,7 +321,7 @@ fail:
int TestSynchCritical(int argc, char* argv[])
{
BOOL bThreadTerminated = FALSE;
- HANDLE hThread = NULL;
+ HANDLE hThread = nullptr;
DWORD dwThreadExitCode = 0;
DWORD dwDeadLockDetectionTimeMs = 0;
@@ -333,7 +333,8 @@ int TestSynchCritical(int argc, char* argv[])
printf("Deadlock will be assumed after %" PRIu32 " ms.\n", dwDeadLockDetectionTimeMs);
- if (!(hThread = CreateThread(NULL, 0, TestSynchCritical_Main, &bThreadTerminated, 0, NULL)))
+ if (!(hThread =
+ CreateThread(nullptr, 0, TestSynchCritical_Main, &bThreadTerminated, 0, nullptr)))
{
printf("CriticalSection failure: Failed to create main thread\n");
return -1;
diff --git a/winpr/libwinpr/synch/test/TestSynchEvent.c b/winpr/libwinpr/synch/test/TestSynchEvent.c
index 1db566692..b08ffe8e6 100644
--- a/winpr/libwinpr/synch/test/TestSynchEvent.c
+++ b/winpr/libwinpr/synch/test/TestSynchEvent.c
@@ -4,22 +4,22 @@
int TestSynchEvent(int argc, char* argv[])
{
- HANDLE event = NULL;
+ HANDLE event = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- if (ResetEvent(NULL))
+ if (ResetEvent(nullptr))
{
- printf("ResetEvent(NULL) unexpectedly succeeded\n");
+ printf("ResetEvent(nullptr) unexpectedly succeeded\n");
return -1;
}
- if (SetEvent(NULL))
+ if (SetEvent(nullptr))
{
- printf("SetEvent(NULL) unexpectedly succeeded\n");
+ printf("SetEvent(nullptr) unexpectedly succeeded\n");
return -1;
}
- event = CreateEvent(NULL, TRUE, TRUE, NULL);
+ event = CreateEvent(nullptr, TRUE, TRUE, nullptr);
if (!event)
{
diff --git a/winpr/libwinpr/synch/test/TestSynchInit.c b/winpr/libwinpr/synch/test/TestSynchInit.c
index dcb64b468..b7a22cab7 100644
--- a/winpr/libwinpr/synch/test/TestSynchInit.c
+++ b/winpr/libwinpr/synch/test/TestSynchInit.c
@@ -10,11 +10,11 @@
static INIT_ONCE initOnceTest = INIT_ONCE_STATIC_INIT;
-static HANDLE hStartEvent = NULL;
-static LONG* pErrors = NULL;
-static LONG* pTestThreadFunctionCalls = NULL;
-static LONG* pTestOnceFunctionCalls = NULL;
-static LONG* pInitOnceExecuteOnceCalls = NULL;
+static HANDLE hStartEvent = nullptr;
+static LONG* pErrors = nullptr;
+static LONG* pTestThreadFunctionCalls = nullptr;
+static LONG* pTestOnceFunctionCalls = nullptr;
+static LONG* pInitOnceExecuteOnceCalls = nullptr;
static UINT32 prand(UINT32 max)
{
@@ -65,7 +65,7 @@ static DWORD WINAPI TestThreadFunction(LPVOID lpParam)
return 0;
}
- ok = InitOnceExecuteOnce(&initOnceTest, TestOnceFunction, NULL, NULL);
+ ok = InitOnceExecuteOnce(&initOnceTest, TestOnceFunction, nullptr, nullptr);
calls = InterlockedIncrement(pInitOnceExecuteOnceCalls);
if (!ok && calls > TEST_NUM_FAILURES)
{
@@ -101,7 +101,7 @@ int TestSynchInit(int argc, char* argv[])
*pTestOnceFunctionCalls = 0;
*pInitOnceExecuteOnceCalls = 0;
- if (!(hStartEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(hStartEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
(void)fprintf(stderr, "error creating start event\n");
InterlockedIncrement(pErrors);
@@ -110,7 +110,7 @@ int TestSynchInit(int argc, char* argv[])
for (DWORD i = 0; i < TEST_NUM_THREADS; i++)
{
- if (!(hThreads[i] = CreateThread(NULL, 0, TestThreadFunction, NULL, 0, NULL)))
+ if (!(hThreads[i] = CreateThread(nullptr, 0, TestThreadFunction, nullptr, 0, nullptr)))
{
(void)fprintf(stderr, "error creating thread #%" PRIu32 "\n", i);
InterlockedIncrement(pErrors);
diff --git a/winpr/libwinpr/synch/test/TestSynchMultipleThreads.c b/winpr/libwinpr/synch/test/TestSynchMultipleThreads.c
index b69964811..999dedcd5 100644
--- a/winpr/libwinpr/synch/test/TestSynchMultipleThreads.c
+++ b/winpr/libwinpr/synch/test/TestSynchMultipleThreads.c
@@ -30,7 +30,7 @@ static int start_threads(size_t count, HANDLE* threads)
{
for (size_t i = 0; i < count; i++)
{
- threads[i] = CreateThread(NULL, 0, test_thread, NULL, CREATE_SUSPENDED, NULL);
+ threads[i] = CreateThread(nullptr, 0, test_thread, nullptr, CREATE_SUSPENDED, nullptr);
if (!threads[i])
{
@@ -58,7 +58,7 @@ static int close_threads(DWORD count, HANDLE* threads)
(void)fprintf(stderr, "%s: CloseHandle [%" PRIu32 "] failure\n", __func__, i);
rc = -1;
}
- threads[i] = NULL;
+ threads[i] = nullptr;
}
return rc;
diff --git a/winpr/libwinpr/synch/test/TestSynchMutex.c b/winpr/libwinpr/synch/test/TestSynchMutex.c
index 9088b1872..24eddbc77 100644
--- a/winpr/libwinpr/synch/test/TestSynchMutex.c
+++ b/winpr/libwinpr/synch/test/TestSynchMutex.c
@@ -5,10 +5,10 @@
static BOOL test_mutex_basic(void)
{
- HANDLE mutex = NULL;
+ HANDLE mutex = nullptr;
DWORD rc = 0;
- if (!(mutex = CreateMutex(NULL, FALSE, NULL)))
+ if (!(mutex = CreateMutex(nullptr, FALSE, nullptr)))
{
printf("%s: CreateMutex failed\n", __func__);
return FALSE;
@@ -45,11 +45,11 @@ static BOOL test_mutex_basic(void)
static BOOL test_mutex_recursive(void)
{
- HANDLE mutex = NULL;
+ HANDLE mutex = nullptr;
DWORD rc = 0;
DWORD cnt = 50;
- if (!(mutex = CreateMutex(NULL, TRUE, NULL)))
+ if (!(mutex = CreateMutex(nullptr, TRUE, nullptr)))
{
printf("%s: CreateMutex failed\n", __func__);
return FALSE;
@@ -98,8 +98,8 @@ static BOOL test_mutex_recursive(void)
return TRUE;
}
-static HANDLE thread1_mutex1 = NULL;
-static HANDLE thread1_mutex2 = NULL;
+static HANDLE thread1_mutex1 = nullptr;
+static HANDLE thread1_mutex2 = nullptr;
static BOOL thread1_failed = TRUE;
static DWORD WINAPI test_mutex_thread1(LPVOID lpParam)
@@ -155,22 +155,22 @@ static DWORD WINAPI test_mutex_thread1(LPVOID lpParam)
static BOOL test_mutex_threading(void)
{
- HANDLE hThread = NULL;
- HANDLE hStartEvent = NULL;
+ HANDLE hThread = nullptr;
+ HANDLE hStartEvent = nullptr;
- if (!(thread1_mutex1 = CreateMutex(NULL, TRUE, NULL)))
+ if (!(thread1_mutex1 = CreateMutex(nullptr, TRUE, nullptr)))
{
printf("%s: CreateMutex thread1_mutex1 failed\n", __func__);
goto fail;
}
- if (!(thread1_mutex2 = CreateMutex(NULL, FALSE, NULL)))
+ if (!(thread1_mutex2 = CreateMutex(nullptr, FALSE, nullptr)))
{
printf("%s: CreateMutex thread1_mutex2 failed\n", __func__);
goto fail;
}
- if (!(hStartEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(hStartEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
(void)fprintf(stderr, "%s: error creating start event\n", __func__);
goto fail;
@@ -178,7 +178,7 @@ static BOOL test_mutex_threading(void)
thread1_failed = TRUE;
- if (!(hThread = CreateThread(NULL, 0, test_mutex_thread1, (LPVOID)hStartEvent, 0, NULL)))
+ if (!(hThread = CreateThread(nullptr, 0, test_mutex_thread1, (LPVOID)hStartEvent, 0, nullptr)))
{
(void)fprintf(stderr, "%s: error creating test_mutex_thread_1\n", __func__);
goto fail;
diff --git a/winpr/libwinpr/synch/test/TestSynchSemaphore.c b/winpr/libwinpr/synch/test/TestSynchSemaphore.c
index aa29dd4a1..bdfc1dc4b 100644
--- a/winpr/libwinpr/synch/test/TestSynchSemaphore.c
+++ b/winpr/libwinpr/synch/test/TestSynchSemaphore.c
@@ -4,10 +4,10 @@
int TestSynchSemaphore(int argc, char* argv[])
{
- HANDLE semaphore = NULL;
+ HANDLE semaphore = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- semaphore = CreateSemaphore(NULL, 0, 1, NULL);
+ semaphore = CreateSemaphore(nullptr, 0, 1, nullptr);
if (!semaphore)
{
diff --git a/winpr/libwinpr/synch/test/TestSynchThread.c b/winpr/libwinpr/synch/test/TestSynchThread.c
index 58f7cb080..dbcebc86b 100644
--- a/winpr/libwinpr/synch/test/TestSynchThread.c
+++ b/winpr/libwinpr/synch/test/TestSynchThread.c
@@ -14,12 +14,12 @@ static DWORD WINAPI test_thread(LPVOID arg)
int TestSynchThread(int argc, char* argv[])
{
DWORD rc = 0;
- HANDLE thread = NULL;
+ HANDLE thread = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- thread = CreateThread(NULL, 0, test_thread, NULL, 0, NULL);
+ thread = CreateThread(nullptr, 0, test_thread, nullptr, 0, nullptr);
if (!thread)
{
@@ -71,7 +71,7 @@ int TestSynchThread(int argc, char* argv[])
return -1;
}
- thread = CreateThread(NULL, 0, test_thread, NULL, 0, NULL);
+ thread = CreateThread(nullptr, 0, test_thread, nullptr, 0, nullptr);
if (!thread)
{
@@ -113,7 +113,7 @@ int TestSynchThread(int argc, char* argv[])
}
/* Thread detach test */
- thread = CreateThread(NULL, 0, test_thread, NULL, 0, NULL);
+ thread = CreateThread(nullptr, 0, test_thread, nullptr, 0, nullptr);
if (!thread)
{
diff --git a/winpr/libwinpr/synch/test/TestSynchTimerQueue.c b/winpr/libwinpr/synch/test/TestSynchTimerQueue.c
index 2b8a920c3..13bc738e3 100644
--- a/winpr/libwinpr/synch/test/TestSynchTimerQueue.c
+++ b/winpr/libwinpr/synch/test/TestSynchTimerQueue.c
@@ -71,7 +71,7 @@ int TestSynchTimerQueue(int argc, char* argv[])
apcData[index].FireCount = 0;
apcData[index].MaxFireCount = FIRE_COUNT;
- if (!(apcData[index].CompletionEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ if (!(apcData[index].CompletionEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
{
printf("Failed to create apcData[%" PRIu32 "] event (%" PRIu32 ")\n", index,
GetLastError());
diff --git a/winpr/libwinpr/synch/test/TestSynchWaitableTimer.c b/winpr/libwinpr/synch/test/TestSynchWaitableTimer.c
index 7c3cef0aa..06e6f4597 100644
--- a/winpr/libwinpr/synch/test/TestSynchWaitableTimer.c
+++ b/winpr/libwinpr/synch/test/TestSynchWaitableTimer.c
@@ -5,13 +5,13 @@
int TestSynchWaitableTimer(int argc, char* argv[])
{
DWORD status = 0;
- HANDLE timer = NULL;
+ HANDLE timer = nullptr;
LONG period = 0;
LARGE_INTEGER due = WINPR_C_ARRAY_INIT;
int result = -1;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- timer = CreateWaitableTimer(NULL, FALSE, NULL);
+ timer = CreateWaitableTimer(nullptr, FALSE, nullptr);
if (!timer)
{
@@ -21,7 +21,7 @@ int TestSynchWaitableTimer(int argc, char* argv[])
due.QuadPart = -1500000LL; /* 0.15 seconds */
- if (!SetWaitableTimer(timer, &due, 0, NULL, NULL, 0))
+ if (!SetWaitableTimer(timer, &due, 0, nullptr, nullptr, 0))
{
printf("SetWaitableTimer failure\n");
goto out;
@@ -49,7 +49,7 @@ int TestSynchWaitableTimer(int argc, char* argv[])
due.QuadPart = 0;
period = 120; /* 0.12 seconds */
- if (!SetWaitableTimer(timer, &due, period, NULL, NULL, 0))
+ if (!SetWaitableTimer(timer, &due, period, nullptr, nullptr, 0))
{
printf("SetWaitableTimer failure\n");
goto out;
@@ -63,7 +63,7 @@ int TestSynchWaitableTimer(int argc, char* argv[])
printf("Timer Signaled\n");
- if (!SetWaitableTimer(timer, &due, period, NULL, NULL, 0))
+ if (!SetWaitableTimer(timer, &due, period, nullptr, nullptr, 0))
{
printf("SetWaitableTimer failure\n");
goto out;
diff --git a/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c b/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c
index 8c469d498..53c365266 100644
--- a/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c
+++ b/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c
@@ -4,7 +4,7 @@
#include
static int g_Count = 0;
-static HANDLE g_Event = NULL;
+static HANDLE g_Event = nullptr;
struct apc_data
{
@@ -14,7 +14,7 @@ typedef struct apc_data APC_DATA;
static VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
{
- APC_DATA* apcData = NULL;
+ APC_DATA* apcData = nullptr;
UINT32 CurrentTime = GetTickCount();
WINPR_UNUSED(dwTimerLowValue);
WINPR_UNUSED(dwTimerHighValue);
@@ -36,13 +36,13 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
{
int status = -1;
DWORD rc = 0;
- HANDLE hTimer = NULL;
+ HANDLE hTimer = nullptr;
BOOL bSuccess = 0;
LARGE_INTEGER due = WINPR_C_ARRAY_INIT;
APC_DATA apcData = WINPR_C_ARRAY_INIT;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
- g_Event = CreateEvent(NULL, TRUE, FALSE, NULL);
+ g_Event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!g_Event)
{
@@ -50,7 +50,7 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
goto cleanup;
}
- hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
+ hTimer = CreateWaitableTimer(nullptr, FALSE, nullptr);
if (!hTimer)
goto cleanup;
diff --git a/winpr/libwinpr/synch/timer.c b/winpr/libwinpr/synch/timer.c
index 95721084b..b8786ef35 100644
--- a/winpr/libwinpr/synch/timer.c
+++ b/winpr/libwinpr/synch/timer.c
@@ -133,7 +133,7 @@ static void TimerPostDelete_APC(LPVOID arg)
BOOL TimerCloseHandle(HANDLE handle)
{
- WINPR_TIMER* timer = NULL;
+ WINPR_TIMER* timer = nullptr;
timer = (WINPR_TIMER*)handle;
if (!TimerIsHandled(handle))
@@ -160,8 +160,8 @@ BOOL TimerCloseHandle(HANDLE handle)
free(timer->name);
if (timer->apcItem.linked)
{
- TimerDeleter* deleter = NULL;
- WINPR_APC_ITEM* apcItem = NULL;
+ TimerDeleter* deleter = nullptr;
+ WINPR_APC_ITEM* apcItem = nullptr;
switch (apc_remove(&timer->apcItem))
{
@@ -224,7 +224,7 @@ static BOOL InstallTimerSignalHandler(PINIT_ONCE InitOnce, PVOID Parameter, PVOI
sigaddset(&action.sa_mask, SIGALRM);
action.sa_flags = SA_RESTART | SA_SIGINFO;
action.sa_sigaction = WaitableTimerSignalHandler;
- sigaction(SIGALRM, &action, NULL);
+ sigaction(SIGALRM, &action, nullptr);
return TRUE;
}
#endif
@@ -260,7 +260,7 @@ static int InitializeWaitableTimer(WINPR_TIMER* timer)
return -1;
#elif defined(TIMER_IMPL_POSIX)
struct sigevent sigev = WINPR_C_ARRAY_INIT;
- InitOnceExecuteOnce(&TimerSignalHandler_InitOnce, InstallTimerSignalHandler, NULL, NULL);
+ InitOnceExecuteOnce(&TimerSignalHandler_InitOnce, InstallTimerSignalHandler, nullptr, nullptr);
sigev.sigev_notify = SIGEV_SIGNAL;
sigev.sigev_signo = SIGALRM;
sigev.sigev_value.sival_ptr = (void*)timer;
@@ -292,27 +292,12 @@ static BOOL timer_drain_fd(int fd)
return ret >= 0;
}
-static HANDLE_OPS ops = { TimerIsHandled,
- TimerCloseHandle,
- TimerGetFd,
- TimerCleanupHandle,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL };
+static HANDLE_OPS ops = { TimerIsHandled, TimerCloseHandle, TimerGetFd, TimerCleanupHandle,
+ nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr,
+ nullptr };
/**
* Waitable Timer
@@ -321,8 +306,8 @@ static HANDLE_OPS ops = { TimerIsHandled,
HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset,
LPCSTR lpTimerName)
{
- HANDLE handle = NULL;
- WINPR_TIMER* timer = NULL;
+ HANDLE handle = nullptr;
+ WINPR_TIMER* timer = nullptr;
if (lpTimerAttributes)
WLog_WARN(TAG, "[%s] does not support lpTimerAttributes", lpTimerName);
@@ -336,8 +321,8 @@ HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManua
timer->fd = -1;
timer->lPeriod = 0;
timer->bManualReset = bManualReset;
- timer->pfnCompletionRoutine = NULL;
- timer->lpArgToCompletionRoutine = NULL;
+ timer->pfnCompletionRoutine = nullptr;
+ timer->lpArgToCompletionRoutine = nullptr;
timer->bInit = FALSE;
if (lpTimerName)
@@ -371,21 +356,21 @@ HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManua
#if defined(TIMER_IMPL_DISPATCH) || defined(TIMER_IMPL_POSIX)
fail:
TimerCloseHandle(handle);
- return NULL;
+ return nullptr;
#endif
}
HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset,
LPCWSTR lpTimerName)
{
- HANDLE handle = NULL;
- LPSTR name = NULL;
+ HANDLE handle = nullptr;
+ LPSTR name = nullptr;
if (lpTimerName)
{
- name = ConvertWCharToUtf8Alloc(lpTimerName, NULL);
+ name = ConvertWCharToUtf8Alloc(lpTimerName, nullptr);
if (!name)
- return NULL;
+ return nullptr;
}
handle = CreateWaitableTimerA(lpTimerAttributes, bManualReset, name);
@@ -408,14 +393,14 @@ HANDLE CreateWaitableTimerExA(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCSTR lp
HANDLE CreateWaitableTimerExW(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName,
DWORD dwFlags, DWORD dwDesiredAccess)
{
- HANDLE handle = NULL;
- LPSTR name = NULL;
+ HANDLE handle = nullptr;
+ LPSTR name = nullptr;
if (lpTimerName)
{
- name = ConvertWCharToUtf8Alloc(lpTimerName, NULL);
+ name = ConvertWCharToUtf8Alloc(lpTimerName, nullptr);
if (!name)
- return NULL;
+ return nullptr;
}
handle = CreateWaitableTimerExA(lpTimerAttributes, name, dwFlags, dwDesiredAccess);
@@ -458,8 +443,8 @@ BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPerio
BOOL fResume)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_TIMER* timer = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_TIMER* timer = nullptr;
LONGLONG seconds = 0;
LONGLONG nanoseconds = 0;
int status = 0;
@@ -531,14 +516,14 @@ BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPerio
}
#ifdef TIMER_IMPL_TIMERFD
- status = timerfd_settime(timer->fd, 0, &(timer->timeout), NULL);
+ status = timerfd_settime(timer->fd, 0, &(timer->timeout), nullptr);
if (status)
{
WLog_ERR(TAG, "timerfd_settime failure: %d", status);
return FALSE;
}
#else
- status = timer_settime(timer->tid, 0, &(timer->timeout), NULL);
+ status = timer_settime(timer->tid, 0, &(timer->timeout), nullptr);
if (status != 0)
{
WLog_ERR(TAG, "timer_settime failure");
@@ -632,7 +617,7 @@ HANDLE OpenWaitableTimerA(WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
{
/* TODO: Implement */
WLog_ERR(TAG, "not implemented");
- return NULL;
+ return nullptr;
}
HANDLE OpenWaitableTimerW(WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
@@ -641,13 +626,13 @@ HANDLE OpenWaitableTimerW(WINPR_ATTR_UNUSED DWORD dwDesiredAccess,
{
/* TODO: Implement */
WLog_ERR(TAG, "not implemented");
- return NULL;
+ return nullptr;
}
BOOL CancelWaitableTimer(HANDLE hTimer)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
+ WINPR_HANDLE* Object = nullptr;
if (!winpr_Handle_GetInfo(hTimer, &Type, &Object))
return FALSE;
@@ -674,7 +659,7 @@ BOOL CancelWaitableTimer(HANDLE hTimer)
int GetTimerFileDescriptor(HANDLE hTimer)
{
- WINPR_HANDLE* hdl = NULL;
+ WINPR_HANDLE* hdl = nullptr;
ULONG type = 0;
if (!winpr_Handle_GetInfo(hTimer, &type, &hdl) || type != HANDLE_TYPE_TIMER)
@@ -734,7 +719,7 @@ static void timespec_copy(struct timespec* dst, struct timespec* src)
static void InsertTimerQueueTimer(WINPR_TIMER_QUEUE_TIMER** pHead, WINPR_TIMER_QUEUE_TIMER* timer)
{
- WINPR_TIMER_QUEUE_TIMER* node = NULL;
+ WINPR_TIMER_QUEUE_TIMER* node = nullptr;
WINPR_ASSERT(pHead);
WINPR_ASSERT(timer);
@@ -742,7 +727,7 @@ static void InsertTimerQueueTimer(WINPR_TIMER_QUEUE_TIMER** pHead, WINPR_TIMER_Q
if (!(*pHead))
{
*pHead = timer;
- timer->next = NULL;
+ timer->next = nullptr;
return;
}
@@ -767,27 +752,27 @@ static void InsertTimerQueueTimer(WINPR_TIMER_QUEUE_TIMER** pHead, WINPR_TIMER_Q
else
{
node->next = timer;
- timer->next = NULL;
+ timer->next = nullptr;
}
}
static void RemoveTimerQueueTimer(WINPR_TIMER_QUEUE_TIMER** pHead, WINPR_TIMER_QUEUE_TIMER* timer)
{
BOOL found = FALSE;
- WINPR_TIMER_QUEUE_TIMER* node = NULL;
- WINPR_TIMER_QUEUE_TIMER* prevNode = NULL;
+ WINPR_TIMER_QUEUE_TIMER* node = nullptr;
+ WINPR_TIMER_QUEUE_TIMER* prevNode = nullptr;
WINPR_ASSERT(pHead);
WINPR_ASSERT(timer);
if (timer == *pHead)
{
*pHead = timer->next;
- timer->next = NULL;
+ timer->next = nullptr;
return;
}
node = *pHead;
- prevNode = NULL;
+ prevNode = nullptr;
while (node)
{
@@ -808,14 +793,14 @@ static void RemoveTimerQueueTimer(WINPR_TIMER_QUEUE_TIMER** pHead, WINPR_TIMER_Q
prevNode->next = timer->next;
}
- timer->next = NULL;
+ timer->next = nullptr;
}
}
static int FireExpiredTimerQueueTimers(WINPR_TIMER_QUEUE* timerQueue)
{
struct timespec CurrentTime;
- WINPR_TIMER_QUEUE_TIMER* node = NULL;
+ WINPR_TIMER_QUEUE_TIMER* node = nullptr;
WINPR_ASSERT(timerQueue);
@@ -832,7 +817,7 @@ static int FireExpiredTimerQueueTimers(WINPR_TIMER_QUEUE* timerQueue)
node->Callback(node->Parameter, TRUE);
node->FireCount++;
timerQueue->activeHead = node->next;
- node->next = NULL;
+ node->next = nullptr;
if (node->Period)
{
@@ -891,15 +876,15 @@ static void* TimerQueueThread(void* arg)
break;
}
- return NULL;
+ return nullptr;
}
static int StartTimerQueueThread(WINPR_TIMER_QUEUE* timerQueue)
{
WINPR_ASSERT(timerQueue);
- pthread_cond_init(&(timerQueue->cond), NULL);
- pthread_mutex_init(&(timerQueue->cond_mutex), NULL);
- pthread_mutex_init(&(timerQueue->mutex), NULL);
+ pthread_cond_init(&(timerQueue->cond), nullptr);
+ pthread_mutex_init(&(timerQueue->cond_mutex), nullptr);
+ pthread_mutex_init(&(timerQueue->mutex), nullptr);
pthread_attr_init(&(timerQueue->attr));
timerQueue->param.sched_priority = sched_get_priority_max(SCHED_FIFO);
pthread_attr_setschedparam(&(timerQueue->attr), &(timerQueue->param));
@@ -910,16 +895,16 @@ static int StartTimerQueueThread(WINPR_TIMER_QUEUE* timerQueue)
HANDLE CreateTimerQueue(void)
{
- HANDLE handle = NULL;
- WINPR_TIMER_QUEUE* timerQueue = NULL;
+ HANDLE handle = nullptr;
+ WINPR_TIMER_QUEUE* timerQueue = nullptr;
timerQueue = (WINPR_TIMER_QUEUE*)calloc(1, sizeof(WINPR_TIMER_QUEUE));
if (timerQueue)
{
WINPR_HANDLE_SET_TYPE_AND_MODE(timerQueue, HANDLE_TYPE_TIMER_QUEUE, WINPR_FD_READ);
handle = (HANDLE)timerQueue;
- timerQueue->activeHead = NULL;
- timerQueue->inactiveHead = NULL;
+ timerQueue->activeHead = nullptr;
+ timerQueue->inactiveHead = nullptr;
timerQueue->bCancelled = FALSE;
StartTimerQueueThread(timerQueue);
}
@@ -929,10 +914,10 @@ HANDLE CreateTimerQueue(void)
BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
{
- void* rvalue = NULL;
- WINPR_TIMER_QUEUE* timerQueue = NULL;
- WINPR_TIMER_QUEUE_TIMER* node = NULL;
- WINPR_TIMER_QUEUE_TIMER* nextNode = NULL;
+ void* rvalue = nullptr;
+ WINPR_TIMER_QUEUE* timerQueue = nullptr;
+ WINPR_TIMER_QUEUE_TIMER* node = nullptr;
+ WINPR_TIMER_QUEUE_TIMER* nextNode = nullptr;
if (!TimerQueue)
return FALSE;
@@ -948,7 +933,7 @@ BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
* Quote from MSDN regarding CompletionEvent:
* If this parameter is INVALID_HANDLE_VALUE, the function waits for
* all callback functions to complete before returning.
- * If this parameter is NULL, the function marks the timer for
+ * If this parameter is nullptr, the function marks the timer for
* deletion and returns immediately.
*
* Note: The current WinPR implementation implicitly waits for any
@@ -964,7 +949,7 @@ BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
node = node->next;
}
- timerQueue->activeHead = NULL;
+ timerQueue->activeHead = nullptr;
/* Once all timers are inactive, free them */
node = timerQueue->inactiveHead;
@@ -975,7 +960,7 @@ BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
node = nextNode;
}
- timerQueue->inactiveHead = NULL;
+ timerQueue->inactiveHead = nullptr;
}
/* Delete timer queue */
pthread_cond_destroy(&(timerQueue->cond));
@@ -992,7 +977,7 @@ BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
BOOL DeleteTimerQueue(HANDLE TimerQueue)
{
- return DeleteTimerQueueEx(TimerQueue, NULL);
+ return DeleteTimerQueueEx(TimerQueue, nullptr);
}
BOOL CreateTimerQueueTimer(HANDLE* phNewTimer, HANDLE TimerQueue, WAITORTIMERCALLBACK Callback,
@@ -1022,7 +1007,7 @@ BOOL CreateTimerQueueTimer(HANDLE* phNewTimer, HANDLE TimerQueue, WAITORTIMERCAL
timer->Parameter = Parameter;
timer->timerQueue = (WINPR_TIMER_QUEUE*)TimerQueue;
timer->FireCount = 0;
- timer->next = NULL;
+ timer->next = nullptr;
pthread_mutex_lock(&(timerQueue->cond_mutex));
InsertTimerQueueTimer(&(timerQueue->activeHead), timer);
pthread_cond_signal(&(timerQueue->cond));
@@ -1033,8 +1018,8 @@ BOOL CreateTimerQueueTimer(HANDLE* phNewTimer, HANDLE TimerQueue, WAITORTIMERCAL
BOOL ChangeTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, ULONG DueTime, ULONG Period)
{
struct timespec CurrentTime;
- WINPR_TIMER_QUEUE* timerQueue = NULL;
- WINPR_TIMER_QUEUE_TIMER* timer = NULL;
+ WINPR_TIMER_QUEUE* timerQueue = nullptr;
+ WINPR_TIMER_QUEUE_TIMER* timer = nullptr;
if (!TimerQueue || !Timer)
return FALSE;
@@ -1047,7 +1032,7 @@ BOOL ChangeTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, ULONG DueTime, ULONG
RemoveTimerQueueTimer(&(timerQueue->inactiveHead), timer);
timer->DueTime = DueTime;
timer->Period = Period;
- timer->next = NULL;
+ timer->next = nullptr;
timespec_copy(&(timer->StartTime), &CurrentTime);
timespec_add_ms(&(timer->StartTime), DueTime);
timespec_copy(&(timer->ExpirationTime), &(timer->StartTime));
@@ -1059,8 +1044,8 @@ BOOL ChangeTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, ULONG DueTime, ULONG
BOOL DeleteTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, HANDLE CompletionEvent)
{
- WINPR_TIMER_QUEUE* timerQueue = NULL;
- WINPR_TIMER_QUEUE_TIMER* timer = NULL;
+ WINPR_TIMER_QUEUE* timerQueue = nullptr;
+ WINPR_TIMER_QUEUE_TIMER* timer = nullptr;
if (!TimerQueue || !Timer)
return FALSE;
@@ -1072,7 +1057,7 @@ BOOL DeleteTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, HANDLE CompletionEve
* Quote from MSDN regarding CompletionEvent:
* If this parameter is INVALID_HANDLE_VALUE, the function waits for
* all callback functions to complete before returning.
- * If this parameter is NULL, the function marks the timer for
+ * If this parameter is nullptr, the function marks the timer for
* deletion and returns immediately.
*
* Note: The current WinPR implementation implicitly waits for any
diff --git a/winpr/libwinpr/synch/wait.c b/winpr/libwinpr/synch/wait.c
index 452b07891..1de29c2b9 100644
--- a/winpr/libwinpr/synch/wait.c
+++ b/winpr/libwinpr/synch/wait.c
@@ -117,7 +117,7 @@ STATIC_NEEDED int pthread_mutex_timedlock(pthread_mutex_t* mutex,
return ETIMEDOUT;
}
- nanosleep(&sleepytime, NULL);
+ nanosleep(&sleepytime, nullptr);
}
return retcode;
@@ -135,7 +135,7 @@ static void ts_add_ms(struct timespec* ts, DWORD dwMilliseconds)
DWORD WaitForSingleObjectEx(HANDLE hHandle, DWORD dwMilliseconds, BOOL bAlertable)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
+ WINPR_HANDLE* Object = nullptr;
WINPR_POLL_SET pollset = WINPR_C_ARRAY_INIT;
if (!winpr_Handle_GetInfo(hHandle, &Type, &Object))
@@ -210,7 +210,7 @@ DWORD WaitForSingleObjectEx(HANDLE hHandle, DWORD dwMilliseconds, BOOL bAlertabl
else
{
int status = -1;
- WINPR_THREAD* thread = NULL;
+ WINPR_THREAD* thread = nullptr;
BOOL isSet = FALSE;
size_t extraFds = 0;
DWORD ret = 0;
@@ -308,8 +308,8 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait
int fd = -1;
int status = -1;
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_THREAD* thread = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_THREAD* thread = nullptr;
WINPR_POLL_SET pollset = WINPR_C_ARRAY_INIT;
DWORD ret = WAIT_FAILED;
size_t extraFds = 0;
diff --git a/winpr/libwinpr/sysinfo/cpufeatures/cpu-features.c b/winpr/libwinpr/sysinfo/cpufeatures/cpu-features.c
index 12faa46c7..0cce93bb5 100644
--- a/winpr/libwinpr/sysinfo/cpufeatures/cpu-features.c
+++ b/winpr/libwinpr/sysinfo/cpufeatures/cpu-features.c
@@ -228,13 +228,13 @@ static int read_file(const char* pathname, char* buffer, size_t buffsize)
* the content of /proc/cpuinfo and return it as a heap-allocated
* string that must be freed by the caller.
*
- * Return NULL if not found
+ * Return nullptr if not found
*/
static char* extract_cpuinfo_field(const char* buffer, int buflen, const char* field)
{
int fieldlen = strlen(field);
const char* bufend = buffer + buflen;
- char* result = NULL;
+ char* result = nullptr;
int len;
const char *p, *q;
/* Look for first field occurrence, and ensures it starts the line. */
@@ -244,7 +244,7 @@ static char* extract_cpuinfo_field(const char* buffer, int buflen, const char* f
{
p = memmem(p, bufend - p, field, fieldlen);
- if (p == NULL)
+ if (p == nullptr)
goto EXIT;
if (p == buffer || p[-1] == '\n')
@@ -257,21 +257,21 @@ static char* extract_cpuinfo_field(const char* buffer, int buflen, const char* f
p += fieldlen;
p = memchr(p, ':', bufend - p);
- if (p == NULL || p[1] != ' ')
+ if (p == nullptr || p[1] != ' ')
goto EXIT;
/* Find the end of the line */
p += 2;
q = memchr(p, '\n', bufend - p);
- if (q == NULL)
+ if (q == nullptr)
q = bufend;
/* Copy the line into a heap-allocated buffer */
len = q - p;
result = malloc(len + 1);
- if (result == NULL)
+ if (result == nullptr)
goto EXIT;
memcpy(result, p, len);
@@ -288,7 +288,7 @@ static int has_list_item(const char* list, const char* item)
const char* p = list;
int itemlen = strlen(item);
- if (list == NULL)
+ if (list == nullptr)
return 0;
while (*p)
@@ -322,7 +322,7 @@ static int has_list_item(const char* list, const char* item)
* NOTE: Does not skip over leading spaces, or deal with sign characters.
* NOTE: Ignores overflows.
*
- * The function returns NULL in case of error (bad format), or the new
+ * The function returns nullptr in case of error (bad format), or the new
* position after the decimal number in case of success (which will always
* be <= 'limit').
*/
@@ -356,7 +356,7 @@ static const char* parse_number(const char* input, const char* limit, int base,
}
if (p == input)
- return NULL;
+ return nullptr;
*result = val;
return p;
@@ -434,7 +434,7 @@ static void cpulist_parse(CpuList* list, const char* line, int line_len)
/* Find the end of current item, and put it into 'q' */
q = memchr(p, ',', end - p);
- if (q == NULL)
+ if (q == nullptr)
{
q = end;
}
@@ -442,7 +442,7 @@ static void cpulist_parse(CpuList* list, const char* line, int line_len)
/* Get first value */
p = parse_decimal(p, q, &start_value);
- if (p == NULL)
+ if (p == nullptr)
goto BAD_FORMAT;
end_value = start_value;
@@ -454,7 +454,7 @@ static void cpulist_parse(CpuList* list, const char* line, int line_len)
{
p = parse_decimal(p + 1, q, &end_value);
- if (p == NULL)
+ if (p == nullptr)
goto BAD_FORMAT;
}
@@ -648,7 +648,7 @@ static uint32_t get_elf_hwcap_from_proc_cpuinfo(const char* cpuinfo, int cpuinfo
if (cpuArch)
{
- architecture = strtol(cpuArch, NULL, 10);
+ architecture = strtol(cpuArch, nullptr, 10);
free(cpuArch);
if (architecture >= 8L)
@@ -664,7 +664,7 @@ static uint32_t get_elf_hwcap_from_proc_cpuinfo(const char* cpuinfo, int cpuinfo
char* cpuFeatures = extract_cpuinfo_field(cpuinfo, cpuinfo_len, "Features");
- if (cpuFeatures != NULL)
+ if (cpuFeatures != nullptr)
{
D("Found cpuFeatures = '%s'\n", cpuFeatures);
@@ -743,7 +743,7 @@ static void android_cpuInitFamily(void)
static void android_cpuInit(void)
{
- char* cpuinfo = NULL;
+ char* cpuinfo = nullptr;
int cpuinfo_len;
android_cpuInitFamily();
g_cpuFeatures = 0;
@@ -759,7 +759,7 @@ static void android_cpuInit(void)
cpuinfo = malloc(cpuinfo_len);
- if (cpuinfo == NULL)
+ if (cpuinfo == nullptr)
{
D("cpuinfo buffer could not be allocated");
return;
@@ -795,7 +795,7 @@ static void android_cpuInit(void)
*/
char* cpuArch = extract_cpuinfo_field(cpuinfo, cpuinfo_len, "CPU architecture");
- if (cpuArch != NULL)
+ if (cpuArch != nullptr)
{
char* end;
long archNumber;
@@ -824,7 +824,7 @@ static void android_cpuInit(void)
{
char* cpuProc = extract_cpuinfo_field(cpuinfo, cpuinfo_len, "Processor");
- if (cpuProc != NULL)
+ if (cpuProc != nullptr)
{
D("found cpuProc = '%s'\n", cpuProc);
@@ -982,7 +982,7 @@ static void android_cpuInit(void)
const struct CpuIdEntry* entry = &cpu_id_entries[i];
char* value = extract_cpuinfo_field(cpuinfo, cpuinfo_len, entry->field);
- if (value == NULL)
+ if (value == nullptr)
continue;
D("field=%s value='%s'\n", entry->field, value);
diff --git a/winpr/libwinpr/sysinfo/sysinfo.c b/winpr/libwinpr/sysinfo/sysinfo.c
index 568429ce8..c7a6ee042 100644
--- a/winpr/libwinpr/sysinfo/sysinfo.c
+++ b/winpr/libwinpr/sysinfo/sysinfo.c
@@ -180,19 +180,19 @@ static DWORD GetNumberOfProcessors(void)
#else
mib[1] = HW_AVAILCPU;
#endif
- sysctl(mib, 2, &numCPUs, &length, NULL, 0);
+ sysctl(mib, 2, &numCPUs, &length, nullptr, 0);
if (numCPUs < 1)
{
mib[1] = HW_NCPU;
- sysctl(mib, 2, &numCPUs, &length, NULL, 0);
+ sysctl(mib, 2, &numCPUs, &length, nullptr, 0);
if (numCPUs < 1)
numCPUs = 1;
}
}
#elif defined(__hpux)
- numCPUs = (DWORD)mpctl(MPC_GETNUMSPUS, NULL, NULL);
+ numCPUs = (DWORD)mpctl(MPC_GETNUMSPUS, nullptr, nullptr);
#elif defined(__sgi)
numCPUs = (DWORD)sysconf(_SC_NPROC_ONLN);
#endif
@@ -246,7 +246,7 @@ void GetSystemTime(LPSYSTEMTIME lpSystemTime)
{
time_t ct = 0;
struct tm tres;
- struct tm* stm = NULL;
+ struct tm* stm = nullptr;
WORD wMilliseconds = 0;
UINT64 now = winpr_GetUnixTimeNS();
ct = WINPR_TIME_NS_TO_S(now);
@@ -278,7 +278,7 @@ VOID GetLocalTime(LPSYSTEMTIME lpSystemTime)
{
time_t ct = 0;
struct tm tres;
- struct tm* ltm = NULL;
+ struct tm* ltm = nullptr;
WORD wMilliseconds = 0;
UINT64 now = winpr_GetUnixTimeNS();
ct = WINPR_TIME_NS_TO_S(now);
@@ -415,7 +415,7 @@ BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation)
BOOL GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
{
BOOL rc = 0;
- LPSTR buffer = NULL;
+ LPSTR buffer = nullptr;
if (!lpnSize || (*lpnSize > INT_MAX))
return FALSE;
@@ -531,7 +531,7 @@ BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, LPSTR lpBuffer, LPDWORD l
BOOL GetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPWSTR lpBuffer, LPDWORD lpnSize)
{
BOOL rc = 0;
- LPSTR lpABuffer = NULL;
+ LPSTR lpABuffer = nullptr;
if (!lpnSize)
{
@@ -599,7 +599,7 @@ UINT64 winpr_GetTickCount64NS(void)
#else
struct timeval tv = WINPR_C_ARRAY_INIT;
- if (gettimeofday(&tv, NULL) == 0)
+ if (gettimeofday(&tv, nullptr) == 0)
ticks = (tv.tv_sec * 1000000000ull) + (tv.tv_usec * 1000ull);
/* We need to trick here:
@@ -645,7 +645,7 @@ UINT64 winpr_GetUnixTimeNS(void)
WINPR_ASSERTING_INT_CAST(uint64_t, ts.tv_nsec);
#else
struct timeval tv = WINPR_C_ARRAY_INIT;
- if (gettimeofday(&tv, NULL) != 0)
+ if (gettimeofday(&tv, nullptr) != 0)
return 0;
return tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000ull;
#endif
diff --git a/winpr/libwinpr/sysinfo/test/TestGetComputerName.c b/winpr/libwinpr/sysinfo/test/TestGetComputerName.c
index 0caef3dc7..2ad8f38e9 100644
--- a/winpr/libwinpr/sysinfo/test/TestGetComputerName.c
+++ b/winpr/libwinpr/sysinfo/test/TestGetComputerName.c
@@ -36,7 +36,7 @@ static BOOL Test_GetComputerName(void)
/* test with null buffer and zero size (required if buffer is null) */
dwSize = 0;
- if (GetComputerNameA(NULL, &dwSize) == TRUE)
+ if (GetComputerNameA(nullptr, &dwSize) == TRUE)
{
(void)fprintf(stderr, "%s: (1) GetComputerNameA unexpectedly succeeded with null buffer\n",
__func__);
@@ -177,15 +177,15 @@ static BOOL Test_GetComputerNameEx_Format(COMPUTER_NAME_FORMAT format)
* lpBuffer [out]
* A pointer to a buffer that receives the computer name or the cluster virtual server name.
* The length of the name may be greater than MAX_COMPUTERNAME_LENGTH characters because DNS
- * allows longer names. To ensure that this buffer is large enough, set this parameter to NULL
- * and use the required buffer size returned in the lpnSize parameter.
+ * allows longer names. To ensure that this buffer is large enough, set this parameter to
+ * nullptr and use the required buffer size returned in the lpnSize parameter.
*
* lpnSize [in, out]
* On input, specifies the size of the buffer, in TCHARs.
* On output, receives the number of TCHARs copied to the destination buffer, not including the
* terminating null character. If the buffer is too small, the function fails and GetLastError
* returns ERROR_MORE_DATA. This parameter receives the size of the buffer required, including
- * the terminating null character. If lpBuffer is NULL, this parameter must be zero.
+ * the terminating null character. If lpBuffer is nullptr, this parameter must be zero.
*
*/
@@ -214,7 +214,7 @@ static BOOL Test_GetComputerNameEx_Format(COMPUTER_NAME_FORMAT format)
/* test with null buffer and zero size (required if buffer is null) */
dwSize = 0;
- if (GetComputerNameExA(format, NULL, &dwSize) == TRUE)
+ if (GetComputerNameExA(format, nullptr, &dwSize) == TRUE)
{
(void)fprintf(stderr,
"%s: (1/%d) GetComputerNameExA unexpectedly succeeded with null buffer\n",
diff --git a/winpr/libwinpr/thread/apc.c b/winpr/libwinpr/thread/apc.c
index 7b3e66754..236a176e4 100644
--- a/winpr/libwinpr/thread/apc.c
+++ b/winpr/libwinpr/thread/apc.c
@@ -62,8 +62,8 @@ BOOL apc_uninit(APC_QUEUE* apc)
void apc_register(WINPR_THREAD* thread, WINPR_APC_ITEM* addItem)
{
- WINPR_APC_ITEM** nextp = NULL;
- APC_QUEUE* apc = NULL;
+ WINPR_APC_ITEM** nextp = nullptr;
+ APC_QUEUE* apc = nullptr;
WINPR_ASSERT(thread);
WINPR_ASSERT(addItem);
@@ -113,7 +113,7 @@ static inline void apc_item_remove(APC_QUEUE* apc, WINPR_APC_ITEM* item)
APC_REMOVE_RESULT apc_remove(WINPR_APC_ITEM* item)
{
WINPR_THREAD* thread = winpr_GetCurrentThread();
- APC_QUEUE* apc = NULL;
+ APC_QUEUE* apc = nullptr;
APC_REMOVE_RESULT ret = APC_REMOVE_OK;
WINPR_ASSERT(item);
@@ -155,9 +155,9 @@ out:
BOOL apc_collectFds(WINPR_THREAD* thread, WINPR_POLL_SET* set, BOOL* haveAutoSignaled)
{
- WINPR_APC_ITEM* item = NULL;
+ WINPR_APC_ITEM* item = nullptr;
BOOL ret = FALSE;
- APC_QUEUE* apc = NULL;
+ APC_QUEUE* apc = nullptr;
WINPR_ASSERT(thread);
WINPR_ASSERT(haveAutoSignaled);
@@ -186,8 +186,8 @@ out:
int apc_executeCompletions(WINPR_THREAD* thread, WINPR_POLL_SET* set, size_t startIndex)
{
- APC_QUEUE* apc = NULL;
- WINPR_APC_ITEM* nextItem = NULL;
+ APC_QUEUE* apc = nullptr;
+ WINPR_APC_ITEM* nextItem = nullptr;
size_t idx = startIndex;
int ret = 0;
@@ -241,9 +241,9 @@ int apc_executeCompletions(WINPR_THREAD* thread, WINPR_POLL_SET* set, size_t sta
void apc_cleanupThread(WINPR_THREAD* thread)
{
- WINPR_APC_ITEM* item = NULL;
- WINPR_APC_ITEM* nextItem = NULL;
- APC_QUEUE* apc = NULL;
+ WINPR_APC_ITEM* item = nullptr;
+ WINPR_APC_ITEM* nextItem = nullptr;
+ APC_QUEUE* apc = nullptr;
WINPR_ASSERT(thread);
@@ -259,13 +259,13 @@ void apc_cleanupThread(WINPR_THREAD* thread)
if (item->type == APC_TYPE_HANDLE_FREE)
item->completion(item->completionArgs);
- item->last = item->next = NULL;
+ item->last = item->next = nullptr;
item->linked = FALSE;
if (item->markedForFree)
free(item);
}
- apc->head = apc->tail = NULL;
+ apc->head = apc->tail = nullptr;
pthread_mutex_unlock(&apc->mutex);
}
diff --git a/winpr/libwinpr/thread/argv.c b/winpr/libwinpr/thread/argv.c
index 3a154a43c..9e0639164 100644
--- a/winpr/libwinpr/thread/argv.c
+++ b/winpr/libwinpr/thread/argv.c
@@ -88,44 +88,44 @@
LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs)
{
- const char* p = NULL;
+ const char* p = nullptr;
size_t length = 0;
- const char* pBeg = NULL;
- const char* pEnd = NULL;
- char* buffer = NULL;
- char* pOutput = NULL;
+ const char* pBeg = nullptr;
+ const char* pEnd = nullptr;
+ char* buffer = nullptr;
+ char* pOutput = nullptr;
int numArgs = 0;
- LPSTR* pArgs = NULL;
+ LPSTR* pArgs = nullptr;
size_t maxNumArgs = 0;
size_t maxBufferSize = 0;
size_t cmdLineLength = 0;
- BOOL* lpEscapedChars = NULL;
- LPSTR lpEscapedCmdLine = NULL;
+ BOOL* lpEscapedChars = nullptr;
+ LPSTR lpEscapedCmdLine = nullptr;
if (!lpCmdLine)
- return NULL;
+ return nullptr;
if (!pNumArgs)
- return NULL;
+ return nullptr;
- pArgs = NULL;
- lpEscapedCmdLine = NULL;
+ pArgs = nullptr;
+ lpEscapedCmdLine = nullptr;
cmdLineLength = strlen(lpCmdLine);
lpEscapedChars = (BOOL*)calloc(cmdLineLength + 1, sizeof(BOOL));
if (!lpEscapedChars)
- return NULL;
+ return nullptr;
if (strstr(lpCmdLine, "\\\""))
{
size_t n = 0;
- const char* pLastEnd = NULL;
+ const char* pLastEnd = nullptr;
lpEscapedCmdLine = (char*)calloc(cmdLineLength + 1, sizeof(char));
if (!lpEscapedCmdLine)
{
free(lpEscapedChars);
- return NULL;
+ return nullptr;
}
p = (const char*)lpCmdLine;
@@ -197,7 +197,7 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs)
{
free(lpEscapedCmdLine);
free(lpEscapedChars);
- return NULL;
+ return nullptr;
}
pArgs = (LPSTR*)buffer;
@@ -279,7 +279,7 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs)
LPWSTR* CommandLineToArgvW(WINPR_ATTR_UNUSED LPCWSTR lpCmdLine, WINPR_ATTR_UNUSED int* pNumArgs)
{
WLog_ERR("TODO", "TODO: Implement");
- return NULL;
+ return nullptr;
}
#endif
diff --git a/winpr/libwinpr/thread/process.c b/winpr/libwinpr/thread/process.c
index 086209d6d..5a1740760 100644
--- a/winpr/libwinpr/thread/process.c
+++ b/winpr/libwinpr/thread/process.c
@@ -99,19 +99,19 @@
static char* FindApplicationPath(char* application)
{
LPCSTR pathName = "PATH";
- char* path = NULL;
- char* save = NULL;
+ char* path = nullptr;
+ char* save = nullptr;
DWORD nSize = 0;
- LPSTR lpSystemPath = NULL;
- char* filename = NULL;
+ LPSTR lpSystemPath = nullptr;
+ char* filename = nullptr;
if (!application)
- return NULL;
+ return nullptr;
if (application[0] == '/')
return _strdup(application);
- nSize = GetEnvironmentVariableA(pathName, NULL, 0);
+ nSize = GetEnvironmentVariableA(pathName, nullptr, 0);
if (!nSize)
return _strdup(application);
@@ -119,15 +119,15 @@ static char* FindApplicationPath(char* application)
lpSystemPath = (LPSTR)malloc(nSize);
if (!lpSystemPath)
- return NULL;
+ return nullptr;
if (GetEnvironmentVariableA(pathName, lpSystemPath, nSize) != nSize - 1)
{
free(lpSystemPath);
- return NULL;
+ return nullptr;
}
- save = NULL;
+ save = nullptr;
path = strtok_s(lpSystemPath, ":", &save);
while (path)
@@ -140,8 +140,8 @@ static char* FindApplicationPath(char* application)
}
free(filename);
- filename = NULL;
- path = strtok_s(NULL, ":", &save);
+ filename = nullptr;
+ path = strtok_s(nullptr, ":", &save);
}
free(lpSystemPath);
@@ -162,19 +162,19 @@ static BOOL CreateProcessExA(HANDLE hToken, WINPR_ATTR_UNUSED DWORD dwLogonFlags
{
pid_t pid = 0;
int numArgs = 0;
- LPSTR* pArgs = NULL;
- char** envp = NULL;
- char* filename = NULL;
- HANDLE thread = NULL;
- HANDLE process = NULL;
- WINPR_ACCESS_TOKEN* token = NULL;
- LPTCH lpszEnvironmentBlock = NULL;
+ LPSTR* pArgs = nullptr;
+ char** envp = nullptr;
+ char* filename = nullptr;
+ HANDLE thread = nullptr;
+ HANDLE process = nullptr;
+ WINPR_ACCESS_TOKEN* token = nullptr;
+ LPTCH lpszEnvironmentBlock = nullptr;
BOOL ret = FALSE;
sigset_t oldSigMask;
sigset_t newSigMask;
BOOL restoreSigMask = FALSE;
numArgs = 0;
- lpszEnvironmentBlock = NULL;
+ lpszEnvironmentBlock = nullptr;
/* https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa
*/
if (lpCommandLine)
@@ -206,7 +206,7 @@ static BOOL CreateProcessExA(HANDLE hToken, WINPR_ATTR_UNUSED DWORD dwLogonFlags
filename = FindApplicationPath(pArgs[0]);
- if (NULL == filename)
+ if (nullptr == filename)
goto finish;
/* block all signals so that the child can safely reset the caller's handlers */
@@ -235,11 +235,11 @@ static BOOL CreateProcessExA(HANDLE hToken, WINPR_ATTR_UNUSED DWORD dwLogonFlags
sigemptyset(&act.sa_mask);
for (int sig = 1; sig < NSIG; sig++)
- sigaction(sig, &act, NULL);
+ sigaction(sig, &act, nullptr);
/* unblock all signals */
sigfillset(&set);
- pthread_sigmask(SIG_UNBLOCK, &set, NULL);
+ pthread_sigmask(SIG_UNBLOCK, &set, nullptr);
if (lpStartupInfo)
{
@@ -345,7 +345,7 @@ finish:
/* restore caller's original signal mask */
if (restoreSigMask)
- pthread_sigmask(SIG_SETMASK, &oldSigMask, NULL);
+ pthread_sigmask(SIG_SETMASK, &oldSigMask, nullptr);
free(filename);
free((void*)pArgs);
@@ -375,7 +375,7 @@ BOOL CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine,
DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory,
LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
- return CreateProcessExA(NULL, 0, lpApplicationName, lpCommandLine, lpProcessAttributes,
+ return CreateProcessExA(nullptr, 0, lpApplicationName, lpCommandLine, lpProcessAttributes,
lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment,
lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
}
@@ -451,7 +451,7 @@ BOOL CreateProcessWithTokenA(WINPR_ATTR_UNUSED HANDLE hToken, WINPR_ATTR_UNUSED
LPSTARTUPINFOA lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation)
{
- return CreateProcessExA(NULL, 0, lpApplicationName, lpCommandLine, NULL, NULL, FALSE,
+ return CreateProcessExA(nullptr, 0, lpApplicationName, lpCommandLine, nullptr, nullptr, FALSE,
dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo,
lpProcessInformation);
}
@@ -477,7 +477,7 @@ VOID ExitProcess(UINT uExitCode)
BOOL GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode)
{
- WINPR_PROCESS* process = NULL;
+ WINPR_PROCESS* process = nullptr;
if (!hProcess)
return FALSE;
@@ -493,7 +493,7 @@ BOOL GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode)
HANDLE _GetCurrentProcess(VOID)
{
WLog_ERR("TODO", "TODO: implement");
- return NULL;
+ return nullptr;
}
DWORD GetCurrentProcessId(VOID)
@@ -503,7 +503,7 @@ DWORD GetCurrentProcessId(VOID)
BOOL TerminateProcess(HANDLE hProcess, WINPR_ATTR_UNUSED UINT uExitCode)
{
- WINPR_PROCESS* process = NULL;
+ WINPR_PROCESS* process = nullptr;
process = (WINPR_PROCESS*)hProcess;
if (!process || (process->pid <= 0))
@@ -560,23 +560,23 @@ static HANDLE_OPS ops = { ProcessHandleIsHandle,
ProcessHandleCloseHandle,
ProcessGetFd,
ProcessCleanupHandle, /* CleanupHandle */
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL };
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr };
static int pidfd_open(pid_t pid)
{
@@ -616,11 +616,11 @@ static int pidfd_open(pid_t pid)
HANDLE CreateProcessHandle(pid_t pid)
{
- WINPR_PROCESS* process = NULL;
+ WINPR_PROCESS* process = nullptr;
process = (WINPR_PROCESS*)calloc(1, sizeof(WINPR_PROCESS));
if (!process)
- return NULL;
+ return nullptr;
process->pid = pid;
process->common.Type = HANDLE_TYPE_PROCESS;
diff --git a/winpr/libwinpr/thread/test/TestThreadCommandLineToArgv.c b/winpr/libwinpr/thread/test/TestThreadCommandLineToArgv.c
index 80941bf74..3a82d2195 100644
--- a/winpr/libwinpr/thread/test/TestThreadCommandLineToArgv.c
+++ b/winpr/libwinpr/thread/test/TestThreadCommandLineToArgv.c
@@ -57,7 +57,7 @@ static BOOL test_command_line_parsing_case(const char* line, const char** list,
if ((numArgs > 0) && !pArgs)
{
- (void)fprintf(stderr, "expected %d arguments, got NULL return\n", numArgs);
+ (void)fprintf(stderr, "expected %d arguments, got nullptr return\n", numArgs);
goto fail;
}
diff --git a/winpr/libwinpr/thread/test/TestThreadCreateProcess.c b/winpr/libwinpr/thread/test/TestThreadCreateProcess.c
index 85eb0cea8..08e0d43b3 100644
--- a/winpr/libwinpr/thread/test/TestThreadCreateProcess.c
+++ b/winpr/libwinpr/thread/test/TestThreadCreateProcess.c
@@ -14,7 +14,7 @@ int TestThreadCreateProcess(int argc, char* argv[])
{
BOOL status = 0;
DWORD exitCode = 0;
- LPCTSTR lpApplicationName = NULL;
+ LPCTSTR lpApplicationName = nullptr;
#ifdef _WIN32
TCHAR lpCommandLine[200] = _T("cmd /C set");
@@ -23,17 +23,17 @@ int TestThreadCreateProcess(int argc, char* argv[])
#endif
// LPTSTR lpCommandLine;
- LPSECURITY_ATTRIBUTES lpProcessAttributes = NULL;
- LPSECURITY_ATTRIBUTES lpThreadAttributes = NULL;
+ LPSECURITY_ATTRIBUTES lpProcessAttributes = nullptr;
+ LPSECURITY_ATTRIBUTES lpThreadAttributes = nullptr;
BOOL bInheritHandles = 0;
DWORD dwCreationFlags = 0;
- LPVOID lpEnvironment = NULL;
- LPCTSTR lpCurrentDirectory = NULL;
+ LPVOID lpEnvironment = nullptr;
+ LPCTSTR lpCurrentDirectory = nullptr;
STARTUPINFO StartupInfo = WINPR_C_ARRAY_INIT;
PROCESS_INFORMATION ProcessInformation = WINPR_C_ARRAY_INIT;
- LPTCH lpszEnvironmentBlock = NULL;
- HANDLE pipe_read = NULL;
- HANDLE pipe_write = NULL;
+ LPTCH lpszEnvironmentBlock = nullptr;
+ HANDLE pipe_read = nullptr;
+ HANDLE pipe_write = nullptr;
char buf[1024] = WINPR_C_ARRAY_INIT;
DWORD read_bytes = 0;
int ret = 0;
@@ -44,17 +44,17 @@ int TestThreadCreateProcess(int argc, char* argv[])
lpszEnvironmentBlock = GetEnvironmentStrings();
- lpApplicationName = NULL;
+ lpApplicationName = nullptr;
- lpProcessAttributes = NULL;
- lpThreadAttributes = NULL;
+ lpProcessAttributes = nullptr;
+ lpThreadAttributes = nullptr;
bInheritHandles = FALSE;
dwCreationFlags = 0;
#ifdef _UNICODE
dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT;
#endif
lpEnvironment = lpszEnvironmentBlock;
- lpCurrentDirectory = NULL;
+ lpCurrentDirectory = nullptr;
StartupInfo.cb = sizeof(STARTUPINFO);
status = CreateProcess(lpApplicationName, lpCommandLine, lpProcessAttributes,
@@ -87,7 +87,7 @@ int TestThreadCreateProcess(int argc, char* argv[])
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
- saAttr.lpSecurityDescriptor = NULL;
+ saAttr.lpSecurityDescriptor = nullptr;
if (!CreatePipe(&pipe_read, &pipe_write, &saAttr, 0))
{
@@ -133,7 +133,7 @@ int TestThreadCreateProcess(int argc, char* argv[])
}
ZeroMemory(buf, sizeof(buf));
- ReadFile(pipe_read, buf, sizeof(buf) - 1, &read_bytes, NULL);
+ ReadFile(pipe_read, buf, sizeof(buf) - 1, &read_bytes, nullptr);
if (!strstr((const char*)buf, TESTENV_A))
{
printf("No or unexpected data read from pipe\n");
diff --git a/winpr/libwinpr/thread/test/TestThreadExitThread.c b/winpr/libwinpr/thread/test/TestThreadExitThread.c
index ca7104f7e..2f6e37589 100644
--- a/winpr/libwinpr/thread/test/TestThreadExitThread.c
+++ b/winpr/libwinpr/thread/test/TestThreadExitThread.c
@@ -15,7 +15,7 @@ static DWORD WINAPI thread_func(LPVOID arg)
int TestThreadExitThread(int argc, char* argv[])
{
- HANDLE thread = NULL;
+ HANDLE thread = nullptr;
DWORD waitResult = 0;
WINPR_UNUSED(argc);
@@ -25,7 +25,7 @@ int TestThreadExitThread(int argc, char* argv[])
* decrease the number of loops */
for (int i = 0; i < 100; i++)
{
- thread = CreateThread(NULL, 0, thread_func, NULL, 0, NULL);
+ thread = CreateThread(nullptr, 0, thread_func, nullptr, 0, nullptr);
if (thread == INVALID_HANDLE_VALUE)
{
diff --git a/winpr/libwinpr/thread/thread.c b/winpr/libwinpr/thread/thread.c
index b9d76f4ca..ca4713f5a 100644
--- a/winpr/libwinpr/thread/thread.c
+++ b/winpr/libwinpr/thread/thread.c
@@ -114,7 +114,7 @@
static WINPR_THREAD mainThread;
#if defined(WITH_THREAD_LIST)
-static wListDictionary* thread_list = NULL;
+static wListDictionary* thread_list = nullptr;
#endif
static BOOL ThreadCloseHandle(HANDLE handle);
@@ -220,10 +220,10 @@ static BOOL mux_condition_bundle_init(mux_condition_bundle* bundle)
WINPR_ASSERT(bundle);
bundle->val = FALSE;
- if (!run_mutex_init(pthread_mutex_init, &bundle->mux, NULL))
+ if (!run_mutex_init(pthread_mutex_init, &bundle->mux, nullptr))
return FALSE;
- if (!run_cond_init(pthread_cond_init, &bundle->cond, NULL))
+ if (!run_cond_init(pthread_cond_init, &bundle->cond, nullptr))
return FALSE;
return TRUE;
}
@@ -329,7 +329,7 @@ static DWORD ThreadCleanupHandle(HANDLE handle)
if (!thread->joined)
{
- int rc = pthread_join(thread->thread, NULL);
+ int rc = pthread_join(thread->thread, nullptr);
if (rc != 0)
{
@@ -351,33 +351,18 @@ fail:
return status;
}
-static HANDLE_OPS ops = { ThreadIsHandled,
- ThreadCloseHandle,
- ThreadGetFd,
- ThreadCleanupHandle,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL };
+static HANDLE_OPS ops = { ThreadIsHandled, ThreadCloseHandle, ThreadGetFd, ThreadCleanupHandle,
+ nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr,
+ nullptr };
static void dump_thread(WINPR_THREAD* thread)
{
#if defined(WITH_DEBUG_THREADS)
void* stack = winpr_backtrace(20);
- char** msg = NULL;
+ char** msg = nullptr;
size_t used = 0;
WLog_DBG(TAG, "Called from:");
msg = winpr_backtrace_symbols(stack, &used);
@@ -519,7 +504,7 @@ static void* thread_launcher(void* arg)
{
DWORD rc = 0;
WINPR_THREAD* thread = (WINPR_THREAD*)arg;
- LPTHREAD_START_ROUTINE fkt = NULL;
+ LPTHREAD_START_ROUTINE fkt = nullptr;
if (!thread)
{
@@ -567,7 +552,7 @@ exit:
cleanup_handle(thread);
}
- return NULL;
+ return nullptr;
}
static BOOL winpr_StartThread(WINPR_THREAD* thread)
@@ -632,7 +617,7 @@ error:
BOOL SetThreadPriority(HANDLE hThread, int nPriority)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
+ WINPR_HANDLE* Object = nullptr;
if (!winpr_Handle_GetInfo(hThread, &Type, &Object) || Object->Type != HANDLE_TYPE_THREAD)
return FALSE;
@@ -690,11 +675,11 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, size_t dwStackSize
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter,
DWORD dwCreationFlags, WINPR_ATTR_UNUSED LPDWORD lpThreadId)
{
- HANDLE handle = NULL;
+ HANDLE handle = nullptr;
WINPR_THREAD* thread = (WINPR_THREAD*)calloc(1, sizeof(WINPR_THREAD));
if (!thread)
- return NULL;
+ return nullptr;
thread->dwStackSize = dwStackSize;
thread->lpParameter = lpParameter;
@@ -712,7 +697,7 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, size_t dwStackSize
goto fail;
}
- if (!run_mutex_init(pthread_mutex_init, &thread->mutex, NULL))
+ if (!run_mutex_init(pthread_mutex_init, &thread->mutex, nullptr))
{
WLog_ERR(TAG, "failed to initialize thread mutex");
goto fail;
@@ -732,7 +717,7 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, size_t dwStackSize
WINPR_HANDLE_SET_TYPE_AND_MODE(thread, HANDLE_TYPE_THREAD, WINPR_FD_READ);
handle = (HANDLE)thread;
- InitOnceExecuteOnce(&threads_InitOnce, initializeThreads, NULL, NULL);
+ InitOnceExecuteOnce(&threads_InitOnce, initializeThreads, nullptr, nullptr);
if (!(dwCreationFlags & CREATE_SUSPENDED))
{
@@ -748,7 +733,7 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, size_t dwStackSize
return handle;
fail:
cleanup_handle(thread);
- return NULL;
+ return nullptr;
}
void cleanup_handle(void* obj)
@@ -831,7 +816,7 @@ HANDLE CreateRemoteThread(WINPR_ATTR_UNUSED HANDLE hProcess,
{
WLog_ERR(TAG, "not implemented");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return NULL;
+ return nullptr;
}
VOID ExitThread(DWORD dwExitCode)
@@ -884,8 +869,8 @@ VOID ExitThread(DWORD dwExitCode)
BOOL GetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_THREAD* thread = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_THREAD* thread = nullptr;
if (!winpr_Handle_GetInfo(hThread, &Type, &Object) || Object->Type != HANDLE_TYPE_THREAD)
{
@@ -901,9 +886,9 @@ BOOL GetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode)
WINPR_THREAD* winpr_GetCurrentThread(VOID)
{
- WINPR_THREAD* ret = NULL;
+ WINPR_THREAD* ret = nullptr;
- InitOnceExecuteOnce(&threads_InitOnce, initializeThreads, NULL, NULL);
+ InitOnceExecuteOnce(&threads_InitOnce, initializeThreads, nullptr, nullptr);
if (mainThreadId == pthread_self())
return (HANDLE)&mainThread;
@@ -950,9 +935,9 @@ static void userAPC(LPVOID arg)
DWORD QueueUserAPC(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_APC_ITEM* apc = NULL;
- UserApcItem* apcItem = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_APC_ITEM* apc = nullptr;
+ UserApcItem* apcItem = nullptr;
if (!pfnAPC)
return 1;
@@ -986,8 +971,8 @@ DWORD QueueUserAPC(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData)
DWORD ResumeThread(HANDLE hThread)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_THREAD* thread = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_THREAD* thread = nullptr;
if (!winpr_Handle_GetInfo(hThread, &Type, &Object) || Object->Type != HANDLE_TYPE_THREAD)
{
@@ -1040,8 +1025,8 @@ BOOL SwitchToThread(VOID)
BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode)
{
ULONG Type = 0;
- WINPR_HANDLE* Object = NULL;
- WINPR_THREAD* thread = NULL;
+ WINPR_HANDLE* Object = nullptr;
+ WINPR_THREAD* thread = nullptr;
if (!winpr_Handle_GetInfo(hThread, &Type, &Object) || Object->Type != HANDLE_TYPE_THREAD)
return FALSE;
@@ -1069,7 +1054,7 @@ BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode)
VOID DumpThreadHandles(void)
{
#if defined(WITH_DEBUG_THREADS)
- char** msg = NULL;
+ char** msg = nullptr;
size_t used = 0;
void* stack = winpr_backtrace(20);
WLog_DBG(TAG, "---------------- Called from ----------------------------");
@@ -1091,7 +1076,7 @@ VOID DumpThreadHandles(void)
}
else
{
- ULONG_PTR* keys = NULL;
+ ULONG_PTR* keys = nullptr;
ListDictionary_Lock(thread_list);
int x, count = ListDictionary_GetKeys(thread_list, &keys);
WLog_DBG(TAG, "Dumping %d elements", count);
diff --git a/winpr/libwinpr/thread/tls.c b/winpr/libwinpr/thread/tls.c
index 977d47d2a..d81f25f97 100644
--- a/winpr/libwinpr/thread/tls.c
+++ b/winpr/libwinpr/thread/tls.c
@@ -38,7 +38,7 @@ DWORD TlsAlloc(void)
{
pthread_key_t key = 0;
- if (pthread_key_create(&key, NULL) != 0)
+ if (pthread_key_create(&key, nullptr) != 0)
return TLS_OUT_OF_INDEXES;
return key;
@@ -46,7 +46,7 @@ DWORD TlsAlloc(void)
LPVOID TlsGetValue(DWORD dwTlsIndex)
{
- LPVOID value = NULL;
+ LPVOID value = nullptr;
pthread_key_t key = 0;
key = (pthread_key_t)dwTlsIndex;
value = (LPVOID)pthread_getspecific(key);
diff --git a/winpr/libwinpr/timezone/TimeZoneIanaAbbrevMap.c b/winpr/libwinpr/timezone/TimeZoneIanaAbbrevMap.c
index 810f08cc4..ae775dcd6 100644
--- a/winpr/libwinpr/timezone/TimeZoneIanaAbbrevMap.c
+++ b/winpr/libwinpr/timezone/TimeZoneIanaAbbrevMap.c
@@ -38,7 +38,7 @@ typedef struct
const static char* zonepath = "/usr/share/zoneinfo";
-static TimeZoneInanaAbbrevMapEntry* TimeZoneIanaAbbrevMap = NULL;
+static TimeZoneInanaAbbrevMapEntry* TimeZoneIanaAbbrevMap = nullptr;
static size_t TimeZoneIanaAbbrevMapSize = 0;
static void append(const char* iana, const char* sname)
@@ -59,7 +59,7 @@ static void append(const char* iana, const char* sname)
static void append_timezone(const char* dir, const char* name)
{
- char* tz = NULL;
+ char* tz = nullptr;
if (!dir && !name)
return;
if (!dir)
@@ -77,7 +77,7 @@ static void append_timezone(const char* dir, const char* name)
char* oldtz = setNewAndSaveOldTZ(tz);
- const time_t t = time(NULL);
+ const time_t t = time(nullptr);
struct tm lt = WINPR_C_ARRAY_INIT;
(void)localtime_r(&t, <);
append(tz, lt.tm_zone);
@@ -90,10 +90,10 @@ static void handle_link(const char* base, const char* dir, const char* name);
static char* topath(const char* base, const char* bname, const char* name)
{
size_t plen = 0;
- char* path = NULL;
+ char* path = nullptr;
if (!base && !bname && !name)
- return NULL;
+ return nullptr;
if (!base && !name)
return _strdup(bname);
@@ -124,9 +124,9 @@ static void iterate_subdir_recursive(const char* base, const char* bname, const
DIR* d = opendir(path);
if (d)
{
- struct dirent* dp = NULL;
+ struct dirent* dp = nullptr;
// NOLINTNEXTLINE(concurrency-mt-unsafe)
- while ((dp = readdir(d)) != NULL)
+ while ((dp = readdir(d)) != nullptr)
{
switch (dp->d_type)
{
@@ -136,7 +136,7 @@ static void iterate_subdir_recursive(const char* base, const char* bname, const
continue;
if (strcmp(dp->d_name, "..") == 0)
continue;
- iterate_subdir_recursive(path, dp->d_name, NULL);
+ iterate_subdir_recursive(path, dp->d_name, nullptr);
}
break;
case DT_LNK:
@@ -156,14 +156,14 @@ static void iterate_subdir_recursive(const char* base, const char* bname, const
static char* get_link_target(const char* base, const char* dir, const char* name)
{
- char* apath = NULL;
+ char* apath = nullptr;
char* path = topath(base, dir, name);
if (!path)
- return NULL;
+ return nullptr;
SSIZE_T rc = -1;
size_t size = 0;
- char* target = NULL;
+ char* target = nullptr;
do
{
size += 64;
@@ -226,7 +226,7 @@ static void TimeZoneIanaAbbrevCleanup(void)
free(entry->Abbrev);
}
free(TimeZoneIanaAbbrevMap);
- TimeZoneIanaAbbrevMap = NULL;
+ TimeZoneIanaAbbrevMap = nullptr;
TimeZoneIanaAbbrevMapSize = 0;
}
@@ -234,7 +234,7 @@ static BOOL CALLBACK TimeZoneIanaAbbrevInitialize(WINPR_ATTR_UNUSED PINIT_ONCE o
WINPR_ATTR_UNUSED PVOID param,
WINPR_ATTR_UNUSED PVOID* context)
{
- iterate_subdir_recursive(zonepath, NULL, NULL);
+ iterate_subdir_recursive(zonepath, nullptr, nullptr);
(void)atexit(TimeZoneIanaAbbrevCleanup);
return TRUE;
@@ -244,7 +244,7 @@ size_t TimeZoneIanaAbbrevGet(const char* abbrev, const char** list, size_t lists
{
static INIT_ONCE init_guard = INIT_ONCE_STATIC_INIT;
- InitOnceExecuteOnce(&init_guard, TimeZoneIanaAbbrevInitialize, NULL, NULL);
+ InitOnceExecuteOnce(&init_guard, TimeZoneIanaAbbrevInitialize, nullptr, nullptr);
size_t rc = 0;
for (size_t x = 0; x < TimeZoneIanaAbbrevMapSize; x++)
diff --git a/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c b/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c
index 2f78f005f..c78058069 100644
--- a/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c
+++ b/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c
@@ -90,7 +90,7 @@ static void tz_context_free(void)
tz_entry_free(&tz_context.entries[x]);
free(tz_context.entries);
tz_context.count = 0;
- tz_context.entries = NULL;
+ tz_context.entries = nullptr;
}
#if defined(WITH_TIMEZONE_FROM_FILE) && defined(WITH_WINPR_JSON)
@@ -101,7 +101,7 @@ static char* tz_get_object_str(WINPR_JSON* json, size_t pos, const char* name)
{
WLog_WARN(TAG, "Invalid JSON entry at entry %" PRIuz ", missing an Object named '%s'", pos,
name);
- return NULL;
+ return nullptr;
}
WINPR_JSON* obj = WINPR_JSON_GetObjectItemCaseSensitive(json, name);
WINPR_ASSERT(obj);
@@ -110,15 +110,15 @@ static char* tz_get_object_str(WINPR_JSON* json, size_t pos, const char* name)
WLog_WARN(TAG,
"Invalid JSON entry at entry %" PRIuz ", Object named '%s': Not of type string",
pos, name);
- return NULL;
+ return nullptr;
}
const char* str = WINPR_JSON_GetStringValue(obj);
if (!str)
{
- WLog_WARN(TAG, "Invalid JSON entry at entry %" PRIuz ", Object named '%s': NULL string",
+ WLog_WARN(TAG, "Invalid JSON entry at entry %" PRIuz ", Object named '%s': nullptr string",
pos, name);
- return NULL;
+ return nullptr;
}
return _strdup(str);
@@ -189,7 +189,7 @@ static BOOL CALLBACK load_timezones(PINIT_ONCE once, PVOID param, PVOID* pvconte
#if defined(WITH_TIMEZONE_FROM_FILE) && defined(WITH_WINPR_JSON)
{
- WINPR_JSON* json = NULL;
+ WINPR_JSON* json = nullptr;
char* filename = GetCombinedPath(WINPR_RESOURCE_ROOT, "TimeZoneNameMap.json");
if (!filename)
{
@@ -248,9 +248,9 @@ const TimeZoneNameMapEntry* TimeZoneGetAt(size_t index)
{
static INIT_ONCE init_guard = INIT_ONCE_STATIC_INIT;
- InitOnceExecuteOnce(&init_guard, load_timezones, &tz_context, NULL);
+ InitOnceExecuteOnce(&init_guard, load_timezones, &tz_context, nullptr);
if (index >= tz_context.count)
- return NULL;
+ return nullptr;
return &tz_context.entries[index];
}
@@ -270,7 +270,7 @@ static const char* return_type(const TimeZoneNameMapEntry* entry, TimeZoneNameTy
case TIME_ZONE_NAME_DAYLIGHT:
return entry->DaylightName;
default:
- return NULL;
+ return nullptr;
}
}
@@ -299,7 +299,7 @@ static const char* get_for_type(const char* val, TimeZoneNameType type,
{
const TimeZoneNameMapEntry* entry = TimeZoneGetAt(index++);
if (!entry)
- return NULL;
+ return nullptr;
if (cmp(entry, val))
return return_type(entry, type);
}
@@ -308,11 +308,11 @@ static const char* get_for_type(const char* val, TimeZoneNameType type,
#if defined(WITH_TIMEZONE_ICU)
static char* get_wzid_icu(const UChar* utzid, size_t utzid_len)
{
- char* res = NULL;
+ char* res = nullptr;
UErrorCode error = U_ZERO_ERROR;
int32_t rc = ucal_getWindowsTimeZoneID(utzid, WINPR_ASSERTING_INT_CAST(int32_t, utzid_len),
- NULL, 0, &error);
+ nullptr, 0, &error);
if ((error == U_BUFFER_OVERFLOW_ERROR) && (rc > 0))
{
rc++; // make space for '\0'
@@ -323,7 +323,7 @@ static char* get_wzid_icu(const UChar* utzid, size_t utzid_len)
int32_t rc2 = ucal_getWindowsTimeZoneID(
utzid, WINPR_ASSERTING_INT_CAST(int32_t, utzid_len), wzid, rc, &error2);
if (U_SUCCESS(error2) && (rc2 > 0))
- res = ConvertWCharNToUtf8Alloc(wzid, (size_t)rc, NULL);
+ res = ConvertWCharNToUtf8Alloc(wzid, (size_t)rc, nullptr);
free(wzid);
}
}
@@ -335,7 +335,7 @@ static char* get(const char* iana)
size_t utzid_len = 0;
UChar* utzid = ConvertUtf8ToWCharAlloc(iana, &utzid_len);
if (!utzid)
- return NULL;
+ return nullptr;
char* wzid = get_wzid_icu(utzid, utzid_len);
free(utzid);
@@ -346,7 +346,7 @@ static const char* map_fallback(const char* iana, TimeZoneNameType type)
{
char* wzid = get(iana);
if (!wzid)
- return NULL;
+ return nullptr;
const char* res = get_for_type(wzid, type, id_cmp);
free(wzid);
@@ -356,14 +356,14 @@ static const char* map_fallback(const char* iana, TimeZoneNameType type)
static const char* map_fallback(const char* iana, WINPR_ATTR_UNUSED TimeZoneNameType type)
{
if (!iana)
- return NULL;
+ return nullptr;
for (size_t x = 0; x < WindowsZonesNrElements; x++)
{
const WINDOWS_TZID_ENTRY* const entry = &WindowsZones[x];
if (strchr(entry->tzid, ' '))
{
- const char* res = NULL;
+ const char* res = nullptr;
char* tzid = _strdup(entry->tzid);
char* ctzid = tzid;
while (tzid)
@@ -386,14 +386,14 @@ static const char* map_fallback(const char* iana, WINPR_ATTR_UNUSED TimeZoneName
return entry->windows;
}
- return NULL;
+ return nullptr;
}
#endif
const char* TimeZoneIanaToWindows(const char* iana, TimeZoneNameType type)
{
if (!iana)
- return NULL;
+ return nullptr;
const char* val = get_for_type(iana, type, iana_cmp);
if (val)
@@ -401,7 +401,7 @@ const char* TimeZoneIanaToWindows(const char* iana, TimeZoneNameType type)
const char* wzid = map_fallback(iana, type);
if (!wzid)
- return NULL;
+ return nullptr;
return get_for_type(wzid, type, id_cmp);
}
diff --git a/winpr/libwinpr/timezone/timezone.c b/winpr/libwinpr/timezone/timezone.c
index 364d36ff3..cc64ed7c6 100644
--- a/winpr/libwinpr/timezone/timezone.c
+++ b/winpr/libwinpr/timezone/timezone.c
@@ -52,7 +52,7 @@ static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp)
char* tzid = malloc(length);
if (!tzid)
- return NULL;
+ return nullptr;
do
{
@@ -66,7 +66,7 @@ static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp)
if (read > length - 1UL)
{
free(tzid);
- return NULL;
+ return nullptr;
}
length += CHUNK_SIZE;
@@ -74,7 +74,7 @@ static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp)
if (!tmp)
{
free(tzid);
- return NULL;
+ return nullptr;
}
tzid = tmp;
@@ -83,7 +83,7 @@ static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp)
if (ferror(fp))
{
free(tzid);
- return NULL;
+ return nullptr;
}
tzid[read] = '\0';
@@ -100,7 +100,7 @@ static char* winpr_get_timezone_from_link(const char* links[], size_t count)
{
const char* _links[] = { "/etc/localtime", "/etc/TZ" };
- if (links == NULL)
+ if (links == nullptr)
{
links = _links;
count = ARRAYSIZE(_links);
@@ -115,9 +115,9 @@ static char* winpr_get_timezone_from_link(const char* links[], size_t count)
for (size_t x = 0; x < count; x++)
{
- char* tzid = NULL;
+ char* tzid = nullptr;
const char* link = links[x];
- char* buf = realpath(link, NULL);
+ char* buf = realpath(link, nullptr);
if (buf)
{
@@ -161,7 +161,7 @@ static char* winpr_get_timezone_from_link(const char* links[], size_t count)
return tzid;
}
- return NULL;
+ return nullptr;
}
#if defined(ANDROID)
@@ -169,7 +169,7 @@ static char* winpr_get_timezone_from_link(const char* links[], size_t count)
static char* winpr_get_android_timezone_identifier(void)
{
- char* tzid = NULL;
+ char* tzid = nullptr;
JNIEnv* jniEnv;
/* Preferred: Try to get identifier from java TimeZone class */
@@ -181,7 +181,7 @@ static char* winpr_get_android_timezone_identifier(void)
jmethodID jDefaultTimezone;
jmethodID jTimezoneIdentifier;
jstring tzJId;
- jboolean attached = (*jniVm)->AttachCurrentThread(jniVm, &jniEnv, NULL);
+ jboolean attached = (*jniVm)->AttachCurrentThread(jniVm, &jniEnv, nullptr);
jObjClass = (*jniEnv)->FindClass(jniEnv, "java/util/TimeZone");
if (!jObjClass)
@@ -242,8 +242,8 @@ static char* winpr_get_unix_timezone_identifier_from_file(void)
#if defined(ANDROID)
return winpr_get_android_timezone_identifier();
#else
- FILE* fp = NULL;
- char* tzid = NULL;
+ FILE* fp = nullptr;
+ char* tzid = nullptr;
#if !defined(WINPR_TIMEZONE_FILE)
#error \
"Please define WINPR_TIMEZONE_FILE with the path to your timezone file (e.g. /etc/timezone or similar)"
@@ -251,12 +251,12 @@ static char* winpr_get_unix_timezone_identifier_from_file(void)
fp = winpr_fopen(WINPR_TIMEZONE_FILE, "r");
#endif
- if (NULL == fp)
- return NULL;
+ if (nullptr == fp)
+ return nullptr;
tzid = winpr_read_unix_timezone_identifier_from_file(fp);
(void)fclose(fp);
- if (tzid != NULL)
+ if (tzid != nullptr)
WLog_DBG(TAG, "tzid: %s", tzid);
return tzid;
#endif
@@ -265,9 +265,9 @@ static char* winpr_get_unix_timezone_identifier_from_file(void)
static char* winpr_time_zone_from_env(void)
{
LPCSTR tz = "TZ";
- char* tzid = NULL;
+ char* tzid = nullptr;
- DWORD nSize = GetEnvironmentVariableA(tz, NULL, 0);
+ DWORD nSize = GetEnvironmentVariableA(tz, nullptr, 0);
if (nSize > 0)
{
tzid = (char*)calloc(nSize, sizeof(char));
@@ -286,17 +286,17 @@ static char* winpr_time_zone_from_env(void)
fail:
free(tzid);
- return NULL;
+ return nullptr;
}
static char* winpr_translate_time_zone(const char* tzid)
{
const char* zipath = "/usr/share/zoneinfo/";
- char* buf = NULL;
+ char* buf = nullptr;
const char* links[] = { buf };
if (!tzid)
- return NULL;
+ return nullptr;
if (tzid[0] == '/')
{
@@ -323,7 +323,7 @@ static char* winpr_guess_time_zone(void)
tzid = winpr_get_unix_timezone_identifier_from_file();
if (tzid)
goto end;
- tzid = winpr_get_timezone_from_link(NULL, 0);
+ tzid = winpr_get_timezone_from_link(nullptr, 0);
if (tzid)
goto end;
@@ -481,7 +481,7 @@ static BOOL get_transition_date(const struct tm* start, BOOL toDst, SYSTEMTIME*
WINPR_ASSERT(start);
WINPR_ASSERT(pdate);
- *pdate = tm2transitiontime(NULL);
+ *pdate = tm2transitiontime(nullptr);
if (start->tm_isdst < 0)
return FALSE;
@@ -549,7 +549,7 @@ static BOOL map_iana_id(const char* iana, LPDYNAMIC_TIME_ZONE_INFORMATION tz)
if (winId)
(void)ConvertUtf8ToWChar(winId, tz->TimeZoneKeyName, ARRAYSIZE(tz->TimeZoneKeyName));
- return winId != NULL;
+ return winId != nullptr;
}
static const char* weekday2str(WORD wDayOfWeek)
@@ -752,8 +752,8 @@ static int dynamic_time_zone_from_localtime(const struct tm* local_time,
DWORD GetDynamicTimeZoneInformation(PDYNAMIC_TIME_ZONE_INFORMATION pTimeZoneInformation)
{
- const char** list = NULL;
- char* tzid = NULL;
+ const char** list = nullptr;
+ char* tzid = nullptr;
const char* defaultName = "Client Local Time";
DWORD res = TIME_ZONE_ID_UNKNOWN;
const DYNAMIC_TIME_ZONE_INFORMATION empty = WINPR_C_ARRAY_INIT;
@@ -764,7 +764,7 @@ DWORD GetDynamicTimeZoneInformation(PDYNAMIC_TIME_ZONE_INFORMATION pTimeZoneInfo
(void)ConvertUtf8ToWChar(defaultName, pTimeZoneInformation->StandardName,
ARRAYSIZE(pTimeZoneInformation->StandardName));
- const time_t t = time(NULL);
+ const time_t t = time(nullptr);
struct tm tres = WINPR_C_ARRAY_INIT;
struct tm* local_time = localtime_r(&t, &tres);
if (!local_time)
@@ -777,7 +777,7 @@ DWORD GetDynamicTimeZoneInformation(PDYNAMIC_TIME_ZONE_INFORMATION pTimeZoneInfo
tzid = winpr_guess_time_zone();
if (!map_iana_id(tzid, pTimeZoneInformation))
{
- const size_t len = TimeZoneIanaAbbrevGet(local_time->tm_zone, NULL, 0);
+ const size_t len = TimeZoneIanaAbbrevGet(local_time->tm_zone, nullptr, 0);
list = (const char**)calloc(len, sizeof(const char*));
if (!list)
goto out_error;
@@ -866,10 +866,10 @@ DWORD EnumDynamicTimeZoneInformation(DWORD dwIndex,
(void)ConvertUtf8ToWChar(entry->Id, lpTimeZoneInformation->TimeZoneKeyName,
ARRAYSIZE(lpTimeZoneInformation->TimeZoneKeyName));
- const time_t t = time(NULL);
+ const time_t t = time(nullptr);
struct tm tres = WINPR_C_ARRAY_INIT;
- char* tzcopy = entry->Iana ? setNewAndSaveOldTZ(entry->Iana) : NULL;
+ char* tzcopy = entry->Iana ? setNewAndSaveOldTZ(entry->Iana) : nullptr;
struct tm* local_time = localtime_r(&t, &tres);
@@ -917,7 +917,7 @@ char* setNewAndSaveOldTZ(const char* val)
{
// NOLINTBEGIN(concurrency-mt-unsafe)
const char* otz = getenv("TZ");
- char* oldtz = NULL;
+ char* oldtz = nullptr;
if (otz)
oldtz = _strdup(otz);
setenv("TZ", val, 1);
diff --git a/winpr/libwinpr/utils/android.c b/winpr/libwinpr/utils/android.c
index 2918cc717..0bc62445e 100644
--- a/winpr/libwinpr/utils/android.c
+++ b/winpr/libwinpr/utils/android.c
@@ -27,7 +27,7 @@
#define TAG WINPR_TAG("android")
-JavaVM* jniVm = NULL;
+JavaVM* jniVm = nullptr;
WINPR_API jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
@@ -39,7 +39,7 @@ WINPR_API jint JNI_OnLoad(JavaVM* vm, void* reserved)
WINPR_API void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved)
{
- JNIEnv* env = NULL;
+ JNIEnv* env = nullptr;
WLog_INFO(TAG, "Tearing down JNI environment...");
if ((*jniVm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK)
@@ -56,7 +56,7 @@ jboolean winpr_jni_attach_thread(JNIEnv** env)
if ((*jniVm)->GetEnv(jniVm, (void**)env, JNI_VERSION_1_4) != JNI_OK)
{
WLog_INFO(TAG, "android_java_callback: attaching current thread");
- (*jniVm)->AttachCurrentThread(jniVm, env, NULL);
+ (*jniVm)->AttachCurrentThread(jniVm, env, nullptr);
if ((*jniVm)->GetEnv(jniVm, (void**)env, JNI_VERSION_1_4) != JNI_OK)
{
diff --git a/winpr/libwinpr/utils/asn1/asn1.c b/winpr/libwinpr/utils/asn1/asn1.c
index 275e6ddf4..1ce1b48ef 100644
--- a/winpr/libwinpr/utils/asn1/asn1.c
+++ b/winpr/libwinpr/utils/asn1/asn1.c
@@ -78,7 +78,7 @@ void WinPrAsn1FreeOID(WinPrAsn1_OID* poid)
{
WINPR_ASSERT(poid);
free(poid->data);
- poid->data = NULL;
+ poid->data = nullptr;
poid->len = 0;
}
@@ -147,14 +147,14 @@ WinPrAsn1Encoder* WinPrAsn1Encoder_New(WinPrAsn1EncodingRule encoding)
{
WinPrAsn1Encoder* enc = calloc(1, sizeof(*enc));
if (!enc)
- return NULL;
+ return nullptr;
enc->encoding = encoding;
- enc->pool = Stream_New(NULL, 1024);
+ enc->pool = Stream_New(nullptr, 1024);
if (!enc->pool)
{
free(enc);
- return NULL;
+ return nullptr;
}
enc->containers = &enc->staticContainers[0];
@@ -176,7 +176,7 @@ void WinPrAsn1Encoder_Reset(WinPrAsn1Encoder* enc)
void WinPrAsn1Encoder_Free(WinPrAsn1Encoder** penc)
{
- WinPrAsn1Encoder* enc = NULL;
+ WinPrAsn1Encoder* enc = nullptr;
WINPR_ASSERT(penc);
enc = *penc;
@@ -191,13 +191,13 @@ void WinPrAsn1Encoder_Free(WinPrAsn1Encoder** penc)
Stream_Free(enc->pool, TRUE);
free(enc);
}
- *penc = NULL;
+ *penc = nullptr;
}
static Asn1Chunk* asn1enc_get_free_chunk(WinPrAsn1Encoder* enc, size_t chunkSz, BOOL commit,
size_t* id)
{
- Asn1Chunk* ret = NULL;
+ Asn1Chunk* ret = nullptr;
WINPR_ASSERT(enc);
WINPR_ASSERT(chunkSz);
@@ -210,7 +210,7 @@ static Asn1Chunk* asn1enc_get_free_chunk(WinPrAsn1Encoder* enc, size_t chunkSz,
if (ret->capacity && ret->capacity == ret->used)
{
if (!Stream_EnsureRemainingCapacity(enc->pool, chunkSz))
- return NULL;
+ return nullptr;
Stream_Seek(enc->pool, chunkSz);
ret->capacity += chunkSz;
@@ -224,10 +224,10 @@ static Asn1Chunk* asn1enc_get_free_chunk(WinPrAsn1Encoder* enc, size_t chunkSz,
if (enc->freeChunkId == enc->chunksCapacity)
{
/* chunks need a resize */
- Asn1Chunk* src = (enc->chunks != &enc->staticChunks[0]) ? enc->chunks : NULL;
+ Asn1Chunk* src = (enc->chunks != &enc->staticChunks[0]) ? enc->chunks : nullptr;
Asn1Chunk* tmp = realloc(src, (enc->chunksCapacity + 10) * sizeof(*src));
if (!tmp)
- return NULL;
+ return nullptr;
if (enc->chunks == &enc->staticChunks[0])
memcpy(tmp, &enc->staticChunks[0], enc->chunksCapacity * sizeof(*src));
@@ -238,10 +238,10 @@ static Asn1Chunk* asn1enc_get_free_chunk(WinPrAsn1Encoder* enc, size_t chunkSz,
enc->chunksCapacity += 10;
}
if (enc->freeChunkId == enc->chunksCapacity)
- return NULL;
+ return nullptr;
if (!Stream_EnsureRemainingCapacity(enc->pool, chunkSz))
- return NULL;
+ return nullptr;
ret = &enc->chunks[enc->freeChunkId];
ret->poolOffset = Stream_GetPosition(enc->pool);
@@ -257,17 +257,17 @@ static Asn1Chunk* asn1enc_get_free_chunk(WinPrAsn1Encoder* enc, size_t chunkSz,
static WinPrAsn1EncContainer* asn1enc_get_free_container(WinPrAsn1Encoder* enc, size_t* id)
{
- WinPrAsn1EncContainer* ret = NULL;
+ WinPrAsn1EncContainer* ret = nullptr;
WINPR_ASSERT(enc);
if (enc->freeContainerIndex == enc->containerCapacity)
{
/* containers need a resize (or switch from static to dynamic) */
WinPrAsn1EncContainer* src =
- (enc->containers != &enc->staticContainers[0]) ? enc->containers : NULL;
+ (enc->containers != &enc->staticContainers[0]) ? enc->containers : nullptr;
WinPrAsn1EncContainer* tmp = realloc(src, (enc->containerCapacity + 10) * sizeof(*src));
if (!tmp)
- return NULL;
+ return nullptr;
if (enc->containers == &enc->staticContainers[0])
memcpy(tmp, &enc->staticContainers[0], enc->containerCapacity * sizeof(*src));
@@ -276,7 +276,7 @@ static WinPrAsn1EncContainer* asn1enc_get_free_container(WinPrAsn1Encoder* enc,
enc->containerCapacity += 10;
}
if (enc->freeContainerIndex == enc->containerCapacity)
- return NULL;
+ return nullptr;
ret = &enc->containers[enc->freeContainerIndex];
*id = enc->freeContainerIndex;
@@ -333,11 +333,11 @@ static WinPrAsn1EncContainer* getAsn1Container(WinPrAsn1Encoder* enc, ContainerT
{
size_t ret = 0;
size_t chunkId = 0;
- WinPrAsn1EncContainer* container = NULL;
+ WinPrAsn1EncContainer* container = nullptr;
Asn1Chunk* chunk = asn1enc_get_free_chunk(enc, maxLen, FALSE, &chunkId);
if (!chunk)
- return NULL;
+ return nullptr;
container = asn1enc_get_free_container(enc, &ret);
container->containerType = ctype;
@@ -350,42 +350,42 @@ static WinPrAsn1EncContainer* getAsn1Container(WinPrAsn1Encoder* enc, ContainerT
BOOL WinPrAsn1EncAppContainer(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId)
{
WINPR_ASSERT_VALID_TAG(tagId);
- return getAsn1Container(enc, ASN1_CONTAINER_APP, tagId, FALSE, 6) != NULL;
+ return getAsn1Container(enc, ASN1_CONTAINER_APP, tagId, FALSE, 6) != nullptr;
}
BOOL WinPrAsn1EncSeqContainer(WinPrAsn1Encoder* enc)
{
- return getAsn1Container(enc, ASN1_CONTAINER_SEQ, 0, FALSE, 6) != NULL;
+ return getAsn1Container(enc, ASN1_CONTAINER_SEQ, 0, FALSE, 6) != nullptr;
}
BOOL WinPrAsn1EncSetContainer(WinPrAsn1Encoder* enc)
{
- return getAsn1Container(enc, ASN1_CONTAINER_SET, 0, FALSE, 6) != NULL;
+ return getAsn1Container(enc, ASN1_CONTAINER_SET, 0, FALSE, 6) != nullptr;
}
BOOL WinPrAsn1EncContextualSeqContainer(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId)
{
- return getAsn1Container(enc, ASN1_CONTAINER_SEQ, tagId, TRUE, 6 + 6) != NULL;
+ return getAsn1Container(enc, ASN1_CONTAINER_SEQ, tagId, TRUE, 6 + 6) != nullptr;
}
BOOL WinPrAsn1EncContextualSetContainer(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId)
{
- return getAsn1Container(enc, ASN1_CONTAINER_SET, tagId, TRUE, 6 + 6) != NULL;
+ return getAsn1Container(enc, ASN1_CONTAINER_SET, tagId, TRUE, 6 + 6) != nullptr;
}
BOOL WinPrAsn1EncContextualContainer(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId)
{
- return getAsn1Container(enc, ASN1_CONTAINER_CONTEXT_ONLY, tagId, TRUE, 6) != NULL;
+ return getAsn1Container(enc, ASN1_CONTAINER_CONTEXT_ONLY, tagId, TRUE, 6) != nullptr;
}
BOOL WinPrAsn1EncOctetStringContainer(WinPrAsn1Encoder* enc)
{
- return getAsn1Container(enc, ASN1_CONTAINER_OCTETSTRING, 0, FALSE, 6) != NULL;
+ return getAsn1Container(enc, ASN1_CONTAINER_OCTETSTRING, 0, FALSE, 6) != nullptr;
}
BOOL WinPrAsn1EncContextualOctetStringContainer(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId)
{
- return getAsn1Container(enc, ASN1_CONTAINER_OCTETSTRING, tagId, TRUE, 6 + 6) != NULL;
+ return getAsn1Container(enc, ASN1_CONTAINER_OCTETSTRING, tagId, TRUE, 6 + 6) != nullptr;
}
size_t WinPrAsn1EncEndContainer(WinPrAsn1Encoder* enc)
@@ -395,8 +395,8 @@ size_t WinPrAsn1EncEndContainer(WinPrAsn1Encoder* enc)
size_t innerHeaderBytes = 0;
size_t outerHeaderBytes = 0;
BYTE containerByte = 0;
- WinPrAsn1EncContainer* container = NULL;
- Asn1Chunk* chunk = NULL;
+ WinPrAsn1EncContainer* container = nullptr;
+ Asn1Chunk* chunk = nullptr;
wStream staticS;
wStream* s = &staticS;
@@ -479,8 +479,8 @@ size_t WinPrAsn1EncEndContainer(WinPrAsn1Encoder* enc)
static BOOL asn1_getWriteStream(WinPrAsn1Encoder* enc, size_t len, wStream* s)
{
- BYTE* dest = NULL;
- Asn1Chunk* chunk = asn1enc_get_free_chunk(enc, len, TRUE, NULL);
+ BYTE* dest = nullptr;
+ Asn1Chunk* chunk = asn1enc_get_free_chunk(enc, len, TRUE, nullptr);
if (!chunk)
return FALSE;
@@ -1114,7 +1114,7 @@ size_t WinPrAsn1DecReadIA5String(WinPrAsn1Decoder* dec, WinPrAsn1_IA5STRING* tar
WinPrAsn1_tag tag = 0;
size_t len = 0;
size_t ret = 0;
- WinPrAsn1_IA5STRING s = NULL;
+ WinPrAsn1_IA5STRING s = nullptr;
WINPR_ASSERT(dec);
WINPR_ASSERT(target);
@@ -1141,7 +1141,7 @@ size_t WinPrAsn1DecReadGeneralString(WinPrAsn1Decoder* dec, WinPrAsn1_STRING* ta
WinPrAsn1_tag tag = 0;
size_t len = 0;
size_t ret = 0;
- WinPrAsn1_IA5STRING s = NULL;
+ WinPrAsn1_IA5STRING s = nullptr;
WINPR_ASSERT(dec);
WINPR_ASSERT(target);
diff --git a/winpr/libwinpr/utils/cmdline.c b/winpr/libwinpr/utils/cmdline.c
index eb30a9c4c..f1e872e42 100644
--- a/winpr/libwinpr/utils/cmdline.c
+++ b/winpr/libwinpr/utils/cmdline.c
@@ -60,7 +60,7 @@ static void log_error_(DWORD flags, LPCSTR message, int index, WINPR_ATTR_UNUSED
if ((flags & COMMAND_LINE_SILENCE_PARSER) == 0)
{
const DWORD level = WLOG_ERROR;
- static wLog* log = NULL;
+ static wLog* log = nullptr;
if (!log)
log = WLog_Get(TAG);
@@ -83,7 +83,7 @@ static void log_comma_error_(const char* message, WINPR_ATTR_UNUSED const char*
const char* file, const char* fkt, size_t line)
{
const DWORD level = WLOG_ERROR;
- static wLog* log = NULL;
+ static wLog* log = nullptr;
if (!log)
log = WLog_Get(TAG);
@@ -106,12 +106,12 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
int status = 0;
int count = 0;
BOOL notescaped = FALSE;
- const char* sigil = NULL;
+ const char* sigil = nullptr;
size_t sigil_length = 0;
- char* keyword = NULL;
+ char* keyword = nullptr;
size_t keyword_index = 0;
- char* separator = NULL;
- char* value = NULL;
+ char* separator = nullptr;
+ char* value = nullptr;
int toggle = 0;
if (!argv)
@@ -230,7 +230,7 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
}
}
- separator = NULL;
+ separator = nullptr;
if ((flags & COMMAND_LINE_SEPARATOR_COLON) && (!separator))
separator = strchr(keyword, ':');
@@ -254,13 +254,13 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
}
keyword_length = length - keyword_index;
- value = NULL;
+ value = nullptr;
}
if (!escaped)
continue;
- for (size_t j = 0; options[j].Name != NULL; j++)
+ for (size_t j = 0; options[j].Name != nullptr; j++)
{
COMMAND_LINE_ARGUMENT_A* cur = &options[j];
BOOL match = FALSE;
@@ -271,7 +271,7 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
match = TRUE;
}
- if ((!match) && (cur->Alias != NULL))
+ if ((!match) && (cur->Alias != nullptr))
{
if (strncmp(cur->Alias, keyword, keyword_length) == 0)
{
@@ -319,7 +319,7 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
}
else if (!value_present && (cur->Flags & COMMAND_LINE_VALUE_OPTIONAL))
{
- value = NULL;
+ value = nullptr;
}
else if (!value_present && argument)
{
@@ -341,7 +341,7 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
if (value && (cur->Flags & COMMAND_LINE_VALUE_FLAG))
{
i--;
- value = NULL;
+ value = nullptr;
}
}
@@ -442,10 +442,10 @@ int CommandLineParseArgumentsW(WINPR_ATTR_UNUSED int argc, WINPR_ATTR_UNUSED LPW
int CommandLineClearArgumentsA(COMMAND_LINE_ARGUMENT_A* options)
{
- for (size_t i = 0; options[i].Name != NULL; i++)
+ for (size_t i = 0; options[i].Name != nullptr; i++)
{
options[i].Flags &= COMMAND_LINE_INPUT_FLAG_MASK;
- options[i].Value = NULL;
+ options[i].Value = nullptr;
}
return 0;
@@ -453,10 +453,10 @@ int CommandLineClearArgumentsA(COMMAND_LINE_ARGUMENT_A* options)
int CommandLineClearArgumentsW(COMMAND_LINE_ARGUMENT_W* options)
{
- for (int i = 0; options[i].Name != NULL; i++)
+ for (int i = 0; options[i].Name != nullptr; i++)
{
options[i].Flags &= COMMAND_LINE_INPUT_FLAG_MASK;
- options[i].Value = NULL;
+ options[i].Value = nullptr;
}
return 0;
@@ -468,19 +468,19 @@ const COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(const COMMAND_LINE_ARGUM
WINPR_ASSERT(options);
WINPR_ASSERT(Name);
- for (size_t i = 0; options[i].Name != NULL; i++)
+ for (size_t i = 0; options[i].Name != nullptr; i++)
{
if (strcmp(options[i].Name, Name) == 0)
return &options[i];
- if (options[i].Alias != NULL)
+ if (options[i].Alias != nullptr)
{
if (strcmp(options[i].Alias, Name) == 0)
return &options[i];
}
}
- return NULL;
+ return nullptr;
}
const COMMAND_LINE_ARGUMENT_W* CommandLineFindArgumentW(const COMMAND_LINE_ARGUMENT_W* options,
@@ -489,32 +489,32 @@ const COMMAND_LINE_ARGUMENT_W* CommandLineFindArgumentW(const COMMAND_LINE_ARGUM
WINPR_ASSERT(options);
WINPR_ASSERT(Name);
- for (size_t i = 0; options[i].Name != NULL; i++)
+ for (size_t i = 0; options[i].Name != nullptr; i++)
{
if (_wcscmp(options[i].Name, Name) == 0)
return &options[i];
- if (options[i].Alias != NULL)
+ if (options[i].Alias != nullptr)
{
if (_wcscmp(options[i].Alias, Name) == 0)
return &options[i];
}
}
- return NULL;
+ return nullptr;
}
const COMMAND_LINE_ARGUMENT_A* CommandLineFindNextArgumentA(const COMMAND_LINE_ARGUMENT_A* argument)
{
- const COMMAND_LINE_ARGUMENT_A* nextArgument = NULL;
+ const COMMAND_LINE_ARGUMENT_A* nextArgument = nullptr;
if (!argument || !argument->Name)
- return NULL;
+ return nullptr;
nextArgument = &argument[1];
- if (nextArgument->Name == NULL)
- return NULL;
+ if (nextArgument->Name == nullptr)
+ return nullptr;
return nextArgument;
}
@@ -634,7 +634,7 @@ static char* get_next_comma(char* string, BOOL fullquoted)
case '\0':
if (quoted != 0)
log_comma_error("Invalid quoted argument", log);
- return NULL;
+ return nullptr;
case '\\':
if (!escaped)
@@ -651,7 +651,7 @@ static char* get_next_comma(char* string, BOOL fullquoted)
if ((quoted == 0) && !first)
{
log_comma_error("Invalid quoted argument", log);
- return NULL;
+ return nullptr;
}
if (now == quoted)
quoted = 0;
@@ -664,7 +664,7 @@ static char* get_next_comma(char* string, BOOL fullquoted)
if (first)
{
log_comma_error("Invalid argument (empty list elements)", log);
- return NULL;
+ return nullptr;
}
if (quoted == 0)
return last;
@@ -675,8 +675,6 @@ static char* get_next_comma(char* string, BOOL fullquoted)
}
first = FALSE;
}
-
- return NULL;
}
static BOOL is_valid_fullquoted(const char* string)
@@ -714,19 +712,19 @@ static BOOL is_valid_fullquoted(const char* string)
char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list, size_t* count)
{
- char** p = NULL;
- char* str = NULL;
+ char** p = nullptr;
+ char* str = nullptr;
size_t nArgs = 0;
size_t prefix = 0;
size_t len = 0;
size_t namelen = 0;
BOOL failed = FALSE;
- char* copy = NULL;
- char* unquoted = NULL;
+ char* copy = nullptr;
+ char* unquoted = nullptr;
BOOL fullquoted = FALSE;
BOOL success = FALSE;
- if (count == NULL)
+ if (count == nullptr)
goto fail;
*count = 0;
@@ -858,19 +856,19 @@ fail:
if (count)
*count = 0;
free((void*)p);
- return NULL;
+ return nullptr;
}
return p;
}
char** CommandLineParseCommaSeparatedValues(const char* list, size_t* count)
{
- return CommandLineParseCommaSeparatedValuesEx(NULL, list, count);
+ return CommandLineParseCommaSeparatedValuesEx(nullptr, list, count);
}
char* CommandLineToCommaSeparatedValues(int argc, char* argv[])
{
- return CommandLineToCommaSeparatedValuesEx(argc, argv, NULL, 0);
+ return CommandLineToCommaSeparatedValuesEx(argc, argv, nullptr, 0);
}
static const char* filtered(const char* arg, const char* filters[], size_t number)
@@ -884,24 +882,24 @@ static const char* filtered(const char* arg, const char* filters[], size_t numbe
if (_strnicmp(arg, filter, len) == 0)
return &arg[len];
}
- return NULL;
+ return nullptr;
}
char* CommandLineToCommaSeparatedValuesEx(int argc, char* argv[], const char* filters[],
size_t number)
{
- char* str = NULL;
+ char* str = nullptr;
size_t offset = 0;
size_t size = WINPR_ASSERTING_INT_CAST(size_t, argc) + 1;
if ((argc <= 0) || !argv)
- return NULL;
+ return nullptr;
for (int x = 0; x < argc; x++)
size += strlen(argv[x]);
str = calloc(size, sizeof(char));
if (!str)
- return NULL;
+ return nullptr;
for (int x = 0; x < argc; x++)
{
int rc = 0;
@@ -912,7 +910,7 @@ char* CommandLineToCommaSeparatedValuesEx(int argc, char* argv[], const char* fi
if (rc <= 0)
{
free(str);
- return NULL;
+ return nullptr;
}
offset += (size_t)rc;
}
diff --git a/winpr/libwinpr/utils/collections/ArrayList.c b/winpr/libwinpr/utils/collections/ArrayList.c
index d0e872713..79d993ea4 100644
--- a/winpr/libwinpr/utils/collections/ArrayList.c
+++ b/winpr/libwinpr/utils/collections/ArrayList.c
@@ -152,7 +152,7 @@ void ArrayList_Unlock(wArrayList* arrayList)
void* ArrayList_GetItem(wArrayList* arrayList, size_t index)
{
- void* obj = NULL;
+ void* obj = nullptr;
WINPR_ASSERT(arrayList);
if (index < arrayList->size)
@@ -202,7 +202,7 @@ static BOOL ArrayList_EnsureCapacity(wArrayList* arrayList, size_t count)
if (arrayList->size + count > arrayList->capacity)
{
- void** newArray = NULL;
+ void** newArray = nullptr;
size_t newCapacity = arrayList->capacity * arrayList->growthFactor;
if (newCapacity < arrayList->size + count)
newCapacity = arrayList->size + count;
@@ -265,7 +265,7 @@ void ArrayList_Clear(wArrayList* arrayList)
if (arrayList->object.fnObjectFree)
arrayList->object.fnObjectFree(arrayList->array[index]);
- arrayList->array[index] = NULL;
+ arrayList->array[index] = nullptr;
}
arrayList->size = 0;
@@ -575,12 +575,12 @@ fail:
wArrayList* ArrayList_New(BOOL synchronized)
{
- wObject* obj = NULL;
- wArrayList* arrayList = NULL;
+ wObject* obj = nullptr;
+ wArrayList* arrayList = nullptr;
arrayList = (wArrayList*)calloc(1, sizeof(wArrayList));
if (!arrayList)
- return NULL;
+ return nullptr;
arrayList->synchronized = synchronized;
arrayList->growthFactor = 2;
@@ -598,7 +598,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
ArrayList_Free(arrayList);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
void ArrayList_Free(wArrayList* arrayList)
diff --git a/winpr/libwinpr/utils/collections/BufferPool.c b/winpr/libwinpr/utils/collections/BufferPool.c
index ae28a84cf..61dd01944 100644
--- a/winpr/libwinpr/utils/collections/BufferPool.c
+++ b/winpr/libwinpr/utils/collections/BufferPool.c
@@ -88,7 +88,7 @@ static BOOL BufferPool_ShiftAvailable(wBufferPool* pool, size_t index, int count
{
if (pool->aSize + count > pool->aCapacity)
{
- wBufferPoolItem* newArray = NULL;
+ wBufferPoolItem* newArray = nullptr;
SSIZE_T newCapacity = pool->aSize + count;
newCapacity += (newCapacity + 2) / 2;
@@ -141,7 +141,7 @@ static BOOL BufferPool_ShiftUsed(wBufferPool* pool, SSIZE_T index, SSIZE_T count
return FALSE;
newUCapacity += 128ll;
} while (newUCapacity <= required);
- wBufferPoolItem* newUArray = NULL;
+ wBufferPoolItem* newUArray = nullptr;
if (pool->alignment > 0)
newUArray = (wBufferPoolItem*)winpr_aligned_realloc(
pool->uArray,
@@ -243,7 +243,7 @@ void* BufferPool_Take(wBufferPool* pool, SSIZE_T size)
SSIZE_T maxIndex = 0;
SSIZE_T foundIndex = -1;
BOOL found = FALSE;
- void* buffer = NULL;
+ void* buffer = nullptr;
BufferPool_Lock(pool);
@@ -301,7 +301,7 @@ void* BufferPool_Take(wBufferPool* pool, SSIZE_T size)
if (!found)
{
if (!size)
- buffer = NULL;
+ buffer = nullptr;
else
{
if (pool->alignment)
@@ -320,7 +320,7 @@ void* BufferPool_Take(wBufferPool* pool, SSIZE_T size)
if (maxSize < size)
{
- void* newBuffer = NULL;
+ void* newBuffer = nullptr;
if (pool->alignment)
newBuffer = winpr_aligned_realloc(
buffer, WINPR_ASSERTING_INT_CAST(size_t, size), pool->alignment);
@@ -371,7 +371,7 @@ out_error:
free(buffer);
out_error_no_free:
BufferPool_Unlock(pool);
- return NULL;
+ return nullptr;
}
/**
@@ -508,7 +508,7 @@ void BufferPool_Clear(wBufferPool* pool)
wBufferPool* BufferPool_New(BOOL synchronized, SSIZE_T fixedSize, DWORD alignment)
{
- wBufferPool* pool = NULL;
+ wBufferPool* pool = nullptr;
pool = (wBufferPool*)calloc(1, sizeof(wBufferPool));
@@ -563,7 +563,7 @@ out_error:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
BufferPool_Free(pool);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
void BufferPool_Free(wBufferPool* pool)
diff --git a/winpr/libwinpr/utils/collections/CountdownEvent.c b/winpr/libwinpr/utils/collections/CountdownEvent.c
index 487f21e35..78aca504f 100644
--- a/winpr/libwinpr/utils/collections/CountdownEvent.c
+++ b/winpr/libwinpr/utils/collections/CountdownEvent.c
@@ -170,7 +170,7 @@ wCountdownEvent* CountdownEvent_New(size_t initialCount)
wCountdownEvent* countdown = (wCountdownEvent*)calloc(1, sizeof(wCountdownEvent));
if (!countdown)
- return NULL;
+ return nullptr;
countdown->count = initialCount;
countdown->initialCount = initialCount;
@@ -178,7 +178,7 @@ wCountdownEvent* CountdownEvent_New(size_t initialCount)
if (!InitializeCriticalSectionAndSpinCount(&countdown->lock, 4000))
goto fail;
- countdown->event = CreateEvent(NULL, TRUE, FALSE, NULL);
+ countdown->event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!countdown->event)
goto fail;
@@ -195,7 +195,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
CountdownEvent_Free(countdown);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
void CountdownEvent_Free(wCountdownEvent* countdown)
diff --git a/winpr/libwinpr/utils/collections/HashTable.c b/winpr/libwinpr/utils/collections/HashTable.c
index 35b0e4904..eab6f8437 100644
--- a/winpr/libwinpr/utils/collections/HashTable.c
+++ b/winpr/libwinpr/utils/collections/HashTable.c
@@ -139,8 +139,8 @@ static inline size_t HashTable_CalculateIdealNumOfBuckets(wHashTable* table)
static inline void HashTable_Rehash(wHashTable* table, size_t numOfBuckets)
{
UINT32 hashValue = 0;
- wKeyValuePair* nextPair = NULL;
- wKeyValuePair** newBucketArray = NULL;
+ wKeyValuePair* nextPair = nullptr;
+ wKeyValuePair** newBucketArray = nullptr;
WINPR_ASSERT(table);
if (numOfBuckets == 0)
@@ -190,11 +190,11 @@ static inline BOOL HashTable_Equals(wHashTable* table, const wKeyValuePair* pair
static inline wKeyValuePair* HashTable_Get(wHashTable* table, const void* key)
{
UINT32 hashValue = 0;
- wKeyValuePair* pair = NULL;
+ wKeyValuePair* pair = nullptr;
WINPR_ASSERT(table);
if (!key)
- return NULL;
+ return nullptr;
hashValue = table->hash(key) % table->numOfBuckets;
pair = table->bucketArray[hashValue];
@@ -308,8 +308,8 @@ BOOL HashTable_Insert(wHashTable* table, const void* key, const void* value)
{
BOOL rc = FALSE;
UINT32 hashValue = 0;
- wKeyValuePair* pair = NULL;
- wKeyValuePair* newPair = NULL;
+ wKeyValuePair* pair = nullptr;
+ wKeyValuePair* newPair = nullptr;
WINPR_ASSERT(table);
if (!key || !value)
@@ -384,8 +384,8 @@ BOOL HashTable_Remove(wHashTable* table, const void* key)
{
UINT32 hashValue = 0;
BOOL status = TRUE;
- wKeyValuePair* pair = NULL;
- wKeyValuePair* previousPair = NULL;
+ wKeyValuePair* pair = nullptr;
+ wKeyValuePair* previousPair = nullptr;
WINPR_ASSERT(table);
if (!key)
@@ -447,12 +447,12 @@ out:
void* HashTable_GetItemValue(wHashTable* table, const void* key)
{
- void* value = NULL;
- wKeyValuePair* pair = NULL;
+ void* value = nullptr;
+ wKeyValuePair* pair = nullptr;
WINPR_ASSERT(table);
if (!key)
- return NULL;
+ return nullptr;
if (table->synchronized)
EnterCriticalSection(&table->lock);
@@ -475,7 +475,7 @@ void* HashTable_GetItemValue(wHashTable* table, const void* key)
BOOL HashTable_SetItemValue(wHashTable* table, const void* key, const void* value)
{
BOOL status = TRUE;
- wKeyValuePair* pair = NULL;
+ wKeyValuePair* pair = nullptr;
WINPR_ASSERT(table);
if (!key)
@@ -505,7 +505,7 @@ BOOL HashTable_SetItemValue(wHashTable* table, const void* key, const void* valu
void HashTable_Clear(wHashTable* table)
{
- wKeyValuePair* nextPair = NULL;
+ wKeyValuePair* nextPair = nullptr;
WINPR_ASSERT(table);
@@ -533,7 +533,7 @@ void HashTable_Clear(wHashTable* table)
}
}
- table->bucketArray[index] = NULL;
+ table->bucketArray[index] = nullptr;
}
table->numOfElements = 0;
@@ -552,8 +552,8 @@ size_t HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys)
{
size_t iKey = 0;
size_t count = 0;
- ULONG_PTR* pKeys = NULL;
- wKeyValuePair* nextPair = NULL;
+ ULONG_PTR* pKeys = nullptr;
+ wKeyValuePair* nextPair = nullptr;
WINPR_ASSERT(table);
@@ -563,7 +563,7 @@ size_t HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys)
iKey = 0;
count = table->numOfElements;
if (ppKeys)
- *ppKeys = NULL;
+ *ppKeys = nullptr;
if (count < 1)
{
@@ -633,10 +633,10 @@ BOOL HashTable_Foreach(wHashTable* table, HASH_TABLE_FOREACH_FN fn, VOID* arg)
if (!table->foreachRecursionLevel && table->pendingRemoves)
{
/* if we're the last recursive foreach call, let's do the cleanup if needed */
- wKeyValuePair** prevPtr = NULL;
+ wKeyValuePair** prevPtr = nullptr;
for (size_t index = 0; index < table->numOfBuckets; index++)
{
- wKeyValuePair* nextPair = NULL;
+ wKeyValuePair* nextPair = nullptr;
prevPtr = &table->bucketArray[index];
for (wKeyValuePair* pair = table->bucketArray[index]; pair;)
{
@@ -670,7 +670,7 @@ out:
BOOL HashTable_Contains(wHashTable* table, const void* key)
{
BOOL status = 0;
- wKeyValuePair* pair = NULL;
+ wKeyValuePair* pair = nullptr;
WINPR_ASSERT(table);
if (!key)
@@ -695,7 +695,7 @@ BOOL HashTable_Contains(wHashTable* table, const void* key)
BOOL HashTable_ContainsKey(wHashTable* table, const void* key)
{
BOOL status = 0;
- wKeyValuePair* pair = NULL;
+ wKeyValuePair* pair = nullptr;
WINPR_ASSERT(table);
if (!key)
@@ -786,13 +786,13 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
HashTable_Free(table);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
void HashTable_Free(wHashTable* table)
{
- wKeyValuePair* pair = NULL;
- wKeyValuePair* nextPair = NULL;
+ wKeyValuePair* pair = nullptr;
+ wKeyValuePair* nextPair = nullptr;
if (!table)
return;
@@ -846,12 +846,12 @@ BOOL HashTable_SetHashFunction(wHashTable* table, HASH_TABLE_HASH_FN fn)
{
WINPR_ASSERT(table);
table->hash = fn;
- return fn != NULL;
+ return fn != nullptr;
}
BOOL HashTable_SetupForStringData(wHashTable* table, BOOL stringValues)
{
- wObject* obj = NULL;
+ wObject* obj = nullptr;
if (!HashTable_SetHashFunction(table, HashTable_StringHash))
return FALSE;
diff --git a/winpr/libwinpr/utils/collections/LinkedList.c b/winpr/libwinpr/utils/collections/LinkedList.c
index cdca11404..a4674dd99 100644
--- a/winpr/libwinpr/utils/collections/LinkedList.c
+++ b/winpr/libwinpr/utils/collections/LinkedList.c
@@ -72,7 +72,7 @@ void* LinkedList_First(wLinkedList* list)
if (list->head)
return list->head->value;
else
- return NULL;
+ return nullptr;
}
/**
@@ -85,7 +85,7 @@ void* LinkedList_Last(wLinkedList* list)
if (list->tail)
return list->tail->value;
else
- return NULL;
+ return nullptr;
}
/**
@@ -98,8 +98,8 @@ void* LinkedList_Last(wLinkedList* list)
BOOL LinkedList_Contains(wLinkedList* list, const void* value)
{
- wLinkedListNode* item = NULL;
- OBJECT_EQUALS_FN keyEquals = NULL;
+ wLinkedListNode* item = nullptr;
+ OBJECT_EQUALS_FN keyEquals = nullptr;
WINPR_ASSERT(list);
if (!list->head)
@@ -116,13 +116,13 @@ BOOL LinkedList_Contains(wLinkedList* list, const void* value)
item = item->next;
}
- return (item != NULL);
+ return (item != nullptr);
}
static wLinkedListNode* LinkedList_FreeNode(wLinkedList* list, wLinkedListNode* node)
{
- wLinkedListNode* next = NULL;
- wLinkedListNode* prev = NULL;
+ wLinkedListNode* next = nullptr;
+ wLinkedListNode* prev = nullptr;
WINPR_ASSERT(list);
WINPR_ASSERT(node);
@@ -158,7 +158,7 @@ static wLinkedListNode* LinkedList_FreeNode(wLinkedList* list, wLinkedListNode*
void LinkedList_Clear(wLinkedList* list)
{
- wLinkedListNode* node = NULL;
+ wLinkedListNode* node = nullptr;
WINPR_ASSERT(list);
if (!list->head)
return;
@@ -168,19 +168,19 @@ void LinkedList_Clear(wLinkedList* list)
while (node)
node = LinkedList_FreeNode(list, node);
- list->head = list->tail = NULL;
+ list->head = list->tail = nullptr;
list->count = 0;
}
static wLinkedListNode* LinkedList_Create(wLinkedList* list, const void* value)
{
- wLinkedListNode* node = NULL;
+ wLinkedListNode* node = nullptr;
WINPR_ASSERT(list);
node = (wLinkedListNode*)calloc(1, sizeof(wLinkedListNode));
if (!node)
- return NULL;
+ return nullptr;
if (list->object.fnObjectNew)
node->value = list->object.fnObjectNew(value);
@@ -258,8 +258,8 @@ BOOL LinkedList_AddLast(wLinkedList* list, const void* value)
BOOL LinkedList_Remove(wLinkedList* list, const void* value)
{
- wLinkedListNode* node = NULL;
- OBJECT_EQUALS_FN keyEquals = NULL;
+ wLinkedListNode* node = nullptr;
+ OBJECT_EQUALS_FN keyEquals = nullptr;
WINPR_ASSERT(list);
keyEquals = list->object.fnObjectEquals;
@@ -320,12 +320,12 @@ void* LinkedList_Enumerator_Current(wLinkedList* list)
{
WINPR_ASSERT(list);
if (list->initial)
- return NULL;
+ return nullptr;
if (list->current)
return list->current->value;
else
- return NULL;
+ return nullptr;
}
/*
@@ -357,7 +357,7 @@ static BOOL default_equal_function(const void* objA, const void* objB)
wLinkedList* LinkedList_New(void)
{
- wLinkedList* list = NULL;
+ wLinkedList* list = nullptr;
list = (wLinkedList*)calloc(1, sizeof(wLinkedList));
if (list)
diff --git a/winpr/libwinpr/utils/collections/ListDictionary.c b/winpr/libwinpr/utils/collections/ListDictionary.c
index b4846e307..4d9749a28 100644
--- a/winpr/libwinpr/utils/collections/ListDictionary.c
+++ b/winpr/libwinpr/utils/collections/ListDictionary.c
@@ -128,7 +128,7 @@ void ListDictionary_Unlock(wListDictionary* listDictionary)
size_t ListDictionary_GetKeys(wListDictionary* listDictionary, ULONG_PTR** ppKeys)
{
- ULONG_PTR* pKeys = NULL;
+ ULONG_PTR* pKeys = nullptr;
WINPR_ASSERT(listDictionary);
if (!ppKeys)
@@ -217,7 +217,7 @@ static wListDictionaryItem* new_item(wListDictionary* listDictionary, const void
{
wListDictionaryItem* item = (wListDictionaryItem*)calloc(1, sizeof(wListDictionaryItem));
if (!item)
- return NULL;
+ return nullptr;
if (listDictionary->objectKey.fnObjectNew)
item->key = listDictionary->objectKey.fnObjectNew(key);
@@ -234,7 +234,7 @@ static wListDictionaryItem* new_item(wListDictionary* listDictionary, const void
fail:
item_free(listDictionary, item);
- return NULL;
+ return nullptr;
}
/**
@@ -284,8 +284,8 @@ out_error:
void ListDictionary_Clear(wListDictionary* listDictionary)
{
- wListDictionaryItem* item = NULL;
- wListDictionaryItem* nextItem = NULL;
+ wListDictionaryItem* item = nullptr;
+ wListDictionaryItem* nextItem = nullptr;
WINPR_ASSERT(listDictionary);
@@ -304,7 +304,7 @@ void ListDictionary_Clear(wListDictionary* listDictionary)
item = nextItem;
}
- listDictionary->head = NULL;
+ listDictionary->head = nullptr;
}
if (listDictionary->synchronized)
@@ -317,8 +317,8 @@ void ListDictionary_Clear(wListDictionary* listDictionary)
BOOL ListDictionary_Contains(wListDictionary* listDictionary, const void* key)
{
- wListDictionaryItem* item = NULL;
- OBJECT_EQUALS_FN keyEquals = NULL;
+ wListDictionaryItem* item = nullptr;
+ OBJECT_EQUALS_FN keyEquals = nullptr;
WINPR_ASSERT(listDictionary);
@@ -339,7 +339,7 @@ BOOL ListDictionary_Contains(wListDictionary* listDictionary, const void* key)
if (listDictionary->synchronized)
ListDictionary_Unlock(listDictionary);
- return (item != NULL);
+ return (item != nullptr);
}
/**
@@ -349,10 +349,10 @@ BOOL ListDictionary_Contains(wListDictionary* listDictionary, const void* key)
static void* ListDictionary_RemoveOrTake(wListDictionary* listDictionary, const void* key,
BOOL take)
{
- void* value = NULL;
- wListDictionaryItem* item = NULL;
- wListDictionaryItem* prevItem = NULL;
- OBJECT_EQUALS_FN keyEquals = NULL;
+ void* value = nullptr;
+ wListDictionaryItem* item = nullptr;
+ wListDictionaryItem* prevItem = nullptr;
+ OBJECT_EQUALS_FN keyEquals = nullptr;
WINPR_ASSERT(listDictionary);
@@ -361,7 +361,7 @@ static void* ListDictionary_RemoveOrTake(wListDictionary* listDictionary, const
keyEquals = listDictionary->objectKey.fnObjectEquals;
item = listDictionary->head;
- prevItem = NULL;
+ prevItem = nullptr;
while (item)
{
@@ -375,7 +375,7 @@ static void* ListDictionary_RemoveOrTake(wListDictionary* listDictionary, const
if (take)
{
value = item->value;
- item->value = NULL;
+ item->value = nullptr;
}
item_free(listDictionary, item);
break;
@@ -407,8 +407,8 @@ void* ListDictionary_Take(wListDictionary* listDictionary, const void* key)
static void* ListDictionary_Remove_Or_Take_Head(wListDictionary* listDictionary, BOOL take)
{
- wListDictionaryItem* item = NULL;
- void* value = NULL;
+ wListDictionaryItem* item = nullptr;
+ void* value = nullptr;
WINPR_ASSERT(listDictionary);
@@ -422,7 +422,7 @@ static void* ListDictionary_Remove_Or_Take_Head(wListDictionary* listDictionary,
if (take)
{
value = item->value;
- item->value = NULL;
+ item->value = nullptr;
}
item_free(listDictionary, item);
}
@@ -449,9 +449,9 @@ void* ListDictionary_Take_Head(wListDictionary* listDictionary)
void* ListDictionary_GetItemValue(wListDictionary* listDictionary, const void* key)
{
- void* value = NULL;
- wListDictionaryItem* item = NULL;
- OBJECT_EQUALS_FN keyEquals = NULL;
+ void* value = nullptr;
+ wListDictionaryItem* item = nullptr;
+ OBJECT_EQUALS_FN keyEquals = nullptr;
WINPR_ASSERT(listDictionary);
@@ -473,7 +473,7 @@ void* ListDictionary_GetItemValue(wListDictionary* listDictionary, const void* k
}
}
- value = (item) ? item->value : NULL;
+ value = (item) ? item->value : nullptr;
if (listDictionary->synchronized)
ListDictionary_Unlock(listDictionary);
@@ -489,8 +489,8 @@ BOOL ListDictionary_SetItemValue(wListDictionary* listDictionary, const void* ke
const void* value)
{
BOOL status = FALSE;
- wListDictionaryItem* item = NULL;
- OBJECT_EQUALS_FN keyEquals = NULL;
+ wListDictionaryItem* item = nullptr;
+ OBJECT_EQUALS_FN keyEquals = nullptr;
WINPR_ASSERT(listDictionary);
@@ -514,7 +514,7 @@ BOOL ListDictionary_SetItemValue(wListDictionary* listDictionary, const void* ke
if (item)
item_set(listDictionary, item, value);
- status = (item != NULL);
+ status = (item != nullptr);
}
if (listDictionary->synchronized)
@@ -536,14 +536,14 @@ wListDictionary* ListDictionary_New(BOOL synchronized)
wListDictionary* listDictionary = (wListDictionary*)calloc(1, sizeof(wListDictionary));
if (!listDictionary)
- return NULL;
+ return nullptr;
listDictionary->synchronized = synchronized;
if (!InitializeCriticalSectionAndSpinCount(&(listDictionary->lock), 4000))
{
free(listDictionary);
- return NULL;
+ return nullptr;
}
listDictionary->objectKey.fnObjectEquals = default_equal_function;
diff --git a/winpr/libwinpr/utils/collections/MessagePipe.c b/winpr/libwinpr/utils/collections/MessagePipe.c
index 98adfe753..0266f6e3a 100644
--- a/winpr/libwinpr/utils/collections/MessagePipe.c
+++ b/winpr/libwinpr/utils/collections/MessagePipe.c
@@ -44,18 +44,18 @@ void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode)
wMessagePipe* MessagePipe_New(void)
{
- wMessagePipe* pipe = NULL;
+ wMessagePipe* pipe = nullptr;
pipe = (wMessagePipe*)malloc(sizeof(wMessagePipe));
if (!pipe)
- return NULL;
+ return nullptr;
- pipe->In = MessageQueue_New(NULL);
+ pipe->In = MessageQueue_New(nullptr);
if (!pipe->In)
goto error_in;
- pipe->Out = MessageQueue_New(NULL);
+ pipe->Out = MessageQueue_New(nullptr);
if (!pipe->Out)
goto error_out;
@@ -65,7 +65,7 @@ error_out:
MessageQueue_Free(pipe->In);
error_in:
free(pipe);
- return NULL;
+ return nullptr;
}
void MessagePipe_Free(wMessagePipe* pipe)
diff --git a/winpr/libwinpr/utils/collections/MessageQueue.c b/winpr/libwinpr/utils/collections/MessageQueue.c
index 3c87237b5..5f16f93c1 100644
--- a/winpr/libwinpr/utils/collections/MessageQueue.c
+++ b/winpr/libwinpr/utils/collections/MessageQueue.c
@@ -163,7 +163,7 @@ static BOOL MessageQueue_EnsureCapacity(wMessageQueue* queue, size_t count)
BOOL MessageQueue_Dispatch(wMessageQueue* queue, const wMessage* message)
{
- wMessage* dst = NULL;
+ wMessage* dst = nullptr;
BOOL ret = FALSE;
WINPR_ASSERT(queue);
@@ -206,14 +206,14 @@ BOOL MessageQueue_Post(wMessageQueue* queue, void* context, UINT32 type, void* w
message.id = type;
message.wParam = wParam;
message.lParam = lParam;
- message.Free = NULL;
+ message.Free = nullptr;
return MessageQueue_Dispatch(queue, &message);
}
BOOL MessageQueue_PostQuit(wMessageQueue* queue, int nExitCode)
{
- return MessageQueue_Post(queue, NULL, WMQ_QUIT, (void*)(size_t)nExitCode, NULL);
+ return MessageQueue_Post(queue, nullptr, WMQ_QUIT, (void*)(size_t)nExitCode, nullptr);
}
int MessageQueue_Get(wMessageQueue* queue, wMessage* message)
@@ -277,11 +277,11 @@ int MessageQueue_Peek(wMessageQueue* queue, wMessage* message, BOOL remove)
wMessageQueue* MessageQueue_New(const wObject* callback)
{
- wMessageQueue* queue = NULL;
+ wMessageQueue* queue = nullptr;
queue = (wMessageQueue*)calloc(1, sizeof(wMessageQueue));
if (!queue)
- return NULL;
+ return nullptr;
if (!InitializeCriticalSectionAndSpinCount(&queue->lock, 4000))
goto fail;
@@ -289,7 +289,7 @@ wMessageQueue* MessageQueue_New(const wObject* callback)
if (!MessageQueue_EnsureCapacity(queue, 32))
goto fail;
- queue->event = CreateEvent(NULL, TRUE, FALSE, NULL);
+ queue->event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!queue->event)
goto fail;
@@ -303,7 +303,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
MessageQueue_Free(queue);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
void MessageQueue_Free(wMessageQueue* queue)
diff --git a/winpr/libwinpr/utils/collections/Object.c b/winpr/libwinpr/utils/collections/Object.c
index 8bee86c04..b32598547 100644
--- a/winpr/libwinpr/utils/collections/Object.c
+++ b/winpr/libwinpr/utils/collections/Object.c
@@ -24,7 +24,7 @@ void* winpr_ObjectStringClone(const void* pvstr)
{
const char* str = pvstr;
if (!str)
- return NULL;
+ return nullptr;
return _strdup(str);
}
@@ -32,7 +32,7 @@ void* winpr_ObjectWStringClone(const void* pvstr)
{
const WCHAR* str = pvstr;
if (!str)
- return NULL;
+ return nullptr;
return _wcsdup(str);
}
diff --git a/winpr/libwinpr/utils/collections/ObjectPool.c b/winpr/libwinpr/utils/collections/ObjectPool.c
index 4e6efd260..b2a6fa7af 100644
--- a/winpr/libwinpr/utils/collections/ObjectPool.c
+++ b/winpr/libwinpr/utils/collections/ObjectPool.c
@@ -63,7 +63,7 @@ static void ObjectPool_Unlock(wObjectPool* pool)
void* ObjectPool_Take(wObjectPool* pool)
{
- void* obj = NULL;
+ void* obj = nullptr;
ObjectPool_Lock(pool);
@@ -73,7 +73,7 @@ void* ObjectPool_Take(wObjectPool* pool)
if (!obj)
{
if (pool->object.fnObjectNew)
- obj = pool->object.fnObjectNew(NULL);
+ obj = pool->object.fnObjectNew(nullptr);
}
if (pool->object.fnObjectInit)
@@ -151,7 +151,7 @@ void ObjectPool_Clear(wObjectPool* pool)
wObjectPool* ObjectPool_New(BOOL synchronized)
{
- wObjectPool* pool = NULL;
+ wObjectPool* pool = nullptr;
pool = (wObjectPool*)calloc(1, sizeof(wObjectPool));
@@ -163,7 +163,7 @@ wObjectPool* ObjectPool_New(BOOL synchronized)
if (!pool->array)
{
free(pool);
- return NULL;
+ return nullptr;
}
pool->synchronized = synchronized;
diff --git a/winpr/libwinpr/utils/collections/PubSub.c b/winpr/libwinpr/utils/collections/PubSub.c
index 35ec2281a..d96b0b21a 100644
--- a/winpr/libwinpr/utils/collections/PubSub.c
+++ b/winpr/libwinpr/utils/collections/PubSub.c
@@ -71,7 +71,7 @@ void PubSub_Unlock(wPubSub* pubSub)
wEventType* PubSub_FindEventType(wPubSub* pubSub, const char* EventName)
{
- wEventType* event = NULL;
+ wEventType* event = nullptr;
WINPR_ASSERT(pubSub);
WINPR_ASSERT(EventName);
@@ -123,7 +123,7 @@ fail:
int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, ...)
{
- wEventType* event = NULL;
+ wEventType* event = nullptr;
int status = -1;
WINPR_ASSERT(pubSub);
@@ -155,7 +155,7 @@ int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, ...)
int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...)
{
- wEventType* event = NULL;
+ wEventType* event = nullptr;
int status = -1;
WINPR_ASSERT(pubSub);
WINPR_ASSERT(EventName);
@@ -177,7 +177,7 @@ int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...)
{
if (event->EventHandlers[index] == EventHandler)
{
- event->EventHandlers[index] = NULL;
+ event->EventHandlers[index] = nullptr;
event->EventHandlerCount--;
MoveMemory((void*)&event->EventHandlers[index],
(void*)&event->EventHandlers[index + 1],
@@ -196,7 +196,7 @@ int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...)
int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, const wEventArgs* e)
{
- wEventType* event = NULL;
+ wEventType* event = nullptr;
int status = -1;
if (!pubSub)
@@ -237,7 +237,7 @@ wPubSub* PubSub_New(BOOL synchronized)
wPubSub* pubSub = (wPubSub*)calloc(1, sizeof(wPubSub));
if (!pubSub)
- return NULL;
+ return nullptr;
pubSub->synchronized = synchronized;
@@ -257,7 +257,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
PubSub_Free(pubSub);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
void PubSub_Free(wPubSub* pubSub)
diff --git a/winpr/libwinpr/utils/collections/Queue.c b/winpr/libwinpr/utils/collections/Queue.c
index c487ff173..50c08e5a0 100644
--- a/winpr/libwinpr/utils/collections/Queue.c
+++ b/winpr/libwinpr/utils/collections/Queue.c
@@ -292,7 +292,7 @@ out:
void* Queue_Dequeue(wQueue* queue)
{
- void* obj = NULL;
+ void* obj = nullptr;
Queue_Lock(queue);
@@ -318,7 +318,7 @@ void* Queue_Dequeue(wQueue* queue)
void* Queue_Peek(wQueue* queue)
{
- void* obj = NULL;
+ void* obj = nullptr;
Queue_Lock(queue);
if (queue->size > 0)
@@ -331,7 +331,7 @@ void* Queue_Peek(wQueue* queue)
void Queue_Discard(wQueue* queue)
{
- void* obj = NULL;
+ void* obj = nullptr;
Queue_Lock(queue);
obj = Queue_Dequeue(queue);
@@ -355,7 +355,7 @@ wQueue* Queue_New(BOOL synchronized, SSIZE_T capacity, SSIZE_T growthFactor)
wQueue* queue = (wQueue*)calloc(1, sizeof(wQueue));
if (!queue)
- return NULL;
+ return nullptr;
queue->synchronized = synchronized;
@@ -371,7 +371,7 @@ wQueue* Queue_New(BOOL synchronized, SSIZE_T capacity, SSIZE_T growthFactor)
if (!Queue_EnsureCapacity(queue, (size_t)capacity))
goto fail;
- queue->event = CreateEvent(NULL, TRUE, FALSE, NULL);
+ queue->event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
if (!queue->event)
goto fail;
@@ -386,7 +386,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
Queue_Free(queue);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
void Queue_Free(wQueue* queue)
diff --git a/winpr/libwinpr/utils/collections/Stack.c b/winpr/libwinpr/utils/collections/Stack.c
index 1f041d5bc..4327c809d 100644
--- a/winpr/libwinpr/utils/collections/Stack.c
+++ b/winpr/libwinpr/utils/collections/Stack.c
@@ -95,7 +95,7 @@ void Stack_Clear(wStack* stack)
if (stack->object.fnObjectFree)
stack->object.fnObjectFree(stack->array[index]);
- stack->array[index] = NULL;
+ stack->array[index] = nullptr;
}
stack->size = 0;
@@ -172,7 +172,7 @@ end:
void* Stack_Pop(wStack* stack)
{
- void* obj = NULL;
+ void* obj = nullptr;
WINPR_ASSERT(stack);
if (stack->synchronized)
@@ -193,7 +193,7 @@ void* Stack_Pop(wStack* stack)
void* Stack_Peek(wStack* stack)
{
- void* obj = NULL;
+ void* obj = nullptr;
WINPR_ASSERT(stack);
if (stack->synchronized)
@@ -219,11 +219,11 @@ static BOOL default_stack_equals(const void* obj1, const void* obj2)
wStack* Stack_New(BOOL synchronized)
{
- wStack* stack = NULL;
+ wStack* stack = nullptr;
stack = (wStack*)calloc(1, sizeof(wStack));
if (!stack)
- return NULL;
+ return nullptr;
stack->object.fnObjectEquals = default_stack_equals;
stack->synchronized = synchronized;
@@ -242,7 +242,7 @@ out_free:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
Stack_Free(stack);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
void Stack_Free(wStack* stack)
diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c
index 0c5fb6b65..b9533deda 100644
--- a/winpr/libwinpr/utils/collections/StreamPool.c
+++ b/winpr/libwinpr/utils/collections/StreamPool.c
@@ -123,7 +123,7 @@ static BOOL StreamPool_EnsureCapacity(wStreamPool* pool, size_t count, BOOL used
if (new_cap > 0)
{
- struct s_StreamPoolEntry* new_arr = NULL;
+ struct s_StreamPoolEntry* new_arr = nullptr;
if (*cap < *size + count)
*cap += count;
@@ -218,7 +218,7 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size)
{
BOOL found = FALSE;
size_t foundIndex = 0;
- wStream* s = NULL;
+ wStream* s = nullptr;
StreamPool_Lock(pool);
@@ -240,7 +240,7 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size)
if (!found)
{
- s = Stream_New(NULL, size);
+ s = Stream_New(nullptr, size);
if (!s)
goto out_fail;
}
@@ -335,7 +335,7 @@ void Stream_Release(wStream* s)
wStream* StreamPool_Find(wStreamPool* pool, const BYTE* ptr)
{
- wStream* s = NULL;
+ wStream* s = nullptr;
StreamPool_Lock(pool);
@@ -400,7 +400,7 @@ size_t StreamPool_UsedCount(wStreamPool* pool)
wStreamPool* StreamPool_New(BOOL synchronized, size_t defaultSize)
{
- wStreamPool* pool = NULL;
+ wStreamPool* pool = nullptr;
pool = (wStreamPool*)calloc(1, sizeof(wStreamPool));
@@ -423,7 +423,7 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
StreamPool_Free(pool);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
void StreamPool_Free(wStreamPool* pool)
@@ -446,7 +446,7 @@ char* StreamPool_GetStatistics(wStreamPool* pool, char* buffer, size_t size)
WINPR_ASSERT(pool);
if (!buffer || (size < 1))
- return NULL;
+ return nullptr;
size_t used = 0;
int offset = _snprintf(buffer, size - 1,
diff --git a/winpr/libwinpr/utils/corkscrew/backtrace.h b/winpr/libwinpr/utils/corkscrew/backtrace.h
index 408f9880e..32004a005 100644
--- a/winpr/libwinpr/utils/corkscrew/backtrace.h
+++ b/winpr/libwinpr/utils/corkscrew/backtrace.h
@@ -48,9 +48,9 @@ extern "C"
or the absolute PC if the library is unknown */
uintptr_t relative_symbol_addr; /* relative offset of the symbol from the start of the
library or 0 if the library is unknown */
- char* map_name; /* executable or library name, or NULL if unknown */
- char* symbol_name; /* symbol name, or NULL if unknown */
- char* demangled_name; /* demangled symbol name, or NULL if unknown */
+ char* map_name; /* executable or library name, or nullptr if unknown */
+ char* symbol_name; /* symbol name, or nullptr if unknown */
+ char* demangled_name; /* demangled symbol name, or nullptr if unknown */
} backtrace_symbol_t;
/*
diff --git a/winpr/libwinpr/utils/corkscrew/debug.c b/winpr/libwinpr/utils/corkscrew/debug.c
index 0fc2fd6ed..2656a3916 100644
--- a/winpr/libwinpr/utils/corkscrew/debug.c
+++ b/winpr/libwinpr/utils/corkscrew/debug.c
@@ -96,7 +96,7 @@ typedef struct
} t_corkscrew;
static pthread_once_t initialized = PTHREAD_ONCE_INIT;
-static t_corkscrew* fkt = NULL;
+static t_corkscrew* fkt = nullptr;
void load_library(void)
{
@@ -174,7 +174,7 @@ fail:
if (lib.hdl)
dlclose(lib.hdl);
- fkt = NULL;
+ fkt = nullptr;
}
}
@@ -193,14 +193,14 @@ void* winpr_corkscrew_backtrace(DWORD size)
t_corkscrew_data* data = calloc(1, sizeof(t_corkscrew_data));
if (!data)
- return NULL;
+ return nullptr;
data->buffer = calloc(size, sizeof(backtrace_frame_t));
if (!data->buffer)
{
free(data);
- return NULL;
+ return nullptr;
}
pthread_once(&initialized, load_library);
@@ -216,14 +216,14 @@ char** winpr_corkscrew_backtrace_symbols(void* buffer, size_t* used)
*used = 0;
if (!data)
- return NULL;
+ return nullptr;
pthread_once(&initialized, load_library);
if (!fkt)
{
LOGF(support_msg);
- return NULL;
+ return nullptr;
}
else
{
@@ -237,7 +237,7 @@ char** winpr_corkscrew_backtrace_symbols(void* buffer, size_t* used)
{
free(vlines);
free(symbols);
- return NULL;
+ return nullptr;
}
/* Set the pointers in the allocated buffer's initial array section */
diff --git a/winpr/libwinpr/utils/corkscrew/demangle.h b/winpr/libwinpr/utils/corkscrew/demangle.h
index 75c01d7bf..a736d5bf6 100644
--- a/winpr/libwinpr/utils/corkscrew/demangle.h
+++ b/winpr/libwinpr/utils/corkscrew/demangle.h
@@ -29,7 +29,7 @@ extern "C"
/*
* Demangles a C++ symbol name.
- * If name is NULL or if the name cannot be demangled, returns NULL.
+ * If name is nullptr or if the name cannot be demangled, returns nullptr.
* Otherwise, returns a newly allocated string that contains the demangled name.
*
* The caller must free the returned string using free().
diff --git a/winpr/libwinpr/utils/corkscrew/map_info.h b/winpr/libwinpr/utils/corkscrew/map_info.h
index dc2275e38..6c363890e 100644
--- a/winpr/libwinpr/utils/corkscrew/map_info.h
+++ b/winpr/libwinpr/utils/corkscrew/map_info.h
@@ -36,7 +36,7 @@ extern "C"
bool is_readable;
bool is_writable;
bool is_executable;
- void* data; // arbitrary data associated with the map by the user, initially NULL
+ void* data; // arbitrary data associated with the map by the user, initially nullptr
char name[];
} map_info_t;
diff --git a/winpr/libwinpr/utils/corkscrew/ptrace.h b/winpr/libwinpr/utils/corkscrew/ptrace.h
index 8ff75753e..0b61aba1a 100644
--- a/winpr/libwinpr/utils/corkscrew/ptrace.h
+++ b/winpr/libwinpr/utils/corkscrew/ptrace.h
@@ -127,7 +127,7 @@ extern "C"
/*
* Finds a symbol using ptrace.
* Returns the containing map and information about the symbol, or
- * NULL if one or the other is not available.
+ * nullptr if one or the other is not available.
*/
void find_symbol_ptrace(const ptrace_context_t* context, uintptr_t addr,
const map_info_t** out_map_info, const symbol_t** out_symbol);
diff --git a/winpr/libwinpr/utils/corkscrew/symbol_table.h b/winpr/libwinpr/utils/corkscrew/symbol_table.h
index 380e17dce..b2106b976 100644
--- a/winpr/libwinpr/utils/corkscrew/symbol_table.h
+++ b/winpr/libwinpr/utils/corkscrew/symbol_table.h
@@ -40,7 +40,7 @@ extern "C"
/*
* Loads a symbol table from a given file.
- * Returns NULL on error.
+ * Returns nullptr on error.
*/
symbol_table_t* load_symbol_table(const char* filename);
@@ -51,7 +51,7 @@ extern "C"
/*
* Finds a symbol associated with an address in the symbol table.
- * Returns NULL if not found.
+ * Returns nullptr if not found.
*/
const symbol_t* find_symbol(const symbol_table_t* table, uintptr_t addr);
diff --git a/winpr/libwinpr/utils/debug.c b/winpr/libwinpr/utils/debug.c
index 5d6a337b3..ff57e1da4 100644
--- a/winpr/libwinpr/utils/debug.c
+++ b/winpr/libwinpr/utils/debug.c
@@ -93,7 +93,7 @@ void* winpr_backtrace(DWORD size)
return winpr_win_backtrace(size);
#else
WLog_FATAL(TAG, "%s", support_msg);
- /* return a non NULL buffer to allow the backtrace function family to succeed without failing
+ /* return a non nullptr buffer to allow the backtrace function family to succeed without failing
*/
return strndup(support_msg, sizeof(support_msg));
#endif
@@ -107,7 +107,7 @@ char** winpr_backtrace_symbols(void* buffer, size_t* used)
if (!buffer)
{
WLog_FATAL(TAG, "%s", support_msg);
- return NULL;
+ return nullptr;
}
#if defined(USE_UNWIND)
@@ -130,7 +130,7 @@ char** winpr_backtrace_symbols(void* buffer, size_t* used)
size_t len = strnlen(support_msg, sizeof(support_msg));
char* ppmsg = calloc(sizeof(char*) + len + 1, sizeof(char));
if (!ppmsg)
- return NULL;
+ return nullptr;
char** msgptr = (char**)ppmsg;
char* msg = &ppmsg[sizeof(char*)];
@@ -176,7 +176,7 @@ void winpr_log_backtrace(const char* tag, DWORD level, DWORD size)
void winpr_log_backtrace_ex(wLog* log, DWORD level, WINPR_ATTR_UNUSED DWORD size)
{
size_t used = 0;
- char** msg = NULL;
+ char** msg = nullptr;
void* stack = winpr_backtrace(20);
if (!stack)
diff --git a/winpr/libwinpr/utils/execinfo/debug.c b/winpr/libwinpr/utils/execinfo/debug.c
index 5f76dc480..f6990913b 100644
--- a/winpr/libwinpr/utils/execinfo/debug.c
+++ b/winpr/libwinpr/utils/execinfo/debug.c
@@ -48,14 +48,14 @@ void* winpr_execinfo_backtrace(DWORD size)
t_execinfo* data = calloc(1, sizeof(t_execinfo));
if (!data)
- return NULL;
+ return nullptr;
data->buffer = (void**)calloc(size, sizeof(void*));
if (!data->buffer)
{
free(data);
- return NULL;
+ return nullptr;
}
assert(size <= INT32_MAX);
@@ -63,7 +63,7 @@ void* winpr_execinfo_backtrace(DWORD size)
if (rc < 0)
{
free(data);
- return NULL;
+ return nullptr;
}
data->max = size;
data->used = (size_t)rc;
@@ -77,7 +77,7 @@ char** winpr_execinfo_backtrace_symbols(void* buffer, size_t* used)
*used = 0;
if (!data)
- return NULL;
+ return nullptr;
if (used)
*used = data->used;
diff --git a/winpr/libwinpr/utils/image.c b/winpr/libwinpr/utils/image.c
index 6332eeaa9..ed2db0008 100644
--- a/winpr/libwinpr/utils/image.c
+++ b/winpr/libwinpr/utils/image.c
@@ -77,7 +77,7 @@ BOOL writeBitmapFileHeader(wStream* s, const WINPR_BITMAP_FILE_HEADER* bf)
BOOL readBitmapFileHeader(wStream* s, WINPR_BITMAP_FILE_HEADER* bf)
{
- static wLog* log = NULL;
+ static wLog* log = nullptr;
if (!log)
log = WLog_Get(TAG);
@@ -198,7 +198,7 @@ BOOL readBitmapInfoHeader(wStream* s, WINPR_BITMAP_INFO_HEADER* bi, size_t* poff
BYTE* winpr_bitmap_construct_header(size_t width, size_t height, size_t bpp)
{
- BYTE* result = NULL;
+ BYTE* result = nullptr;
WINPR_BITMAP_FILE_HEADER bf = WINPR_C_ARRAY_INIT;
WINPR_BITMAP_INFO_HEADER bi = WINPR_C_ARRAY_INIT;
@@ -208,11 +208,11 @@ BYTE* winpr_bitmap_construct_header(size_t width, size_t height, size_t bpp)
size_t imgSize = stride * height;
if ((width > INT32_MAX) || (height > INT32_MAX) || (bpp > UINT16_MAX) || (imgSize > UINT32_MAX))
- return NULL;
+ return nullptr;
- wStream* s = Stream_New(NULL, WINPR_IMAGE_BMP_HEADER_LEN);
+ wStream* s = Stream_New(nullptr, WINPR_IMAGE_BMP_HEADER_LEN);
if (!s)
- return NULL;
+ return nullptr;
bf.bfType[0] = 'B';
bf.bfType[1] = 'M';
@@ -248,7 +248,7 @@ BYTE* winpr_bitmap_construct_header(size_t width, size_t height, size_t bpp)
offset += sizeof(DWORD) * 3; // 3 DWORD color masks
break;
default:
- return NULL;
+ return nullptr;
}
if (!writeBitmapFileHeader(s, &bf))
@@ -263,7 +263,7 @@ BYTE* winpr_bitmap_construct_header(size_t width, size_t height, size_t bpp)
Stream_Zero(s, offset);
result = Stream_Buffer(s);
fail:
- Stream_Free(s, result == 0);
+ Stream_Free(s, result == nullptr);
return result;
}
@@ -279,15 +279,15 @@ static void* winpr_bitmap_write_buffer(const BYTE* data, WINPR_ATTR_UNUSED size_
{
WINPR_ASSERT(data || (size == 0));
- void* result = NULL;
+ void* result = nullptr;
size_t bpp_stride = 1ull * width * (bpp / 8);
if ((bpp_stride % 4) != 0)
bpp_stride += 4 - (bpp_stride % 4);
if (bpp_stride > UINT32_MAX)
- return NULL;
+ return nullptr;
- wStream* s = Stream_New(NULL, 1024);
+ wStream* s = Stream_New(nullptr, 1024);
if (stride == 0)
stride = (UINT32)bpp_stride;
@@ -318,7 +318,7 @@ static void* winpr_bitmap_write_buffer(const BYTE* data, WINPR_ATTR_UNUSED size_
*pSize = (UINT32)pos;
}
fail:
- Stream_Free(s, result == NULL);
+ Stream_Free(s, result == nullptr);
free(bmp_header);
return result;
}
@@ -332,9 +332,9 @@ int winpr_bitmap_write(const char* filename, const BYTE* data, size_t width, siz
int winpr_bitmap_write_ex(const char* filename, const BYTE* data, size_t stride, size_t width,
size_t height, size_t bpp)
{
- FILE* fp = NULL;
+ FILE* fp = nullptr;
int ret = -1;
- void* bmpdata = NULL;
+ void* bmpdata = nullptr;
const size_t bpp_stride = ((((width * bpp) + 31) & (size_t)~31) >> 3);
if ((stride > UINT32_MAX) || (width > UINT32_MAX) || (height > UINT32_MAX) ||
@@ -502,7 +502,7 @@ static int winpr_image_bitmap_read_buffer(wImage* image, const BYTE* buffer, siz
scanline = uscanline;
}
- image->data = NULL;
+ image->data = nullptr;
{
const size_t asize = 1ULL * image->scanline * image->height;
if (asize > 0)
@@ -544,7 +544,7 @@ fail:
if (rc < 0)
{
free(image->data);
- image->data = NULL;
+ image->data = nullptr;
}
return rc;
@@ -646,7 +646,7 @@ wImage* winpr_image_new(void)
wImage* image = (wImage*)calloc(1, sizeof(wImage));
if (!image)
- return NULL;
+ return nullptr;
return image;
}
@@ -674,9 +674,9 @@ static void* winpr_convert_to_jpeg(WINPR_ATTR_UNUSED const void* data,
#if !defined(WINPR_UTILS_IMAGE_JPEG)
WLog_WARN(TAG, "JPEG not supported in this build");
- return NULL;
+ return nullptr;
#else
- BYTE* outbuffer = NULL;
+ BYTE* outbuffer = nullptr;
unsigned long outsize = 0;
struct jpeg_compress_struct cinfo = WINPR_C_ARRAY_INIT;
@@ -684,9 +684,9 @@ static void* winpr_convert_to_jpeg(WINPR_ATTR_UNUSED const void* data,
const size_t bytes = (bpp + 7) / 8;
const size_t expect2 = 1ull * width * height * bytes;
if (expect1 < expect2)
- return NULL;
+ return nullptr;
if (expect1 > size)
- return NULL;
+ return nullptr;
/* Set up the error handler. */
struct jpeg_error_mgr jerr = WINPR_C_ARRAY_INIT;
@@ -753,7 +753,7 @@ SSIZE_T winpr_convert_from_jpeg(WINPR_ATTR_UNUSED const BYTE* comp_data,
struct jpeg_decompress_struct cinfo = WINPR_C_ARRAY_INIT;
struct jpeg_error_mgr jerr;
SSIZE_T size = -1;
- BYTE* decomp_data = NULL;
+ BYTE* decomp_data = nullptr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
@@ -811,10 +811,10 @@ static void* winpr_convert_to_webp(WINPR_ATTR_UNUSED const void* data,
#if !defined(WINPR_UTILS_IMAGE_WEBP)
WLog_WARN(TAG, "WEBP not supported in this build");
- return NULL;
+ return nullptr;
#else
size_t dstSize = 0;
- uint8_t* pDstData = NULL;
+ uint8_t* pDstData = nullptr;
WINPR_ASSERT(width <= INT32_MAX);
WINPR_ASSERT(height <= INT32_MAX);
WINPR_ASSERT(stride <= INT32_MAX);
@@ -827,7 +827,7 @@ static void* winpr_convert_to_webp(WINPR_ATTR_UNUSED const void* data,
dstSize = WebPEncodeLosslessBGR(data, (int)width, (int)height, (int)stride, &pDstData);
break;
default:
- return NULL;
+ return nullptr;
}
void* rc = malloc(dstSize);
@@ -856,7 +856,7 @@ SSIZE_T winpr_convert_from_webp(WINPR_ATTR_UNUSED const BYTE* comp_data,
*width = 0;
*height = 0;
*bpp = 0;
- *ppdecomp_data = NULL;
+ *ppdecomp_data = nullptr;
#if !defined(WINPR_UTILS_IMAGE_WEBP)
WLog_WARN(TAG, "WEBP not supported in this build");
return -1;
@@ -920,12 +920,12 @@ static SSIZE_T save_png_to_buffer(UINT32 bpp, UINT32 width, uint32_t stride, UIN
const uint8_t* data, size_t size, void** pDstData)
{
SSIZE_T rc = -1;
- png_structp png_ptr = NULL;
- png_infop info_ptr = NULL;
- png_byte** row_pointers = NULL;
+ png_structp png_ptr = nullptr;
+ png_infop info_ptr = nullptr;
+ png_byte** row_pointers = nullptr;
struct png_mem_encode state = WINPR_C_ARRAY_INIT;
- *pDstData = NULL;
+ *pDstData = nullptr;
if (!data || (size == 0))
return 0;
@@ -936,13 +936,13 @@ static SSIZE_T save_png_to_buffer(UINT32 bpp, UINT32 width, uint32_t stride, UIN
goto fail;
/* Initialize the write struct. */
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (png_ptr == NULL)
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
+ if (png_ptr == nullptr)
goto fail;
/* Initialize the info struct. */
info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL)
+ if (info_ptr == nullptr)
goto fail;
/* Set up error handling. */
@@ -984,7 +984,7 @@ static SSIZE_T save_png_to_buffer(UINT32 bpp, UINT32 width, uint32_t stride, UIN
/* Actually write the image data. */
png_set_write_fn(png_ptr, &state, png_write_data, png_flush);
png_set_rows(png_ptr, info_ptr, row_pointers);
- png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, NULL);
+ png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, nullptr);
/* Cleanup. */
for (size_t y = 0; y < height; y++)
@@ -1025,7 +1025,7 @@ static void read_data_memory(png_structp png_ptr, png_bytep data, size_t length)
static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t* pSize,
UINT32* pWidth, UINT32* pHeight, UINT32* pBpp)
{
- void* rc = NULL;
+ void* rc = nullptr;
png_uint_32 width = 0;
png_uint_32 height = 0;
int bit_depth = 0;
@@ -1033,12 +1033,12 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t
int interlace_type = 0;
int transforms = PNG_TRANSFORM_IDENTITY;
MEMORY_READER_STATE memory_reader_state = WINPR_C_ARRAY_INIT;
- png_bytepp row_pointers = NULL;
- png_infop info_ptr = NULL;
+ png_bytepp row_pointers = nullptr;
+ png_infop info_ptr = nullptr;
if (SrcSize > UINT32_MAX)
- return NULL;
+ return nullptr;
- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!png_ptr)
goto fail;
info_ptr = png_create_info_struct(png_ptr);
@@ -1052,10 +1052,10 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t
png_set_read_fn(png_ptr, &memory_reader_state, read_data_memory);
transforms |= PNG_TRANSFORM_BGR;
- png_read_png(png_ptr, info_ptr, transforms, NULL);
+ png_read_png(png_ptr, info_ptr, transforms, nullptr);
if (png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type,
- NULL, NULL) != 1)
+ nullptr, nullptr) != 1)
goto fail;
WINPR_ASSERT(bit_depth >= 0);
@@ -1088,7 +1088,7 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t
}
fail:
- png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
return rc;
}
#endif
@@ -1104,15 +1104,15 @@ static void* winpr_convert_to_png(WINPR_ATTR_UNUSED const void* data, WINPR_ATTR
*pSize = 0;
#if defined(WINPR_UTILS_IMAGE_PNG)
- void* dst = NULL;
+ void* dst = nullptr;
SSIZE_T rc = save_png_to_buffer(bpp, width, stride, height, data, size, &dst);
if (rc <= 0)
- return NULL;
+ return nullptr;
*pSize = (UINT32)rc;
return dst;
#elif defined(WITH_LODEPNG)
{
- BYTE* dst = NULL;
+ BYTE* dst = nullptr;
size_t dstsize = 0;
unsigned rc = 1;
@@ -1128,13 +1128,13 @@ static void* winpr_convert_to_png(WINPR_ATTR_UNUSED const void* data, WINPR_ATTR
break;
}
if (rc)
- return NULL;
+ return nullptr;
*pSize = (UINT32)dstsize;
return dst;
}
#else
WLog_WARN(TAG, "PNG not supported in this build");
- return NULL;
+ return nullptr;
#endif
}
@@ -1188,7 +1188,7 @@ static BYTE* convert(const wImage* image, size_t* pstride, WINPR_ATTR_UNUSED UIN
*pstride = 0;
if (image->bitsPerPixel < 24)
- return NULL;
+ return nullptr;
const size_t stride = image->width * 4ull;
BYTE* data = calloc(stride, image->height);
@@ -1321,7 +1321,7 @@ const char* winpr_image_format_mime(UINT32 format)
case WINPR_IMAGE_JPEG:
return "image/jpeg";
default:
- return NULL;
+ return nullptr;
}
}
@@ -1338,7 +1338,7 @@ const char* winpr_image_format_extension(UINT32 format)
case WINPR_IMAGE_JPEG:
return "jpg";
default:
- return NULL;
+ return nullptr;
}
}
@@ -1385,6 +1385,6 @@ void* winpr_image_write_buffer(wImage* image, UINT32 format, size_t* psize)
}
default:
*psize = 0;
- return NULL;
+ return nullptr;
}
}
diff --git a/winpr/libwinpr/utils/ini.c b/winpr/libwinpr/utils/ini.c
index 9633735df..735fb1aa9 100644
--- a/winpr/libwinpr/utils/ini.c
+++ b/winpr/libwinpr/utils/ini.c
@@ -80,10 +80,10 @@ static BOOL IniFile_Load_NextLine(wIniFile* ini, char* str)
}
if (length < 1)
- ini->nextLine = NULL;
+ ini->nextLine = nullptr;
}
- return (ini->nextLine != NULL);
+ return (ini->nextLine != nullptr);
}
static BOOL IniFile_BufferResize(wIniFile* ini, size_t size)
@@ -112,8 +112,8 @@ static BOOL IniFile_Load_String(wIniFile* ini, const char* iniString)
if (!iniString)
return FALSE;
- ini->line = NULL;
- ini->nextLine = NULL;
+ ini->line = nullptr;
+ ini->nextLine = nullptr;
fileSize = strlen(iniString);
if (fileSize < 1)
@@ -139,7 +139,7 @@ static FILE* IniFile_Open_File(wIniFile* ini, const char* filename)
WINPR_ASSERT(ini);
if (!filename)
- return NULL;
+ return nullptr;
if (ini->readOnly)
return winpr_fopen(filename, "rb");
@@ -168,8 +168,8 @@ static BOOL IniFile_Load_File(wIniFile* ini, const char* filename)
if (_fseeki64(fp, 0, SEEK_SET) < 0)
goto out_file;
- ini->line = NULL;
- ini->nextLine = NULL;
+ ini->line = nullptr;
+ ini->nextLine = nullptr;
if (fileSize < 1)
goto out_file;
@@ -195,7 +195,7 @@ static BOOL IniFile_Load_HasNextLine(wIniFile* ini)
{
WINPR_ASSERT(ini);
- return (ini->nextLine != NULL);
+ return (ini->nextLine != nullptr);
}
static char* IniFile_Load_GetNextLine(wIniFile* ini)
@@ -204,7 +204,7 @@ static char* IniFile_Load_GetNextLine(wIniFile* ini)
ini->line = ini->nextLine;
ini->lineLength = strlen(ini->line);
- IniFile_Load_NextLine(ini, NULL);
+ IniFile_Load_NextLine(ini, nullptr);
return ini->line;
}
@@ -221,7 +221,7 @@ static void IniFile_Key_Free(wIniFileKey* key)
static wIniFileKey* IniFile_Key_New(const char* name, const char* value)
{
if (!name || !value)
- return NULL;
+ return nullptr;
wIniFileKey* key = calloc(1, sizeof(wIniFileKey));
@@ -233,7 +233,7 @@ static wIniFileKey* IniFile_Key_New(const char* name, const char* value)
if (!key->name || !key->value)
{
IniFile_Key_Free(key);
- return NULL;
+ return nullptr;
}
}
@@ -280,7 +280,7 @@ static BOOL IniFile_SectionKeysResize(wIniFileSection* section, size_t count)
static wIniFileSection* IniFile_Section_New(const char* name)
{
if (!name)
- return NULL;
+ return nullptr;
wIniFileSection* section = calloc(1, sizeof(wIniFileSection));
@@ -299,17 +299,17 @@ static wIniFileSection* IniFile_Section_New(const char* name)
fail:
IniFile_Section_Free(section);
- return NULL;
+ return nullptr;
}
static wIniFileSection* IniFile_GetSection(wIniFile* ini, const char* name)
{
- wIniFileSection* section = NULL;
+ wIniFileSection* section = nullptr;
WINPR_ASSERT(ini);
if (!name)
- return NULL;
+ return nullptr;
for (size_t index = 0; index < ini->nSections; index++)
{
@@ -349,18 +349,18 @@ static wIniFileSection* IniFile_AddToSection(wIniFile* ini, const char* name)
WINPR_ASSERT(ini);
if (!name)
- return NULL;
+ return nullptr;
wIniFileSection* section = IniFile_GetSection(ini, name);
if (!section)
{
if (!IniFile_SectionResize(ini, 1))
- return NULL;
+ return nullptr;
section = IniFile_Section_New(name);
if (!section)
- return NULL;
+ return nullptr;
ini->sections[ini->nSections++] = section;
}
@@ -369,12 +369,12 @@ static wIniFileSection* IniFile_AddToSection(wIniFile* ini, const char* name)
static wIniFileKey* IniFile_GetKey(wIniFileSection* section, const char* name)
{
- wIniFileKey* key = NULL;
+ wIniFileKey* key = nullptr;
WINPR_ASSERT(section);
if (!name)
- return NULL;
+ return nullptr;
for (size_t index = 0; index < section->nKeys; index++)
{
@@ -393,19 +393,19 @@ static wIniFileKey* IniFile_AddKey(wIniFileSection* section, const char* name, c
WINPR_ASSERT(section);
if (!name || !value)
- return NULL;
+ return nullptr;
wIniFileKey* key = IniFile_GetKey(section, name);
if (!key)
{
if (!IniFile_SectionKeysResize(section, 1))
- return NULL;
+ return nullptr;
key = IniFile_Key_New(name, value);
if (!key)
- return NULL;
+ return nullptr;
section->keys[section->nKeys++] = key;
}
@@ -415,7 +415,7 @@ static wIniFileKey* IniFile_AddKey(wIniFileSection* section, const char* name, c
key->value = _strdup(value);
if (!key->value)
- return NULL;
+ return nullptr;
}
return key;
@@ -423,12 +423,12 @@ static wIniFileKey* IniFile_AddKey(wIniFileSection* section, const char* name, c
static int IniFile_Load(wIniFile* ini)
{
- char* name = NULL;
- char* value = NULL;
- char* separator = NULL;
- char* beg = NULL;
- char* end = NULL;
- wIniFileSection* section = NULL;
+ char* name = nullptr;
+ char* value = nullptr;
+ char* separator = nullptr;
+ char* beg = nullptr;
+ char* end = nullptr;
+ wIniFileSection* section = nullptr;
WINPR_ASSERT(ini);
@@ -455,7 +455,7 @@ static int IniFile_Load(wIniFile* ini)
{
separator = strchr(line, '=');
- if (separator == NULL)
+ if (separator == nullptr)
return -1;
end = separator;
@@ -495,12 +495,12 @@ static BOOL IniFile_SetFilename(wIniFile* ini, const char* name)
{
WINPR_ASSERT(ini);
free(ini->filename);
- ini->filename = NULL;
+ ini->filename = nullptr;
if (!name)
return TRUE;
ini->filename = _strdup(name);
- return ini->filename != NULL;
+ return ini->filename != nullptr;
}
int IniFile_ReadBuffer(wIniFile* ini, const char* buffer)
@@ -542,10 +542,10 @@ char** IniFile_GetSectionNames(wIniFile* ini, size_t* count)
WINPR_ASSERT(ini);
if (!count)
- return NULL;
+ return nullptr;
if (ini->nSections > INT_MAX)
- return NULL;
+ return nullptr;
size_t length = (sizeof(char*) * ini->nSections) + sizeof(char);
@@ -559,7 +559,7 @@ char** IniFile_GetSectionNames(wIniFile* ini, size_t* count)
char** sectionNames = (char**)calloc(length, sizeof(char*));
if (!sectionNames)
- return NULL;
+ return nullptr;
char* p = (char*)&((BYTE*)sectionNames)[sizeof(char*) * ini->nSections];
@@ -582,15 +582,15 @@ char** IniFile_GetSectionKeyNames(wIniFile* ini, const char* section, size_t* co
WINPR_ASSERT(ini);
if (!section || !count)
- return NULL;
+ return nullptr;
wIniFileSection* pSection = IniFile_GetSection(ini, section);
if (!pSection)
- return NULL;
+ return nullptr;
if (pSection->nKeys > INT_MAX)
- return NULL;
+ return nullptr;
size_t length = (sizeof(char*) * pSection->nKeys) + sizeof(char);
@@ -604,7 +604,7 @@ char** IniFile_GetSectionKeyNames(wIniFile* ini, const char* section, size_t* co
char** keyNames = (char**)calloc(length, sizeof(char*));
if (!keyNames)
- return NULL;
+ return nullptr;
char* p = (char*)&((BYTE*)keyNames)[sizeof(char*) * pSection->nKeys];
@@ -624,21 +624,21 @@ char** IniFile_GetSectionKeyNames(wIniFile* ini, const char* section, size_t* co
const char* IniFile_GetKeyValueString(wIniFile* ini, const char* section, const char* key)
{
- const char* value = NULL;
- wIniFileKey* pKey = NULL;
- wIniFileSection* pSection = NULL;
+ const char* value = nullptr;
+ wIniFileKey* pKey = nullptr;
+ wIniFileSection* pSection = nullptr;
WINPR_ASSERT(ini);
pSection = IniFile_GetSection(ini, section);
if (!pSection)
- return NULL;
+ return nullptr;
pKey = IniFile_GetKey(pSection, key);
if (!pKey)
- return NULL;
+ return nullptr;
value = (const char*)pKey->value;
return value;
@@ -648,8 +648,8 @@ int IniFile_GetKeyValueInt(wIniFile* ini, const char* section, const char* key)
{
int err = 0;
long value = 0;
- wIniFileKey* pKey = NULL;
- wIniFileSection* pSection = NULL;
+ wIniFileKey* pKey = nullptr;
+ wIniFileSection* pSection = nullptr;
WINPR_ASSERT(ini);
@@ -665,7 +665,7 @@ int IniFile_GetKeyValueInt(wIniFile* ini, const char* section, const char* key)
err = errno;
errno = 0;
- value = strtol(pKey->value, NULL, 0);
+ value = strtol(pKey->value, nullptr, 0);
if ((value < INT_MIN) || (value > INT_MAX) || (errno != 0))
{
errno = err;
@@ -677,7 +677,7 @@ int IniFile_GetKeyValueInt(wIniFile* ini, const char* section, const char* key)
int IniFile_SetKeyValueString(wIniFile* ini, const char* section, const char* key,
const char* value)
{
- wIniFileKey* pKey = NULL;
+ wIniFileKey* pKey = nullptr;
WINPR_ASSERT(ini);
wIniFileSection* pSection = IniFile_GetSection(ini, section);
@@ -699,8 +699,8 @@ int IniFile_SetKeyValueString(wIniFile* ini, const char* section, const char* ke
int IniFile_SetKeyValueInt(wIniFile* ini, const char* section, const char* key, int value)
{
char strVal[128] = WINPR_C_ARRAY_INIT;
- wIniFileKey* pKey = NULL;
- wIniFileSection* pSection = NULL;
+ wIniFileKey* pKey = nullptr;
+ wIniFileSection* pSection = nullptr;
WINPR_ASSERT(ini);
@@ -725,7 +725,7 @@ char* IniFile_WriteBuffer(wIniFile* ini)
{
size_t offset = 0;
size_t size = 0;
- char* buffer = NULL;
+ char* buffer = nullptr;
WINPR_ASSERT(ini);
@@ -747,7 +747,7 @@ char* IniFile_WriteBuffer(wIniFile* ini)
buffer = calloc(size + 1, sizeof(char));
if (!buffer)
- return NULL;
+ return nullptr;
offset = 0;
@@ -808,7 +808,7 @@ void IniFile_Free(wIniFile* ini)
if (!ini)
return;
- IniFile_SetFilename(ini, NULL);
+ IniFile_SetFilename(ini, nullptr);
for (size_t index = 0; index < ini->nSections; index++)
IniFile_Section_Free(ini->sections[index]);
@@ -835,13 +835,13 @@ fail:
WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
IniFile_Free(ini);
WINPR_PRAGMA_DIAG_POP
- return NULL;
+ return nullptr;
}
wIniFile* IniFile_Clone(const wIniFile* ini)
{
if (!ini)
- return NULL;
+ return nullptr;
wIniFile* copy = IniFile_New();
if (!copy)
@@ -883,5 +883,5 @@ wIniFile* IniFile_Clone(const wIniFile* ini)
fail:
IniFile_Free(copy);
- return NULL;
+ return nullptr;
}
diff --git a/winpr/libwinpr/utils/json/c-json.c b/winpr/libwinpr/utils/json/c-json.c
index 31cea51fa..0ca9143ce 100644
--- a/winpr/libwinpr/utils/json/c-json.c
+++ b/winpr/libwinpr/utils/json/c-json.c
@@ -57,11 +57,11 @@ static double cJSON_GetNumberValue(const cJSON* prop)
return NAN;
errno = 0;
- char* endptr = NULL;
+ char* endptr = nullptr;
double dval = strtod(val, &endptr);
if (val == endptr)
return NAN;
- if (endptr != NULL)
+ if (endptr != nullptr)
return NAN;
if (errno != 0)
return NAN;
@@ -79,7 +79,7 @@ static cJSON* cJSON_ParseWithLength(const char* value, size_t buffer_length)
if (slen >= buffer_length)
{
if (value[buffer_length] != '\0')
- return NULL;
+ return nullptr;
}
return cJSON_Parse(value);
}
@@ -279,7 +279,7 @@ WINPR_JSON* WINPR_JSON_AddObjectToObject(WINPR_JSON* object, const char* name)
BOOL WINPR_JSON_AddItemToArray(WINPR_JSON* array, WINPR_JSON* item)
{
#if defined(USE_CJSON_COMPAT)
- if ((array == NULL) || (item == NULL))
+ if ((array == nullptr) || (item == nullptr))
return FALSE;
cJSON_AddItemToArray((cJSON*)array, (cJSON*)item);
return TRUE;
diff --git a/winpr/libwinpr/utils/json/jansson.c b/winpr/libwinpr/utils/json/jansson.c
index 686213231..f75642f2d 100644
--- a/winpr/libwinpr/utils/json/jansson.c
+++ b/winpr/libwinpr/utils/json/jansson.c
@@ -41,7 +41,7 @@ static const json_t* ccast_(const WINPR_JSON* json, const char* fkt)
{
const json_t* jansson = (const json_t*)json;
if (!jansson)
- WLog_DBG(TAG, "%s: NULL", fkt);
+ WLog_DBG(TAG, "%s: nullptr", fkt);
else
{
WLog_DBG(TAG, "%s: %" PRIuz, fkt, jansson->refcount);
@@ -54,7 +54,7 @@ static json_t* cast_(WINPR_JSON* json, const char* fkt)
{
json_t* jansson = (json_t*)json;
if (!jansson)
- WLog_DBG(TAG, "%s: NULL", fkt);
+ WLog_DBG(TAG, "%s: nullptr", fkt);
else
{
WLog_DBG(TAG, "%s: %" PRIuz, fkt, jansson->refcount);
@@ -67,7 +67,7 @@ static WINPR_JSON* revcast_(json_t* json, const char* fkt)
{
json_t* jansson = (json_t*)json;
if (!jansson)
- WLog_DBG(TAG, "%s: NULL", fkt);
+ WLog_DBG(TAG, "%s: nullptr", fkt);
else
{
WLog_DBG(TAG, "%s: %" PRIuz, fkt, jansson->refcount);
@@ -115,7 +115,7 @@ WINPR_JSON* WINPR_JSON_Parse(const char* value)
WINPR_JSON* WINPR_JSON_ParseWithLength(const char* value, size_t buffer_length)
{
if (!value || (buffer_length == 0))
- return NULL;
+ return nullptr;
json_error_t error = WINPR_C_ARRAY_INIT;
const size_t slen = strnlen(value, buffer_length);
@@ -149,7 +149,7 @@ WINPR_JSON* WINPR_JSON_GetObjectItem(const WINPR_JSON* object, const char* strin
return revcast(json_object_iter_value(it));
it = json_object_iter_next(json, it);
}
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON* object, const char* string)
@@ -159,7 +159,7 @@ WINPR_JSON* WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON* object, cons
BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON* object, const char* string)
{
- return json_object_get(ccast(object), string) != NULL;
+ return json_object_get(ccast(object), string) != nullptr;
}
const char* WINPR_JSON_GetErrorPtr(void)
@@ -278,10 +278,10 @@ WINPR_JSON* WINPR_JSON_CreateObject(void)
static WINPR_JSON* add_to_object(WINPR_JSON* object, const char* name, json_t* obj)
{
if (!obj)
- return NULL;
+ return nullptr;
const int rc = json_object_set_new(cast(object), name, obj);
if (rc != 0)
- return NULL;
+ return nullptr;
return revcast(obj);
}
diff --git a/winpr/libwinpr/utils/json/json-c.c b/winpr/libwinpr/utils/json/json-c.c
index df1d2a590..f0246d631 100644
--- a/winpr/libwinpr/utils/json/json-c.c
+++ b/winpr/libwinpr/utils/json/json-c.c
@@ -33,7 +33,7 @@
#if JSON_C_MINOR_VERSION < 14
static struct json_object* json_object_new_null(void)
{
- return NULL;
+ return nullptr;
}
#endif
#endif
@@ -53,7 +53,7 @@ WINPR_JSON* WINPR_JSON_ParseWithLength(const char* value, size_t buffer_length)
WINPR_ASSERT(buffer_length <= INT_MAX);
json_tokener* tok = json_tokener_new();
if (!tok)
- return NULL;
+ return nullptr;
json_object* obj = json_tokener_parse_ex(tok, value, (int)buffer_length);
json_tokener_free(tok);
return obj;
@@ -87,7 +87,7 @@ WINPR_JSON* WINPR_JSON_GetObjectItem(const WINPR_JSON* object, const char* strin
}
json_object_iter_next(&it);
}
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON* object, const char* string)
@@ -97,7 +97,7 @@ WINPR_JSON* WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON* object, cons
BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON* object, const char* string)
{
- return json_object_object_get_ex((const json_object*)object, string, NULL);
+ return json_object_object_get_ex((const json_object*)object, string, nullptr);
}
const char* WINPR_JSON_GetErrorPtr(void)
@@ -225,7 +225,7 @@ WINPR_JSON* WINPR_JSON_AddNullToObject(WINPR_JSON* object, const char* name)
if (json_object_object_add((json_object*)object, name, obj) != 0)
{
json_object_put(obj);
- return NULL;
+ return nullptr;
}
return obj;
}
@@ -236,7 +236,7 @@ WINPR_JSON* WINPR_JSON_AddTrueToObject(WINPR_JSON* object, const char* name)
if (json_object_object_add((json_object*)object, name, obj) != 0)
{
json_object_put(obj);
- return NULL;
+ return nullptr;
}
return obj;
}
@@ -247,7 +247,7 @@ WINPR_JSON* WINPR_JSON_AddFalseToObject(WINPR_JSON* object, const char* name)
if (json_object_object_add((json_object*)object, name, obj) != 0)
{
json_object_put(obj);
- return NULL;
+ return nullptr;
}
return obj;
}
@@ -258,7 +258,7 @@ WINPR_JSON* WINPR_JSON_AddBoolToObject(WINPR_JSON* object, const char* name, BOO
if (json_object_object_add((json_object*)object, name, obj) != 0)
{
json_object_put(obj);
- return NULL;
+ return nullptr;
}
return obj;
}
@@ -269,7 +269,7 @@ WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name, d
if (json_object_object_add((json_object*)object, name, obj) != 0)
{
json_object_put(obj);
- return NULL;
+ return nullptr;
}
return obj;
}
@@ -280,7 +280,7 @@ WINPR_JSON* WINPR_JSON_AddIntegerToObject(WINPR_JSON* object, const char* name,
if (json_object_object_add((json_object*)object, name, obj) != 0)
{
json_object_put(obj);
- return NULL;
+ return nullptr;
}
return obj;
}
@@ -291,7 +291,7 @@ WINPR_JSON* WINPR_JSON_AddStringToObject(WINPR_JSON* object, const char* name, c
if (json_object_object_add((json_object*)object, name, obj) != 0)
{
json_object_put(obj);
- return NULL;
+ return nullptr;
}
return obj;
}
@@ -302,7 +302,7 @@ WINPR_JSON* WINPR_JSON_AddObjectToObject(WINPR_JSON* object, const char* name)
if (json_object_object_add((json_object*)object, name, obj) != 0)
{
json_object_put(obj);
- return NULL;
+ return nullptr;
}
return obj;
}
@@ -321,7 +321,7 @@ WINPR_JSON* WINPR_JSON_AddArrayToObject(WINPR_JSON* object, const char* name)
if (json_object_object_add((json_object*)object, name, obj) != 0)
{
json_object_put(obj);
- return NULL;
+ return nullptr;
}
return obj;
}
@@ -330,7 +330,7 @@ char* WINPR_JSON_Print(WINPR_JSON* item)
{
const char* str = json_object_to_json_string_ext((json_object*)item, JSON_C_TO_STRING_PRETTY);
if (!str)
- return NULL;
+ return nullptr;
return _strdup(str);
}
@@ -338,6 +338,6 @@ char* WINPR_JSON_PrintUnformatted(WINPR_JSON* item)
{
const char* str = json_object_to_json_string_ext((json_object*)item, JSON_C_TO_STRING_PLAIN);
if (!str)
- return NULL;
+ return nullptr;
return _strdup(str);
}
diff --git a/winpr/libwinpr/utils/json/json-stub.c b/winpr/libwinpr/utils/json/json-stub.c
index cb4bad1f8..90d2d4686 100644
--- a/winpr/libwinpr/utils/json/json-stub.c
+++ b/winpr/libwinpr/utils/json/json-stub.c
@@ -33,14 +33,14 @@ int WINPR_JSON_version(char* buffer, size_t len)
WINPR_JSON* WINPR_JSON_Parse(const char* value)
{
WINPR_UNUSED(value);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_ParseWithLength(const char* value, size_t buffer_length)
{
WINPR_UNUSED(value);
WINPR_UNUSED(buffer_length);
- return NULL;
+ return nullptr;
}
void WINPR_JSON_Delete(WINPR_JSON* item)
@@ -52,7 +52,7 @@ WINPR_JSON* WINPR_JSON_GetArrayItem(const WINPR_JSON* array, size_t index)
{
WINPR_UNUSED(array);
WINPR_UNUSED(index);
- return NULL;
+ return nullptr;
}
size_t WINPR_JSON_GetArraySize(const WINPR_JSON* array)
@@ -65,14 +65,14 @@ WINPR_JSON* WINPR_JSON_GetObjectItem(const WINPR_JSON* object, const char* strin
{
WINPR_UNUSED(object);
WINPR_UNUSED(string);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON* object, const char* string)
{
WINPR_UNUSED(object);
WINPR_UNUSED(string);
- return NULL;
+ return nullptr;
}
BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON* object, const char* string)
@@ -84,13 +84,13 @@ BOOL WINPR_JSON_HasObjectItem(const WINPR_JSON* object, const char* string)
const char* WINPR_JSON_GetErrorPtr(void)
{
- return NULL;
+ return nullptr;
}
const char* WINPR_JSON_GetStringValue(WINPR_JSON* item)
{
WINPR_UNUSED(item);
- return NULL;
+ return nullptr;
}
double WINPR_JSON_GetNumberValue(const WINPR_JSON* item)
@@ -155,66 +155,66 @@ BOOL WINPR_JSON_IsObject(const WINPR_JSON* item)
WINPR_JSON* WINPR_JSON_CreateNull(void)
{
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_CreateTrue(void)
{
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_CreateFalse(void)
{
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_CreateBool(BOOL boolean)
{
WINPR_UNUSED(boolean);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_CreateNumber(double num)
{
WINPR_UNUSED(num);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_CreateString(const char* string)
{
WINPR_UNUSED(string);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_CreateArray(void)
{
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_CreateObject(void)
{
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_AddNullToObject(WINPR_JSON* object, const char* name)
{
WINPR_UNUSED(object);
WINPR_UNUSED(name);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_AddTrueToObject(WINPR_JSON* object, const char* name)
{
WINPR_UNUSED(object);
WINPR_UNUSED(name);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_AddFalseToObject(WINPR_JSON* object, const char* name)
{
WINPR_UNUSED(object);
WINPR_UNUSED(name);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_AddBoolToObject(WINPR_JSON* object, const char* name, BOOL boolean)
@@ -222,7 +222,7 @@ WINPR_JSON* WINPR_JSON_AddBoolToObject(WINPR_JSON* object, const char* name, BOO
WINPR_UNUSED(object);
WINPR_UNUSED(name);
WINPR_UNUSED(boolean);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name, double number)
@@ -230,7 +230,7 @@ WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name, d
WINPR_UNUSED(object);
WINPR_UNUSED(name);
WINPR_UNUSED(number);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_AddStringToObject(WINPR_JSON* object, const char* name, const char* string)
@@ -238,14 +238,14 @@ WINPR_JSON* WINPR_JSON_AddStringToObject(WINPR_JSON* object, const char* name, c
WINPR_UNUSED(object);
WINPR_UNUSED(name);
WINPR_UNUSED(string);
- return NULL;
+ return nullptr;
}
WINPR_JSON* WINPR_JSON_AddObjectToObject(WINPR_JSON* object, const char* name)
{
WINPR_UNUSED(object);
WINPR_UNUSED(name);
- return NULL;
+ return nullptr;
}
BOOL WINPR_JSON_AddItemToArray(WINPR_JSON* array, WINPR_JSON* item)
@@ -259,17 +259,17 @@ WINPR_JSON* WINPR_JSON_AddArrayToObject(WINPR_JSON* object, const char* name)
{
WINPR_UNUSED(object);
WINPR_UNUSED(name);
- return NULL;
+ return nullptr;
}
char* WINPR_JSON_Print(WINPR_JSON* item)
{
WINPR_UNUSED(item);
- return NULL;
+ return nullptr;
}
char* WINPR_JSON_PrintUnformatted(WINPR_JSON* item)
{
WINPR_UNUSED(item);
- return NULL;
+ return nullptr;
}
diff --git a/winpr/libwinpr/utils/json/json.c b/winpr/libwinpr/utils/json/json.c
index c92b25d33..78e18284e 100644
--- a/winpr/libwinpr/utils/json/json.c
+++ b/winpr/libwinpr/utils/json/json.c
@@ -28,7 +28,7 @@ WINPR_JSON* WINPR_JSON_ParseFromFile(const char* filename)
{
FILE* fp = winpr_fopen(filename, "r");
if (!fp)
- return NULL;
+ return nullptr;
WINPR_JSON* json = WINPR_JSON_ParseFromFileFP(fp);
(void)fclose(fp);
return json;
@@ -37,24 +37,24 @@ WINPR_JSON* WINPR_JSON_ParseFromFile(const char* filename)
WINPR_JSON* WINPR_JSON_ParseFromFileFP(FILE* fp)
{
if (!fp)
- return NULL;
+ return nullptr;
if (fseek(fp, 0, SEEK_END) != 0)
- return NULL;
+ return nullptr;
const INT64 size = _ftelli64(fp);
if (size < 0)
- return NULL;
+ return nullptr;
if (fseek(fp, 0, SEEK_SET) != 0)
- return NULL;
+ return nullptr;
const size_t usize = WINPR_ASSERTING_INT_CAST(size_t, size);
char* str = calloc(usize + 1, sizeof(char));
if (!str)
- return NULL;
+ return nullptr;
- WINPR_JSON* json = NULL;
+ WINPR_JSON* json = nullptr;
const size_t s = fread(str, sizeof(char), usize, fp);
if (s == usize)
json = WINPR_JSON_ParseWithLength(str, usize);
diff --git a/winpr/libwinpr/utils/ntlm.c b/winpr/libwinpr/utils/ntlm.c
index 25e0e5a59..753e15f95 100644
--- a/winpr/libwinpr/utils/ntlm.c
+++ b/winpr/libwinpr/utils/ntlm.c
@@ -45,7 +45,7 @@ BOOL NTOWFv1W(LPWSTR Password, UINT32 PasswordLength, BYTE* NtHash)
BOOL NTOWFv1A(LPSTR Password, UINT32 PasswordLength, BYTE* NtHash)
{
- LPWSTR PasswordW = NULL;
+ LPWSTR PasswordW = nullptr;
BOOL result = FALSE;
size_t pwdCharLength = 0;
@@ -89,9 +89,9 @@ BOOL NTOWFv2W(LPWSTR Password, UINT32 PasswordLength, LPWSTR User, UINT32 UserLe
BOOL NTOWFv2A(LPSTR Password, UINT32 PasswordLength, LPSTR User, UINT32 UserLength, LPSTR Domain,
UINT32 DomainLength, BYTE* NtHash)
{
- LPWSTR UserW = NULL;
- LPWSTR DomainW = NULL;
- LPWSTR PasswordW = NULL;
+ LPWSTR UserW = nullptr;
+ LPWSTR DomainW = nullptr;
+ LPWSTR PasswordW = nullptr;
BOOL result = FALSE;
size_t userCharLength = 0;
size_t domainCharLength = 0;
@@ -123,7 +123,7 @@ out_fail:
BOOL NTOWFv2FromHashW(BYTE* NtHashV1, LPWSTR User, UINT32 UserLength, LPWSTR Domain,
UINT32 DomainLength, BYTE* NtHash)
{
- BYTE* buffer = NULL;
+ BYTE* buffer = nullptr;
BYTE result = FALSE;
if (!User || !NtHash)
@@ -156,8 +156,8 @@ out_fail:
BOOL NTOWFv2FromHashA(BYTE* NtHashV1, LPSTR User, UINT32 UserLength, LPSTR Domain,
UINT32 DomainLength, BYTE* NtHash)
{
- LPWSTR UserW = NULL;
- LPWSTR DomainW = NULL;
+ LPWSTR UserW = nullptr;
+ LPWSTR DomainW = nullptr;
BOOL result = FALSE;
size_t userCharLength = 0;
size_t domainCharLength = 0;
diff --git a/winpr/libwinpr/utils/print.c b/winpr/libwinpr/utils/print.c
index e3f57c497..e02208722 100644
--- a/winpr/libwinpr/utils/print.c
+++ b/winpr/libwinpr/utils/print.c
@@ -57,7 +57,7 @@ void winpr_HexLogDump(wLog* log, UINT32 level, const void* data, size_t length)
WINPR_HEXDUMP_LINE_LENGTH + 1ULL;
size_t pos = 0;
- char* buffer = NULL;
+ char* buffer = nullptr;
if (!WLog_IsLevelActive(log, level))
return;
@@ -249,13 +249,13 @@ char* winpr_BinToHexString(const BYTE* data, size_t length, BOOL space)
char* p = (char*)malloc(size);
if (!p)
- return NULL;
+ return nullptr;
rc = winpr_BinToHexStringBuffer(data, length, p, size, space);
if (rc == 0)
{
free(p);
- return NULL;
+ return nullptr;
}
return p;
diff --git a/winpr/libwinpr/utils/sam.c b/winpr/libwinpr/utils/sam.c
index 66e3eac5e..a386ca98e 100644
--- a/winpr/libwinpr/utils/sam.c
+++ b/winpr/libwinpr/utils/sam.c
@@ -53,7 +53,7 @@ static WINPR_SAM_ENTRY* SamEntryFromDataA(LPCSTR User, DWORD UserLength, LPCSTR
{
WINPR_SAM_ENTRY* entry = calloc(1, sizeof(WINPR_SAM_ENTRY));
if (!entry)
- return NULL;
+ return nullptr;
if (User && (UserLength > 0))
entry->User = _strdup(User);
entry->UserLength = UserLength;
@@ -90,9 +90,9 @@ static BOOL SamAreEntriesEqual(const WINPR_SAM_ENTRY* a, const WINPR_SAM_ENTRY*
WINPR_SAM* SamOpen(const char* filename, BOOL readOnly)
{
- FILE* fp = NULL;
- WINPR_SAM* sam = NULL;
- char* allocatedFileName = NULL;
+ FILE* fp = nullptr;
+ WINPR_SAM* sam = nullptr;
+ char* allocatedFileName = nullptr;
if (!filename)
{
@@ -118,7 +118,7 @@ WINPR_SAM* SamOpen(const char* filename, BOOL readOnly)
if (!sam)
{
(void)fclose(fp);
- return NULL;
+ return nullptr;
}
sam->readOnly = readOnly;
@@ -127,7 +127,7 @@ WINPR_SAM* SamOpen(const char* filename, BOOL readOnly)
else
{
WLog_DBG(TAG, "Could not open SAM file!");
- return NULL;
+ return nullptr;
}
return sam;
@@ -150,7 +150,7 @@ static BOOL SamLookupStart(WINPR_SAM* sam)
if (fileSize < 1)
return FALSE;
- sam->context = NULL;
+ sam->context = nullptr;
sam->buffer = (char*)calloc((size_t)fileSize + 2, 1);
if (!sam->buffer)
@@ -167,7 +167,7 @@ static BOOL SamLookupStart(WINPR_SAM* sam)
if (readSize < 1)
{
free(sam->buffer);
- sam->buffer = NULL;
+ sam->buffer = nullptr;
return FALSE;
}
@@ -180,8 +180,8 @@ static BOOL SamLookupStart(WINPR_SAM* sam)
static void SamLookupFinish(WINPR_SAM* sam)
{
free(sam->buffer);
- sam->buffer = NULL;
- sam->line = NULL;
+ sam->buffer = nullptr;
+ sam->line = nullptr;
}
static BOOL SamReadEntry(WINPR_SAM* sam, WINPR_SAM_ENTRY* entry)
@@ -194,7 +194,7 @@ static BOOL SamReadEntry(WINPR_SAM* sam, WINPR_SAM_ENTRY* entry)
char* cur = sam->line;
- while ((cur = strchr(cur, ':')) != NULL)
+ while ((cur = strchr(cur, ':')) != nullptr)
{
count++;
cur++;
@@ -234,7 +234,7 @@ static BOOL SamReadEntry(WINPR_SAM* sam, WINPR_SAM_ENTRY* entry)
if (!entry->Domain)
{
free(entry->User);
- entry->User = NULL;
+ entry->User = nullptr;
return FALSE;
}
@@ -242,7 +242,7 @@ static BOOL SamReadEntry(WINPR_SAM* sam, WINPR_SAM_ENTRY* entry)
entry->Domain[entry->DomainLength] = '\0';
}
else
- entry->Domain = NULL;
+ entry->Domain = nullptr;
if (LmHashLength == 32)
winpr_HexStringToBinBuffer(p[2], LmHashLength, entry->LmHash, sizeof(entry->LmHash));
@@ -275,13 +275,13 @@ void SamResetEntry(WINPR_SAM_ENTRY* entry)
if (entry->UserLength)
{
free(entry->User);
- entry->User = NULL;
+ entry->User = nullptr;
}
if (entry->DomainLength)
{
free(entry->Domain);
- entry->Domain = NULL;
+ entry->Domain = nullptr;
}
ZeroMemory(entry->LmHash, sizeof(entry->LmHash));
@@ -302,7 +302,7 @@ WINPR_SAM_ENTRY* SamLookupUserA(WINPR_SAM* sam, LPCSTR User, UINT32 UserLength,
if (!SamLookupStart(sam))
goto fail;
- while (sam->line != NULL)
+ while (sam->line != nullptr)
{
length = strlen(sam->line);
@@ -324,7 +324,7 @@ WINPR_SAM_ENTRY* SamLookupUserA(WINPR_SAM* sam, LPCSTR User, UINT32 UserLength,
}
SamResetEntry(entry);
- sam->line = strtok_s(NULL, "\n", &sam->context);
+ sam->line = strtok_s(nullptr, "\n", &sam->context);
}
out_fail:
@@ -335,7 +335,7 @@ fail:
if (!found)
{
SamFreeEntry(sam, entry);
- return NULL;
+ return nullptr;
}
return entry;
@@ -344,9 +344,9 @@ fail:
WINPR_SAM_ENTRY* SamLookupUserW(WINPR_SAM* sam, LPCWSTR User, UINT32 UserLength, LPCWSTR Domain,
UINT32 DomainLength)
{
- WINPR_SAM_ENTRY* entry = NULL;
- char* utfUser = NULL;
- char* utfDomain = NULL;
+ WINPR_SAM_ENTRY* entry = nullptr;
+ char* utfUser = nullptr;
+ char* utfDomain = nullptr;
size_t userCharLen = 0;
size_t domainCharLen = 0;
@@ -368,7 +368,7 @@ fail:
void SamClose(WINPR_SAM* sam)
{
- if (sam != NULL)
+ if (sam != nullptr)
{
if (sam->fp)
(void)fclose(sam->fp);
diff --git a/winpr/libwinpr/utils/ssl.c b/winpr/libwinpr/utils/ssl.c
index 248d1655f..620232344 100644
--- a/winpr/libwinpr/utils/ssl.c
+++ b/winpr/libwinpr/utils/ssl.c
@@ -41,9 +41,9 @@
static BOOL g_winpr_openssl_initialized_by_winpr = FALSE;
#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
-static OSSL_PROVIDER* s_winpr_openssl_provider_fips = NULL;
-static OSSL_PROVIDER* s_winpr_openssl_provider_legacy = NULL;
-static OSSL_PROVIDER* s_winpr_openssl_provider_default = NULL;
+static OSSL_PROVIDER* s_winpr_openssl_provider_fips = nullptr;
+static OSSL_PROVIDER* s_winpr_openssl_provider_legacy = nullptr;
+static OSSL_PROVIDER* s_winpr_openssl_provider_default = nullptr;
#endif
/**
@@ -57,7 +57,7 @@ static OSSL_PROVIDER* s_winpr_openssl_provider_default = NULL;
#define WINPR_OPENSSL_LOCKING_REQUIRED 1
static int g_winpr_openssl_num_locks = 0;
-static HANDLE* g_winpr_openssl_locks = NULL;
+static HANDLE* g_winpr_openssl_locks = nullptr;
struct CRYPTO_dynlock_value
{
@@ -88,12 +88,12 @@ static struct CRYPTO_dynlock_value* _winpr_openssl_dynlock_create(const char* fi
struct CRYPTO_dynlock_value* dynlock;
if (!(dynlock = (struct CRYPTO_dynlock_value*)malloc(sizeof(struct CRYPTO_dynlock_value))))
- return NULL;
+ return nullptr;
- if (!(dynlock->mutex = CreateMutex(NULL, FALSE, NULL)))
+ if (!(dynlock->mutex = CreateMutex(nullptr, FALSE, nullptr)))
{
free(dynlock);
- return NULL;
+ return nullptr;
}
return dynlock;
@@ -143,7 +143,7 @@ static BOOL _winpr_openssl_initialize_locking(void)
for (int i = 0; i < count; i++)
{
- if (!(locks[i] = CreateMutex(NULL, FALSE, NULL)))
+ if (!(locks[i] = CreateMutex(nullptr, FALSE, nullptr)))
{
WLog_ERR(TAG, "error creating lock #%d", i);
@@ -199,7 +199,7 @@ static BOOL _winpr_openssl_cleanup_locking(void)
/* undo our static locking modifications */
if (CRYPTO_get_locking_callback() == _winpr_openssl_locking)
{
- CRYPTO_set_locking_callback(NULL);
+ CRYPTO_set_locking_callback(nullptr);
for (int i = 0; i < g_winpr_openssl_num_locks; i++)
{
@@ -208,31 +208,31 @@ static BOOL _winpr_openssl_cleanup_locking(void)
g_winpr_openssl_num_locks = 0;
free(g_winpr_openssl_locks);
- g_winpr_openssl_locks = NULL;
+ g_winpr_openssl_locks = nullptr;
}
/* unset our dynamic locking callbacks */
if (CRYPTO_get_dynlock_create_callback() == _winpr_openssl_dynlock_create)
{
- CRYPTO_set_dynlock_create_callback(NULL);
+ CRYPTO_set_dynlock_create_callback(nullptr);
}
if (CRYPTO_get_dynlock_lock_callback() == _winpr_openssl_dynlock_lock)
{
- CRYPTO_set_dynlock_lock_callback(NULL);
+ CRYPTO_set_dynlock_lock_callback(nullptr);
}
if (CRYPTO_get_dynlock_destroy_callback() == _winpr_openssl_dynlock_destroy)
{
- CRYPTO_set_dynlock_destroy_callback(NULL);
+ CRYPTO_set_dynlock_destroy_callback(nullptr);
}
#if (OPENSSL_VERSION_NUMBER < 0x10000000L) || defined(LIBRESSL_VERSION_NUMBER)
if (CRYPTO_get_id_callback() == _winpr_openssl_id)
{
- CRYPTO_set_id_callback(NULL);
+ CRYPTO_set_id_callback(nullptr);
}
#endif
@@ -252,18 +252,18 @@ static BOOL winpr_enable_fips(DWORD flags)
WLog_DBG(TAG, "Ensuring openssl fips mode is enabled");
#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
- s_winpr_openssl_provider_fips = OSSL_PROVIDER_load(NULL, "fips");
- if (s_winpr_openssl_provider_fips == NULL)
+ s_winpr_openssl_provider_fips = OSSL_PROVIDER_load(nullptr, "fips");
+ if (s_winpr_openssl_provider_fips == nullptr)
{
WLog_WARN(TAG, "OpenSSL FIPS provider failed to load");
}
- if (!EVP_default_properties_is_fips_enabled(NULL))
+ if (!EVP_default_properties_is_fips_enabled(nullptr))
#else
if (FIPS_mode() != 1)
#endif
{
#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
- if (EVP_set_default_properties(NULL, "fips=yes"))
+ if (EVP_set_default_properties(nullptr, "fips=yes"))
#else
if (FIPS_mode_set(1))
#endif
@@ -319,20 +319,20 @@ static BOOL CALLBACK winpr_openssl_initialize(WINPR_ATTR_UNUSED PINIT_ONCE once,
if (OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS |
OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS |
OPENSSL_INIT_ENGINE_ALL_BUILTIN,
- NULL) != 1)
+ nullptr) != 1)
return FALSE;
#endif
#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
/* The legacy provider is needed for MD4. */
- s_winpr_openssl_provider_legacy = OSSL_PROVIDER_load(NULL, "legacy");
- if (s_winpr_openssl_provider_legacy == NULL)
+ s_winpr_openssl_provider_legacy = OSSL_PROVIDER_load(nullptr, "legacy");
+ if (s_winpr_openssl_provider_legacy == nullptr)
{
WLog_WARN(TAG, "OpenSSL LEGACY provider failed to load, no md4 support available!");
}
- s_winpr_openssl_provider_default = OSSL_PROVIDER_load(NULL, "default");
- if (s_winpr_openssl_provider_default == NULL)
+ s_winpr_openssl_provider_default = OSSL_PROVIDER_load(nullptr, "default");
+ if (s_winpr_openssl_provider_default == nullptr)
{
WLog_WARN(TAG, "OpenSSL DEFAULT provider failed to load");
}
@@ -349,7 +349,7 @@ BOOL winpr_InitializeSSL(DWORD flags)
{
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
- if (!InitOnceExecuteOnce(&once, winpr_openssl_initialize, &flags, NULL))
+ if (!InitOnceExecuteOnce(&once, winpr_openssl_initialize, &flags, nullptr))
return FALSE;
return winpr_enable_fips(flags);
@@ -404,14 +404,14 @@ BOOL winpr_CleanupSSL(DWORD flags)
#if (OPENSSL_VERSION_NUMBER < 0x10000000L) || defined(LIBRESSL_VERSION_NUMBER)
ERR_remove_state(0);
#else
- ERR_remove_thread_state(NULL);
+ ERR_remove_thread_state(nullptr);
#endif
}
#endif
#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
OSSL_LIB_CTX* ctx = OSSL_LIB_CTX_get0_global_default();
- OSSL_PROVIDER_do_all(ctx, unload, NULL);
+ OSSL_PROVIDER_do_all(ctx, unload, nullptr);
#endif
return TRUE;
@@ -422,7 +422,7 @@ BOOL winpr_FIPSMode(void)
#if (OPENSSL_VERSION_NUMBER < 0x10001000L) || defined(LIBRESSL_VERSION_NUMBER)
return FALSE;
#elif defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
- return (EVP_default_properties_is_fips_enabled(NULL) == 1);
+ return (EVP_default_properties_is_fips_enabled(nullptr) == 1);
#else
return (FIPS_mode() == 1);
#endif
diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c
index eea333335..748c9fdec 100644
--- a/winpr/libwinpr/utils/stream.c
+++ b/winpr/libwinpr/utils/stream.c
@@ -52,7 +52,7 @@ BOOL Stream_EnsureCapacity(wStream* s, size_t size)
const size_t new_capacity = size + increment - size % increment;
const size_t position = Stream_GetPosition(s);
- BYTE* new_buf = NULL;
+ BYTE* new_buf = nullptr;
if (!s->isOwner)
{
new_buf = (BYTE*)malloc(new_capacity);
@@ -86,14 +86,14 @@ BOOL Stream_EnsureRemainingCapacity(wStream* s, size_t size)
wStream* Stream_New(BYTE* buffer, size_t size)
{
- wStream* s = NULL;
+ wStream* s = nullptr;
if (!buffer && !size)
- return NULL;
+ return nullptr;
s = calloc(1, sizeof(wStream));
if (!s)
- return NULL;
+ return nullptr;
if (buffer)
s->buffer = buffer;
@@ -103,14 +103,14 @@ wStream* Stream_New(BYTE* buffer, size_t size)
if (!s->buffer)
{
free(s);
- return NULL;
+ return nullptr;
}
s->pointer = s->buffer;
s->capacity = size;
s->length = size;
- s->pool = NULL;
+ s->pool = nullptr;
s->count = 1;
s->isAllocatedStream = TRUE;
s->isOwner = TRUE;
@@ -139,7 +139,7 @@ wStream* Stream_StaticInit(wStream* s, BYTE* buffer, size_t size)
*s = empty;
s->buffer = s->pointer = buffer;
s->capacity = s->length = size;
- s->pool = NULL;
+ s->pool = nullptr;
s->count = 1;
s->isAllocatedStream = FALSE;
s->isOwner = FALSE;
@@ -230,7 +230,7 @@ BOOL Stream_SetBuffer(wStream* _s, BYTE* _b)
_s->buffer = _b;
_s->pointer = _b;
- return _s->buffer != NULL;
+ return _s->buffer != nullptr;
}
void Stream_SetCapacity(wStream* _s, size_t _c)
@@ -483,10 +483,10 @@ char* Stream_Read_UTF16_String_As_UTF8(wStream* s, size_t wcharLength, size_t* p
{
const WCHAR* str = Stream_ConstPointer(s);
if (wcharLength > SIZE_MAX / sizeof(WCHAR))
- return NULL;
+ return nullptr;
if (!Stream_CheckAndLogRequiredLength(STREAM_TAG, s, wcharLength * sizeof(WCHAR)))
- return NULL;
+ return nullptr;
Stream_Seek(s, wcharLength * sizeof(WCHAR));
return ConvertWCharNToUtf8Alloc(str, wcharLength, pUtfCharLength);
diff --git a/winpr/libwinpr/utils/strlst.c b/winpr/libwinpr/utils/strlst.c
index d60d11075..b53ac39e1 100644
--- a/winpr/libwinpr/utils/strlst.c
+++ b/winpr/libwinpr/utils/strlst.c
@@ -51,7 +51,7 @@ char** string_list_copy(const char* const* string_list)
if (!copy)
{
- return 0;
+ return nullptr;
}
for (int i = 0; i < length; i++)
@@ -59,7 +59,7 @@ char** string_list_copy(const char* const* string_list)
copy[i] = _strdup(string_list[i]);
}
- copy[length] = 0;
+ copy[length] = nullptr;
return copy;
}
diff --git a/winpr/libwinpr/utils/test/TestASN1.c b/winpr/libwinpr/utils/test/TestASN1.c
index 2b936d0d5..2a6262a4c 100644
--- a/winpr/libwinpr/utils/test/TestASN1.c
+++ b/winpr/libwinpr/utils/test/TestASN1.c
@@ -36,7 +36,7 @@ int TestASN1Read(int argc, char* argv[])
WinPrAsn1_BOOL boolV = 0;
WinPrAsn1_INTEGER integerV = 0;
WinPrAsn1_OID oidV = WINPR_C_ARRAY_INIT;
- WinPrAsn1_IA5STRING ia5stringV = NULL;
+ WinPrAsn1_IA5STRING ia5stringV = nullptr;
WinPrAsn1_UTCTIME utctimeV = WINPR_C_ARRAY_INIT;
WinPrAsn1_tag tag = 0;
size_t len = 0;
@@ -153,11 +153,11 @@ static WinPrAsn1_OID oid4 = { sizeof(oid4_val), oid4_val };
int TestASN1Write(int argc, char* argv[])
{
- wStream* s = NULL;
+ wStream* s = nullptr;
size_t expectedOuputSz = 0;
int retCode = 100;
WinPrAsn1_UTCTIME utcTime;
- WinPrAsn1_IA5STRING ia5string = NULL;
+ WinPrAsn1_IA5STRING ia5string = nullptr;
WinPrAsn1Encoder* enc = WinPrAsn1Encoder_New(WINPR_ASN1_DER);
if (!enc)
goto out;
@@ -286,7 +286,7 @@ int TestASN1Write(int argc, char* argv[])
/* let's output the result */
retCode = 201;
- s = Stream_New(NULL, 1024);
+ s = Stream_New(nullptr, 1024);
if (!s)
goto out;
diff --git a/winpr/libwinpr/utils/test/TestBacktrace.c b/winpr/libwinpr/utils/test/TestBacktrace.c
index c3a89f193..97d4a4d22 100644
--- a/winpr/libwinpr/utils/test/TestBacktrace.c
+++ b/winpr/libwinpr/utils/test/TestBacktrace.c
@@ -5,7 +5,7 @@ int TestBacktrace(int argc, char* argv[])
{
int rc = -1;
size_t used = 0;
- char** msg = NULL;
+ char** msg = nullptr;
void* stack = winpr_backtrace(20);
WINPR_UNUSED(argc);
diff --git a/winpr/libwinpr/utils/test/TestBitStream.c b/winpr/libwinpr/utils/test/TestBitStream.c
index f8bb65baa..1bdb654fb 100644
--- a/winpr/libwinpr/utils/test/TestBitStream.c
+++ b/winpr/libwinpr/utils/test/TestBitStream.c
@@ -51,7 +51,7 @@ static void BitStrGen(void)
int TestBitStream(int argc, char* argv[])
{
- wBitStream* bs = NULL;
+ wBitStream* bs = nullptr;
BYTE buffer[1024] = WINPR_C_ARRAY_INIT;
WINPR_UNUSED(argc);
diff --git a/winpr/libwinpr/utils/test/TestBufferPool.c b/winpr/libwinpr/utils/test/TestBufferPool.c
index b13dc0cf8..aca6a596a 100644
--- a/winpr/libwinpr/utils/test/TestBufferPool.c
+++ b/winpr/libwinpr/utils/test/TestBufferPool.c
@@ -7,7 +7,7 @@ int TestBufferPool(int argc, char* argv[])
{
DWORD PoolSize = 0;
SSIZE_T BufferSize = 0;
- wBufferPool* pool = NULL;
+ wBufferPool* pool = nullptr;
BYTE* Buffers[10] = WINPR_C_ARRAY_INIT;
int DefaultSize = 1234;
diff --git a/winpr/libwinpr/utils/test/TestCmdLine.c b/winpr/libwinpr/utils/test/TestCmdLine.c
index 445205f93..77fe913e1 100644
--- a/winpr/libwinpr/utils/test/TestCmdLine.c
+++ b/winpr/libwinpr/utils/test/TestCmdLine.c
@@ -17,7 +17,7 @@ static const char* testArgv[] = { "mstsc.exe",
"/v:localhost:3389",
"/valuelist:value1,value2",
"/valuelist-empty:",
- 0 };
+ nullptr };
static const char testListAppName[] = "test app name";
static const char* testListArgs[] = {
@@ -28,7 +28,7 @@ static const char* testListArgs[] = {
"a:,\",b",
"\"a,b,c,d d d,fff\"",
"",
- NULL,
+ nullptr,
"'a,b,\",c'",
"\"a,b,',c\"",
"', a, ', b,c'",
@@ -55,15 +55,15 @@ static const char** testListArgsResult[] = {
testListArgs12,
testListArgs1,
testListArgs2,
- NULL /* testListArgs3 */,
- NULL /* testListArgs4 */,
+ nullptr /* testListArgs3 */,
+ nullptr /* testListArgs4 */,
testListArgs5,
testListArgs6,
testListArgs7,
testListArgs8,
testListArgs9,
- NULL /* testListArgs10 */,
- NULL /* testListArgs11 */
+ nullptr /* testListArgs10 */,
+ nullptr /* testListArgs11 */
};
static const size_t testListArgsCount[] = {
ARRAYSIZE(testListArgs12), ARRAYSIZE(testListArgs1),
@@ -85,7 +85,7 @@ static BOOL checkResult(size_t index, char** actual, size_t actualCount)
if (actualCount == 0)
{
- return (actual == NULL);
+ return (actual == nullptr);
}
else
{
@@ -137,66 +137,75 @@ int TestCmdLine(int argc, char* argv[])
DWORD flags = 0;
long width = 0;
long height = 0;
- const COMMAND_LINE_ARGUMENT_A* arg = NULL;
+ const COMMAND_LINE_ARGUMENT_A* arg = nullptr;
int testArgc = 0;
- char** command_line = NULL;
+ char** command_line = nullptr;
COMMAND_LINE_ARGUMENT_A args[] = {
- { "v", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "destination server" },
- { "port", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "server port" },
- { "w", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "width" },
- { "h", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "height" },
- { "f", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "fullscreen" },
- { "bpp", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ { "v", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr,
+ "destination server" },
+ { "port", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr,
+ "server port" },
+ { "w", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr, "width" },
+ { "h", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr, "height" },
+ { "f", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr, "fullscreen" },
+ { "bpp", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr,
"session bpp (color depth)" },
- { "admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "console",
+ { "admin", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, "console",
"admin (or console) session" },
- { "multimon", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "multi-monitor" },
- { "a", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, "addin", "addin" },
- { "u", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "username" },
- { "p", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "password" },
- { "d", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "domain" },
- { "z", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "compression" },
- { "audio", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "audio output mode" },
- { "mic", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "audio input (microphone)" },
- { "fonts", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL,
+ { "multimon", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
+ "multi-monitor" },
+ { "a", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, "addin", "addin" },
+ { "u", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr, "username" },
+ { "p", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr, "password" },
+ { "d", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr, "domain" },
+ { "z", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr,
+ "compression" },
+ { "audio", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr,
+ "audio output mode" },
+ { "mic", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
+ "audio input (microphone)" },
+ { "fonts", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr,
"smooth fonts (cleartype)" },
- { "aero", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueFalse, -1, NULL,
+ { "aero", COMMAND_LINE_VALUE_BOOL, nullptr, nullptr, BoolValueFalse, -1, nullptr,
"desktop composition" },
- { "window-drag", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL,
+ { "window-drag", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr,
"full window drag" },
- { "menu-anims", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL,
+ { "menu-anims", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr,
"menu animations" },
- { "themes", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "themes" },
- { "wallpaper", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "wallpaper" },
- { "codec", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "codec" },
- { "nego", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL,
+ { "themes", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
+ "themes" },
+ { "wallpaper", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
+ "wallpaper" },
+ { "codec", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr, "codec" },
+ { "nego", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"protocol security negotiation" },
- { "sec", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ { "sec", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr,
"force specific protocol security" },
#if defined(WITH_FREERDP_DEPRECATED)
- { "sec-rdp", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL,
+ { "sec-rdp", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"rdp protocol security" },
- { "sec-tls", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL,
+ { "sec-tls", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"tls protocol security" },
- { "sec-nla", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL,
+ { "sec-nla", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr,
"nla protocol security" },
- { "sec-ext", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL,
+ { "sec-ext", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr,
"nla extended protocol security" },
- { "cert-name", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL,
+ { "cert-name", COMMAND_LINE_VALUE_REQUIRED, nullptr, nullptr, nullptr, -1, nullptr,
"certificate name" },
- { "cert-ignore", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ { "cert-ignore", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
"ignore certificate" },
#endif
- { "valuelist", COMMAND_LINE_VALUE_REQUIRED, ",", NULL, NULL, -1, NULL,
+ { "valuelist", COMMAND_LINE_VALUE_REQUIRED, ",", nullptr, nullptr, -1, nullptr,
"List of comma separated values." },
- { "valuelist-empty", COMMAND_LINE_VALUE_REQUIRED, ",", NULL, NULL, -1, NULL,
+ { "valuelist-empty", COMMAND_LINE_VALUE_REQUIRED, ",", nullptr, nullptr, -1,
+ nullptr,
"List of comma separated values. Used to test correct behavior if an empty list was "
"passed." },
- { "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1,
- NULL, "print version" },
- { "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "?",
- "print help" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
+ { "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, nullptr, nullptr,
+ nullptr, -1, nullptr, "print version" },
+ { "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, nullptr, nullptr, nullptr, -1,
+ "?", "print help" },
+ { nullptr, 0, nullptr, nullptr, nullptr, -1, nullptr, nullptr }
};
WINPR_UNUSED(argc);
@@ -212,7 +221,8 @@ int TestCmdLine(int argc, char* argv[])
return ret;
}
- status = CommandLineParseArgumentsA(testArgc, command_line, args, flags, NULL, NULL, NULL);
+ status =
+ CommandLineParseArgumentsA(testArgc, command_line, args, flags, nullptr, nullptr, nullptr);
if (status != 0)
{
@@ -306,14 +316,14 @@ int TestCmdLine(int argc, char* argv[])
}
CommandLineSwitchCase(arg, "w")
{
- width = strtol(arg->Value, NULL, 0);
+ width = strtol(arg->Value, nullptr, 0);
if (errno != 0)
goto out;
}
CommandLineSwitchCase(arg, "h")
{
- height = strtol(arg->Value, NULL, 0);
+ height = strtol(arg->Value, nullptr, 0);
if (errno != 0)
goto out;
@@ -350,7 +360,7 @@ int TestCmdLine(int argc, char* argv[])
{
}
CommandLineSwitchEnd(arg)
- } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != nullptr);
if ((width != 1024) || (height != 768))
{
diff --git a/winpr/libwinpr/utils/test/TestHashTable.c b/winpr/libwinpr/utils/test/TestHashTable.c
index 2bb8505e1..67a3dced9 100644
--- a/winpr/libwinpr/utils/test/TestHashTable.c
+++ b/winpr/libwinpr/utils/test/TestHashTable.c
@@ -15,8 +15,8 @@ static int test_hash_table_pointer(void)
{
int rc = -1;
size_t count = 0;
- char* value = NULL;
- wHashTable* table = NULL;
+ char* value = nullptr;
+ wHashTable* table = nullptr;
table = HashTable_New(TRUE);
if (!table)
@@ -151,7 +151,7 @@ static int test_hash_table_string(void)
{
int rc = -1;
size_t count = 0;
- char* value = NULL;
+ char* value = nullptr;
wHashTable* table = HashTable_New(TRUE);
if (!table)
@@ -368,7 +368,7 @@ static BOOL foreachFn3(const void* key, void* value, void* arg)
static int test_hash_foreach(void)
{
ForeachData foreachData;
- wHashTable* table = NULL;
+ wHashTable* table = nullptr;
int retCode = 0;
foreachData.table = table = HashTable_New(TRUE);
diff --git a/winpr/libwinpr/utils/test/TestIni.c b/winpr/libwinpr/utils/test/TestIni.c
index 5e4143e5e..adffe05d5 100644
--- a/winpr/libwinpr/utils/test/TestIni.c
+++ b/winpr/libwinpr/utils/test/TestIni.c
@@ -42,10 +42,10 @@ int TestIni(int argc, char* argv[])
size_t nKeys = 0;
size_t nSections = 0;
UINT32 iValue = 0;
- wIniFile* ini = NULL;
- const char* sValue = NULL;
- char** keyNames = NULL;
- char** sectionNames = NULL;
+ wIniFile* ini = nullptr;
+ const char* sValue = nullptr;
+ char** keyNames = nullptr;
+ char** sectionNames = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
diff --git a/winpr/libwinpr/utils/test/TestListDictionary.c b/winpr/libwinpr/utils/test/TestListDictionary.c
index 17257c806..e113981fd 100644
--- a/winpr/libwinpr/utils/test/TestListDictionary.c
+++ b/winpr/libwinpr/utils/test/TestListDictionary.c
@@ -14,8 +14,8 @@ static char* val3 = "val3";
int TestListDictionary(int argc, char* argv[])
{
size_t count = 0;
- char* value = NULL;
- wListDictionary* list = NULL;
+ char* value = nullptr;
+ wListDictionary* list = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
diff --git a/winpr/libwinpr/utils/test/TestMessagePipe.c b/winpr/libwinpr/utils/test/TestMessagePipe.c
index 8c85a4ca8..431b2f7ae 100644
--- a/winpr/libwinpr/utils/test/TestMessagePipe.c
+++ b/winpr/libwinpr/utils/test/TestMessagePipe.c
@@ -13,7 +13,7 @@ static DWORD WINAPI message_echo_pipe_client_thread(LPVOID arg)
wMessage message = WINPR_C_ARRAY_INIT;
int count = -1;
- if (!MessageQueue_Post(pipe->In, NULL, 0, (void*)(size_t)index, NULL))
+ if (!MessageQueue_Post(pipe->In, nullptr, 0, (void*)(size_t)index, nullptr))
break;
if (!MessageQueue_Wait(pipe->Out))
@@ -60,9 +60,9 @@ static DWORD WINAPI message_echo_pipe_server_thread(LPVOID arg)
int TestMessagePipe(int argc, char* argv[])
{
- HANDLE ClientThread = NULL;
- HANDLE ServerThread = NULL;
- wMessagePipe* EchoPipe = NULL;
+ HANDLE ClientThread = nullptr;
+ HANDLE ServerThread = nullptr;
+ wMessagePipe* EchoPipe = nullptr;
int ret = 1;
WINPR_UNUSED(argc);
@@ -74,15 +74,15 @@ int TestMessagePipe(int argc, char* argv[])
goto out;
}
- if (!(ClientThread =
- CreateThread(NULL, 0, message_echo_pipe_client_thread, (void*)EchoPipe, 0, NULL)))
+ if (!(ClientThread = CreateThread(nullptr, 0, message_echo_pipe_client_thread, (void*)EchoPipe,
+ 0, nullptr)))
{
printf("failed to create client thread\n");
goto out;
}
- if (!(ServerThread =
- CreateThread(NULL, 0, message_echo_pipe_server_thread, (void*)EchoPipe, 0, NULL)))
+ if (!(ServerThread = CreateThread(nullptr, 0, message_echo_pipe_server_thread, (void*)EchoPipe,
+ 0, nullptr)))
{
printf("failed to create server thread\n");
goto out;
diff --git a/winpr/libwinpr/utils/test/TestMessageQueue.c b/winpr/libwinpr/utils/test/TestMessageQueue.c
index 73e0881d0..0c87f76ce 100644
--- a/winpr/libwinpr/utils/test/TestMessageQueue.c
+++ b/winpr/libwinpr/utils/test/TestMessageQueue.c
@@ -24,7 +24,7 @@ static DWORD WINAPI message_queue_consumer_thread(LPVOID arg)
static bool wrap_test(bool (*fkt)(wMessageQueue* queue))
{
- wMessageQueue* queue = MessageQueue_New(NULL);
+ wMessageQueue* queue = MessageQueue_New(nullptr);
if (!queue)
return false;
@@ -46,7 +46,7 @@ static bool check(const wMessage* message, size_t pos)
return false;
if (message->lParam != (void*)42)
return false;
- if (message->Free != NULL)
+ if (message->Free != nullptr)
return false;
return true;
}
@@ -57,7 +57,7 @@ static bool append(wMessageQueue* queue, size_t pos)
.id = WINPR_ASSERTING_INT_CAST(DWORD, pos),
.wParam = (void*)23,
.lParam = (void*)42,
- .Free = NULL };
+ .Free = nullptr };
return MessageQueue_Dispatch(queue, &message);
}
@@ -148,13 +148,13 @@ static bool test_operation_run(wMessageQueue* queue, HANDLE thread)
WINPR_ASSERT(queue);
WINPR_ASSERT(thread);
- if (!MessageQueue_Post(queue, NULL, 123, NULL, NULL))
+ if (!MessageQueue_Post(queue, nullptr, 123, nullptr, nullptr))
return false;
- if (!MessageQueue_Post(queue, NULL, 456, NULL, NULL))
+ if (!MessageQueue_Post(queue, nullptr, 456, nullptr, nullptr))
return false;
- if (!MessageQueue_Post(queue, NULL, 789, NULL, NULL))
+ if (!MessageQueue_Post(queue, nullptr, 789, nullptr, nullptr))
return false;
if (!MessageQueue_PostQuit(queue, 0))
@@ -168,7 +168,7 @@ static bool test_operation(wMessageQueue* queue)
{
WINPR_ASSERT(queue);
- HANDLE thread = CreateThread(NULL, 0, message_queue_consumer_thread, queue, 0, NULL);
+ HANDLE thread = CreateThread(nullptr, 0, message_queue_consumer_thread, queue, 0, nullptr);
if (!thread)
{
printf("failed to create thread\n");
diff --git a/winpr/libwinpr/utils/test/TestPrint.c b/winpr/libwinpr/utils/test/TestPrint.c
index 8132924ea..d28ea0022 100644
--- a/winpr/libwinpr/utils/test/TestPrint.c
+++ b/winpr/libwinpr/utils/test/TestPrint.c
@@ -25,8 +25,8 @@ static BOOL test_bin_tohex_string(void)
const char empty[33] = WINPR_C_ARRAY_INIT;
char strbuffer[33] = WINPR_C_ARRAY_INIT;
- size_t len =
- winpr_BinToHexStringBuffer(NULL, sizeof(binbuffer), strbuffer, sizeof(strbuffer), TRUE);
+ size_t len = winpr_BinToHexStringBuffer(nullptr, sizeof(binbuffer), strbuffer,
+ sizeof(strbuffer), TRUE);
if (len != 0)
goto fail;
if (memcmp(strbuffer, empty, sizeof(strbuffer)) != 0)
@@ -36,8 +36,8 @@ static BOOL test_bin_tohex_string(void)
goto fail;
if (memcmp(strbuffer, empty, sizeof(strbuffer)) != 0)
goto fail;
- len =
- winpr_BinToHexStringBuffer(binbuffer, sizeof(binbuffer), NULL, sizeof(strbuffer), TRUE);
+ len = winpr_BinToHexStringBuffer(binbuffer, sizeof(binbuffer), nullptr, sizeof(strbuffer),
+ TRUE);
if (len != 0)
goto fail;
if (memcmp(strbuffer, empty, sizeof(strbuffer)) != 0)
@@ -52,28 +52,28 @@ static BOOL test_bin_tohex_string(void)
goto fail;
if (memcmp(strbuffer, empty, sizeof(strbuffer)) != 0)
goto fail;
- len = winpr_BinToHexStringBuffer(binbuffer, sizeof(binbuffer), NULL, 0, TRUE);
+ len = winpr_BinToHexStringBuffer(binbuffer, sizeof(binbuffer), nullptr, 0, TRUE);
if (len != 0)
goto fail;
if (memcmp(strbuffer, empty, sizeof(strbuffer)) != 0)
goto fail;
- len = winpr_BinToHexStringBuffer(NULL, sizeof(binbuffer), strbuffer, 0, TRUE);
+ len = winpr_BinToHexStringBuffer(nullptr, sizeof(binbuffer), strbuffer, 0, TRUE);
if (len != 0)
goto fail;
if (memcmp(strbuffer, empty, sizeof(strbuffer)) != 0)
goto fail;
- len = winpr_BinToHexStringBuffer(binbuffer, 0, NULL, 0, TRUE);
+ len = winpr_BinToHexStringBuffer(binbuffer, 0, nullptr, 0, TRUE);
if (len != 0)
goto fail;
if (memcmp(strbuffer, empty, sizeof(strbuffer)) != 0)
goto fail;
- len = winpr_BinToHexStringBuffer(NULL, 0, NULL, 0, TRUE);
+ len = winpr_BinToHexStringBuffer(nullptr, 0, nullptr, 0, TRUE);
if (len != 0)
goto fail;
if (memcmp(strbuffer, empty, sizeof(strbuffer)) != 0)
goto fail;
- len = winpr_BinToHexStringBuffer(binbuffer, 0, NULL, 0, FALSE);
+ len = winpr_BinToHexStringBuffer(binbuffer, 0, nullptr, 0, FALSE);
if (len != 0)
goto fail;
if (memcmp(strbuffer, empty, sizeof(strbuffer)) != 0)
@@ -127,11 +127,11 @@ fail:
static BOOL test_bin_tohex_string_alloc(void)
{
BOOL rc = FALSE;
- char* str = NULL;
+ char* str = nullptr;
{
const BYTE binbuffer[33] = WINPR_C_ARRAY_INIT;
- str = winpr_BinToHexString(NULL, sizeof(binbuffer), TRUE);
+ str = winpr_BinToHexString(nullptr, sizeof(binbuffer), TRUE);
if (str)
goto fail;
str = winpr_BinToHexString(binbuffer, 0, TRUE);
@@ -140,7 +140,7 @@ static BOOL test_bin_tohex_string_alloc(void)
str = winpr_BinToHexString(binbuffer, 0, FALSE);
if (str)
goto fail;
- str = winpr_BinToHexString(NULL, sizeof(binbuffer), FALSE);
+ str = winpr_BinToHexString(nullptr, sizeof(binbuffer), FALSE);
if (str)
goto fail;
}
@@ -161,7 +161,7 @@ static BOOL test_bin_tohex_string_alloc(void)
if (memcmp(strbuffer1_space, str, sizeof(strbuffer1_space)) != 0)
goto fail;
free(str);
- str = NULL;
+ str = nullptr;
}
{
const BYTE binbuffer1[] = { 0xF1, 0xe2, 0xD3, 0xc4, 0xB5, 0xA6, 0x97, 0x88, 0x79,
@@ -181,7 +181,7 @@ static BOOL test_bin_tohex_string_alloc(void)
if (memcmp(strbuffer1_space, str, sizeof(strbuffer1_space)) != 0)
goto fail;
free(str);
- str = NULL;
+ str = nullptr;
}
rc = TRUE;
fail:
@@ -196,12 +196,12 @@ static BOOL test_hex_string_to_bin(void)
const char stringbuffer[] = "123456789ABCDEFabcdef";
const BYTE empty[1024] = WINPR_C_ARRAY_INIT;
BYTE buffer[1024] = WINPR_C_ARRAY_INIT;
- size_t len = winpr_HexStringToBinBuffer(NULL, 0, NULL, 0);
+ size_t len = winpr_HexStringToBinBuffer(nullptr, 0, nullptr, 0);
if (len != 0)
goto fail;
if (memcmp(buffer, empty, sizeof(buffer)) != 0)
goto fail;
- len = winpr_HexStringToBinBuffer(NULL, sizeof(stringbuffer), buffer, sizeof(buffer));
+ len = winpr_HexStringToBinBuffer(nullptr, sizeof(stringbuffer), buffer, sizeof(buffer));
if (len != 0)
goto fail;
if (memcmp(buffer, empty, sizeof(buffer)) != 0)
@@ -211,7 +211,8 @@ static BOOL test_hex_string_to_bin(void)
goto fail;
if (memcmp(buffer, empty, sizeof(buffer)) != 0)
goto fail;
- len = winpr_HexStringToBinBuffer(stringbuffer, sizeof(stringbuffer), NULL, sizeof(buffer));
+ len =
+ winpr_HexStringToBinBuffer(stringbuffer, sizeof(stringbuffer), nullptr, sizeof(buffer));
if (len != 0)
goto fail;
if (memcmp(buffer, empty, sizeof(buffer)) != 0)
diff --git a/winpr/libwinpr/utils/test/TestPubSub.c b/winpr/libwinpr/utils/test/TestPubSub.c
index 0b05b15c5..50693cd1e 100644
--- a/winpr/libwinpr/utils/test/TestPubSub.c
+++ b/winpr/libwinpr/utils/test/TestPubSub.c
@@ -32,7 +32,7 @@ static wEventType Node_Events[] = { DEFINE_EVENT_ENTRY(MouseMotion),
int TestPubSub(int argc, char* argv[])
{
- wPubSub* node = NULL;
+ wPubSub* node = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
@@ -53,7 +53,7 @@ int TestPubSub(int argc, char* argv[])
e.x = 64;
e.y = 128;
- PubSub_OnMouseMotion(node, NULL, &e);
+ PubSub_OnMouseMotion(node, nullptr, &e);
}
{
@@ -64,7 +64,7 @@ int TestPubSub(int argc, char* argv[])
e.flags = 7;
e.button = 1;
- PubSub_OnMouseButton(node, NULL, &e);
+ PubSub_OnMouseButton(node, nullptr, &e);
}
PubSub_Free(node);
diff --git a/winpr/libwinpr/utils/test/TestStream.c b/winpr/libwinpr/utils/test/TestStream.c
index 55104eab6..5c9123a25 100644
--- a/winpr/libwinpr/utils/test/TestStream.c
+++ b/winpr/libwinpr/utils/test/TestStream.c
@@ -5,13 +5,13 @@
static BOOL TestStream_Verify(wStream* s, size_t mincap, size_t len, size_t pos)
{
- if (Stream_Buffer(s) == NULL)
+ if (Stream_Buffer(s) == nullptr)
{
printf("stream buffer is null\n");
return FALSE;
}
- if (Stream_ConstPointer(s) == NULL)
+ if (Stream_ConstPointer(s) == nullptr)
{
printf("stream pointer is null\n");
return FALSE;
@@ -79,7 +79,7 @@ static BOOL TestStream_Verify(wStream* s, size_t mincap, size_t len, size_t pos)
static BOOL TestStream_New(void)
{
/* Test creation of a 0-size stream with no buffer */
- wStream* s = Stream_New(NULL, 0);
+ wStream* s = Stream_New(nullptr, 0);
if (s)
return FALSE;
@@ -139,8 +139,8 @@ static BOOL TestStream_Create(size_t count, BOOL selfAlloc)
{
size_t len = 0;
size_t cap = 0;
- wStream* s = NULL;
- void* buffer = NULL;
+ wStream* s = nullptr;
+ void* buffer = nullptr;
for (size_t i = 0; i < count; i++)
{
@@ -155,7 +155,7 @@ static BOOL TestStream_Create(size_t count, BOOL selfAlloc)
}
}
- if (!(s = Stream_New(selfAlloc ? buffer : NULL, len)))
+ if (!(s = Stream_New(selfAlloc ? buffer : nullptr, len)))
{
printf("%s: Stream_New failed for stream #%" PRIuz "\n", __func__, i);
goto fail;
@@ -188,7 +188,7 @@ static BOOL TestStream_Create(size_t count, BOOL selfAlloc)
}
}
- Stream_Free(s, buffer == NULL);
+ Stream_Free(s, buffer == nullptr);
free(buffer);
}
@@ -198,7 +198,7 @@ fail:
if (s)
{
- Stream_Free(s, buffer == NULL);
+ Stream_Free(s, buffer == nullptr);
}
return FALSE;
@@ -206,10 +206,10 @@ fail:
static BOOL TestStream_Extent(UINT32 maxSize)
{
- wStream* s = NULL;
+ wStream* s = nullptr;
BOOL result = FALSE;
- if (!(s = Stream_New(NULL, 1)))
+ if (!(s = Stream_New(nullptr, 1)))
{
printf("%s: Stream_New failed\n", __func__);
return FALSE;
@@ -333,7 +333,7 @@ static BOOL TestStream_WriteAndRead(UINT64 value)
} val;
val.u64 = value;
- wStream* s = Stream_New(NULL, 1024);
+ wStream* s = Stream_New(nullptr, 1024);
if (!s)
return FALSE;
BOOL rc = FALSE;
@@ -460,7 +460,7 @@ fail:
static BOOL TestStream_Reading(void)
{
BYTE src[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
- wStream* s = NULL;
+ wStream* s = nullptr;
BOOL result = TRUE;
if (!(s = Stream_New(src, sizeof(src))))
@@ -489,7 +489,7 @@ static BOOL TestStream_Write(void)
UINT32 u32 = 0;
UINT64 u64 = 0;
const BYTE data[] = "someteststreamdata";
- wStream* s = Stream_New(NULL, 100);
+ wStream* s = Stream_New(nullptr, 100);
if (!s)
goto out;
@@ -578,7 +578,7 @@ out:
static BOOL TestStream_Seek(void)
{
BOOL rc = FALSE;
- wStream* s = Stream_New(NULL, 100);
+ wStream* s = Stream_New(nullptr, 100);
if (!s)
goto out;
@@ -620,7 +620,7 @@ out:
static BOOL TestStream_Rewind(void)
{
BOOL rc = FALSE;
- wStream* s = Stream_New(NULL, 100);
+ wStream* s = Stream_New(nullptr, 100);
if (!s)
goto out;
@@ -668,7 +668,7 @@ static BOOL TestStream_Zero(void)
{
BOOL rc = FALSE;
const BYTE data[] = "someteststreamdata";
- wStream* s = Stream_New(NULL, sizeof(data));
+ wStream* s = Stream_New(nullptr, sizeof(data));
if (!s)
goto out;
@@ -716,7 +716,7 @@ static BOOL TestStream_Fill(void)
BOOL rc = FALSE;
const BYTE fill[7] = "XXXXXXX";
const BYTE data[] = "someteststreamdata";
- wStream* s = Stream_New(NULL, sizeof(data));
+ wStream* s = Stream_New(nullptr, sizeof(data));
if (!s)
goto out;
@@ -757,8 +757,8 @@ static BOOL TestStream_Copy(void)
{
BOOL rc = FALSE;
const BYTE data[] = "someteststreamdata";
- wStream* s = Stream_New(NULL, sizeof(data));
- wStream* d = Stream_New(NULL, sizeof(data));
+ wStream* s = Stream_New(nullptr, sizeof(data));
+ wStream* d = Stream_New(nullptr, sizeof(data));
if (!s || !d)
goto out;
diff --git a/winpr/libwinpr/utils/test/TestVersion.c b/winpr/libwinpr/utils/test/TestVersion.c
index b204b0ff7..a50af7731 100644
--- a/winpr/libwinpr/utils/test/TestVersion.c
+++ b/winpr/libwinpr/utils/test/TestVersion.c
@@ -6,9 +6,9 @@
int TestVersion(int argc, char* argv[])
{
- const char* version = NULL;
- const char* git = NULL;
- const char* build = NULL;
+ const char* version = nullptr;
+ const char* git = nullptr;
+ const char* build = nullptr;
int major = 0;
int minor = 0;
int revision = 0;
diff --git a/winpr/libwinpr/utils/test/TestWLog.c b/winpr/libwinpr/utils/test/TestWLog.c
index f75b85d02..b9a9a504d 100644
--- a/winpr/libwinpr/utils/test/TestWLog.c
+++ b/winpr/libwinpr/utils/test/TestWLog.c
@@ -6,13 +6,13 @@
int TestWLog(int argc, char* argv[])
{
- wLog* root = NULL;
- wLog* logA = NULL;
- wLog* logB = NULL;
- wLogLayout* layout = NULL;
- wLogAppender* appender = NULL;
- char* tmp_path = NULL;
- char* wlog_file = NULL;
+ wLog* root = nullptr;
+ wLog* logA = nullptr;
+ wLog* logB = nullptr;
+ wLogLayout* layout = nullptr;
+ wLogAppender* appender = nullptr;
+ char* tmp_path = nullptr;
+ char* wlog_file = nullptr;
int result = 1;
WINPR_UNUSED(argc);
diff --git a/winpr/libwinpr/utils/test/TestWLogCallback.c b/winpr/libwinpr/utils/test/TestWLogCallback.c
index b1ce67b56..82a0ed8f6 100644
--- a/winpr/libwinpr/utils/test/TestWLogCallback.c
+++ b/winpr/libwinpr/utils/test/TestWLogCallback.c
@@ -10,7 +10,7 @@ typedef struct
char* channel;
} test_t;
-static const char* function = NULL;
+static const char* function = nullptr;
static const char* channels[] = { "com.test.channelA", "com.test.channelB" };
static const test_t messages[] = { { WLOG_INFO, "this is a test", "com.test.channelA" },
@@ -76,11 +76,11 @@ static BOOL CallbackAppenderPackage(const wLogMessage* msg)
int TestWLogCallback(int argc, char* argv[])
{
- wLog* root = NULL;
- wLog* logA = NULL;
- wLog* logB = NULL;
- wLogLayout* layout = NULL;
- wLogAppender* appender = NULL;
+ wLog* root = nullptr;
+ wLog* logA = nullptr;
+ wLog* logB = nullptr;
+ wLogLayout* layout = nullptr;
+ wLogAppender* appender = nullptr;
wLogCallbacks callbacks;
WINPR_UNUSED(argc);
diff --git a/winpr/libwinpr/utils/unwind/debug.c b/winpr/libwinpr/utils/unwind/debug.c
index 8418ac991..0ddb93032 100644
--- a/winpr/libwinpr/utils/unwind/debug.c
+++ b/winpr/libwinpr/utils/unwind/debug.c
@@ -152,7 +152,7 @@ void* winpr_unwind_backtrace(DWORD size)
return ctx;
fail:
winpr_unwind_backtrace_free(ctx);
- return NULL;
+ return nullptr;
}
void winpr_unwind_backtrace_free(void* buffer)
@@ -173,14 +173,14 @@ char** winpr_unwind_backtrace_symbols(void* buffer, size_t* used)
char** cpp;
} cnv;
unwind_context_t* ctx = buffer;
- cnv.cpp = NULL;
+ cnv.cpp = nullptr;
if (!ctx)
- return NULL;
+ return nullptr;
cnv.pv = calloc(ctx->pos * (sizeof(char*) + UNWIND_MAX_LINE_SIZE), sizeof(char*));
if (!cnv.pv)
- return NULL;
+ return nullptr;
if (used)
*used = ctx->pos;
diff --git a/winpr/libwinpr/utils/windows/debug.c b/winpr/libwinpr/utils/windows/debug.c
index 2c3e27ca1..5982e5e8c 100644
--- a/winpr/libwinpr/utils/windows/debug.c
+++ b/winpr/libwinpr/utils/windows/debug.c
@@ -54,7 +54,7 @@ void* winpr_win_backtrace(DWORD size)
t_win_stack* data = calloc(1, sizeof(t_win_stack));
if (!data)
- return NULL;
+ return nullptr;
data->max = size;
data->stack = calloc(data->max, sizeof(PVOID));
@@ -62,11 +62,11 @@ void* winpr_win_backtrace(DWORD size)
if (!data->stack)
{
free(data);
- return NULL;
+ return nullptr;
}
- SymInitialize(process, NULL, TRUE);
- data->used = RtlCaptureStackBackTrace(2, size, data->stack, NULL);
+ SymInitialize(process, nullptr, TRUE);
+ data->used = RtlCaptureStackBackTrace(2, size, data->stack, nullptr);
return data;
}
@@ -76,7 +76,7 @@ char** winpr_win_backtrace_symbols(void* buffer, size_t* used)
*used = 0;
if (!buffer)
- return NULL;
+ return nullptr;
{
size_t line_len = 1024;
@@ -93,7 +93,7 @@ char** winpr_win_backtrace_symbols(void* buffer, size_t* used)
free(vlines);
free(symbol);
free(line);
- return NULL;
+ return nullptr;
}
line->SizeOfStruct = sizeof(IMAGEHLP_LINE64);
@@ -132,7 +132,7 @@ char* winpr_win_strerror(DWORD dw, char* dmsg, size_t size)
{
DWORD nSize = 0;
DWORD dwFlags = 0;
- LPTSTR msg = NULL;
+ LPTSTR msg = nullptr;
BOOL alloc = FALSE;
dwFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
#ifdef FORMAT_MESSAGE_ALLOCATE_BUFFER
@@ -142,13 +142,14 @@ char* winpr_win_strerror(DWORD dw, char* dmsg, size_t size)
nSize = (DWORD)(size * sizeof(WCHAR));
msg = (LPTSTR)calloc(nSize, sizeof(WCHAR));
#endif
- const DWORD rc = FormatMessage(dwFlags, NULL, dw, 0, alloc ? (LPTSTR)&msg : msg, nSize, NULL);
+ const DWORD rc =
+ FormatMessage(dwFlags, nullptr, dw, 0, alloc ? (LPTSTR)&msg : msg, nSize, nullptr);
if (rc > 0)
{
#if defined(UNICODE)
(void)WideCharToMultiByte(CP_ACP, 0, msg, (int)rc, dmsg, (int)(MIN(size - 1, INT_MAX)),
- NULL, NULL);
+ nullptr, nullptr);
#else /* defined(UNICODE) */
memcpy(dmsg, msg, MIN(rc, size - 1));
#endif /* defined(UNICODE) */
diff --git a/winpr/libwinpr/utils/winpr.c b/winpr/libwinpr/utils/winpr.c
index 552273436..81b212ad6 100644
--- a/winpr/libwinpr/utils/winpr.c
+++ b/winpr/libwinpr/utils/winpr.c
@@ -67,7 +67,7 @@ static BOOL CALLBACK init_app_details(WINPR_ATTR_UNUSED PINIT_ONCE once,
WINPR_ATTR_NODISCARD
static BOOL initializeApplicationDetails(void)
{
- InitOnceExecuteOnce(&s_winpr_app_details_once, init_app_details, NULL, NULL);
+ InitOnceExecuteOnce(&s_winpr_app_details_once, init_app_details, nullptr, nullptr);
return TRUE;
}
@@ -97,14 +97,14 @@ BOOL winpr_setApplicationDetails(const char* vendor, const char* product, SSIZE_
const char* winpr_getApplicationDetailsVendor(void)
{
if (!initializeApplicationDetails())
- return NULL;
+ return nullptr;
return s_winpr_vendor_string;
}
const char* winpr_getApplicationDetailsProduct(void)
{
if (!initializeApplicationDetails())
- return NULL;
+ return nullptr;
return s_winpr_product_string;
}
@@ -112,9 +112,9 @@ char* winpr_getApplicatonDetailsRegKey(const char* fmt)
{
char* val = winpr_getApplicatonDetailsCombined('\\');
if (!val)
- return NULL;
+ return nullptr;
- char* str = NULL;
+ char* str = nullptr;
size_t slen = 0;
(void)winpr_asprintf(&str, &slen, fmt, val);
free(val);
@@ -128,7 +128,7 @@ char* winpr_getApplicatonDetailsCombined(char separator)
const char* product = winpr_getApplicationDetailsProduct();
size_t slen = 0;
- char* str = NULL;
+ char* str = nullptr;
if (version < 0)
{
(void)winpr_asprintf(&str, &slen, "%s%c%s", vendor, separator, product);
diff --git a/winpr/libwinpr/utils/wlog/Appender.c b/winpr/libwinpr/utils/wlog/Appender.c
index 7b99f5ef7..8c463e150 100644
--- a/winpr/libwinpr/utils/wlog/Appender.c
+++ b/winpr/libwinpr/utils/wlog/Appender.c
@@ -29,7 +29,7 @@ void WLog_Appender_Free(wLog* log, wLogAppender* appender)
if (appender->Layout)
{
WLog_Layout_Free(log, appender->Layout);
- appender->Layout = NULL;
+ appender->Layout = nullptr;
}
DeleteCriticalSection(&appender->lock);
@@ -39,7 +39,7 @@ void WLog_Appender_Free(wLog* log, wLogAppender* appender)
wLogAppender* WLog_GetLogAppender(wLog* log)
{
if (!log)
- return NULL;
+ return nullptr;
if (!log->Appender)
return WLog_GetLogAppender(log->Parent);
@@ -50,7 +50,7 @@ wLogAppender* WLog_GetLogAppender(wLog* log)
BOOL WLog_OpenAppender(wLog* log)
{
int status = 0;
- wLogAppender* appender = NULL;
+ wLogAppender* appender = nullptr;
appender = WLog_GetLogAppender(log);
@@ -72,7 +72,7 @@ BOOL WLog_OpenAppender(wLog* log)
BOOL WLog_CloseAppender(wLog* log)
{
int status = 0;
- wLogAppender* appender = NULL;
+ wLogAppender* appender = nullptr;
appender = WLog_GetLogAppender(log);
@@ -93,10 +93,10 @@ BOOL WLog_CloseAppender(wLog* log)
static wLogAppender* WLog_Appender_New(wLog* log, DWORD logAppenderType)
{
- wLogAppender* appender = NULL;
+ wLogAppender* appender = nullptr;
if (!log)
- return NULL;
+ return nullptr;
switch (logAppenderType)
{
@@ -128,7 +128,7 @@ static wLogAppender* WLog_Appender_New(wLog* log, DWORD logAppenderType)
default:
(void)fprintf(stderr, "%s: unknown handler type %" PRIu32 "\n", __func__,
logAppenderType);
- appender = NULL;
+ appender = nullptr;
break;
}
@@ -136,12 +136,12 @@ static wLogAppender* WLog_Appender_New(wLog* log, DWORD logAppenderType)
appender = WLog_ConsoleAppender_New(log);
if (!appender)
- return NULL;
+ return nullptr;
if (!(appender->Layout = WLog_Layout_New(log)))
{
WLog_Appender_Free(log, appender);
- return NULL;
+ return nullptr;
}
InitializeCriticalSectionAndSpinCount(&appender->lock, 4000);
@@ -157,11 +157,11 @@ BOOL WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType)
if (log->Appender)
{
WLog_Appender_Free(log, log->Appender);
- log->Appender = NULL;
+ log->Appender = nullptr;
}
log->Appender = WLog_Appender_New(log, logAppenderType);
- return log->Appender != NULL;
+ return log->Appender != nullptr;
}
BOOL WLog_ConfigureAppender(wLogAppender* appender, const char* setting, void* value)
diff --git a/winpr/libwinpr/utils/wlog/BinaryAppender.c b/winpr/libwinpr/utils/wlog/BinaryAppender.c
index 34b35d941..200e2f295 100644
--- a/winpr/libwinpr/utils/wlog/BinaryAppender.c
+++ b/winpr/libwinpr/utils/wlog/BinaryAppender.c
@@ -40,7 +40,7 @@ typedef struct
static BOOL WLog_BinaryAppender_Open(wLog* log, wLogAppender* appender)
{
- wLogBinaryAppender* binaryAppender = NULL;
+ wLogBinaryAppender* binaryAppender = nullptr;
if (!log || !appender)
return FALSE;
@@ -71,19 +71,19 @@ static BOOL WLog_BinaryAppender_Open(wLog* log, wLogAppender* appender)
if (!winpr_PathFileExists(binaryAppender->FilePath))
{
- if (!winpr_PathMakePath(binaryAppender->FilePath, 0))
+ if (!winpr_PathMakePath(binaryAppender->FilePath, nullptr))
return FALSE;
UnixChangeFileMode(binaryAppender->FilePath, 0xFFFF);
}
binaryAppender->FileDescriptor = winpr_fopen(binaryAppender->FullFileName, "a+");
- return binaryAppender->FileDescriptor != NULL;
+ return binaryAppender->FileDescriptor != nullptr;
}
static BOOL WLog_BinaryAppender_Close(WINPR_ATTR_UNUSED wLog* log, wLogAppender* appender)
{
- wLogBinaryAppender* binaryAppender = NULL;
+ wLogBinaryAppender* binaryAppender = nullptr;
if (!appender)
return FALSE;
@@ -95,7 +95,7 @@ static BOOL WLog_BinaryAppender_Close(WINPR_ATTR_UNUSED wLog* log, wLogAppender*
if (binaryAppender->FileDescriptor)
(void)fclose(binaryAppender->FileDescriptor);
- binaryAppender->FileDescriptor = NULL;
+ binaryAppender->FileDescriptor = nullptr;
return TRUE;
}
@@ -103,14 +103,14 @@ static BOOL WLog_BinaryAppender_Close(WINPR_ATTR_UNUSED wLog* log, wLogAppender*
static BOOL WLog_BinaryAppender_WriteMessage(wLog* log, wLogAppender* appender,
const wLogMessage* message)
{
- FILE* fp = NULL;
- wStream* s = NULL;
+ FILE* fp = nullptr;
+ wStream* s = nullptr;
size_t MessageLength = 0;
size_t FileNameLength = 0;
size_t FunctionNameLength = 0;
size_t TextStringLength = 0;
BOOL ret = TRUE;
- wLogBinaryAppender* binaryAppender = NULL;
+ wLogBinaryAppender* binaryAppender = nullptr;
if (!log || !appender || !message)
return FALSE;
@@ -133,7 +133,7 @@ static BOOL WLog_BinaryAppender_WriteMessage(wLog* log, wLogAppender* appender,
(FunctionNameLength > UINT32_MAX) || (TextStringLength > UINT32_MAX))
return FALSE;
- s = Stream_New(NULL, MessageLength);
+ s = Stream_New(nullptr, MessageLength);
if (!s)
return FALSE;
@@ -206,7 +206,7 @@ static BOOL WLog_BinaryAppender_Set(wLogAppender* appender, const char* setting,
static void WLog_BinaryAppender_Free(wLogAppender* appender)
{
- wLogBinaryAppender* binaryAppender = NULL;
+ wLogBinaryAppender* binaryAppender = nullptr;
if (appender)
{
binaryAppender = (wLogBinaryAppender*)appender;
@@ -221,7 +221,7 @@ wLogAppender* WLog_BinaryAppender_New(WINPR_ATTR_UNUSED wLog* log)
{
wLogBinaryAppender* BinaryAppender = (wLogBinaryAppender*)calloc(1, sizeof(wLogBinaryAppender));
if (!BinaryAppender)
- return NULL;
+ return nullptr;
BinaryAppender->common.Type = WLOG_APPENDER_BINARY;
BinaryAppender->common.Open = WLog_BinaryAppender_Open;
diff --git a/winpr/libwinpr/utils/wlog/CallbackAppender.c b/winpr/libwinpr/utils/wlog/CallbackAppender.c
index 2034e5af9..72ddff98e 100644
--- a/winpr/libwinpr/utils/wlog/CallbackAppender.c
+++ b/winpr/libwinpr/utils/wlog/CallbackAppender.c
@@ -142,7 +142,7 @@ static BOOL WLog_CallbackAppender_Set(wLogAppender* appender, const char* settin
static void WLog_CallbackAppender_Free(wLogAppender* appender)
{
- wLogCallbackAppender* callbackAppender = NULL;
+ wLogCallbackAppender* callbackAppender = nullptr;
if (!appender)
{
return;
@@ -159,7 +159,7 @@ wLogAppender* WLog_CallbackAppender_New(WINPR_ATTR_UNUSED wLog* log)
wLogCallbackAppender* CallbackAppender =
(wLogCallbackAppender*)calloc(1, sizeof(wLogCallbackAppender));
if (!CallbackAppender)
- return NULL;
+ return nullptr;
CallbackAppender->common.Type = WLOG_APPENDER_CALLBACK;
CallbackAppender->common.Open = WLog_CallbackAppender_Open;
diff --git a/winpr/libwinpr/utils/wlog/ConsoleAppender.c b/winpr/libwinpr/utils/wlog/ConsoleAppender.c
index cb49b5096..75cfb8dc4 100644
--- a/winpr/libwinpr/utils/wlog/ConsoleAppender.c
+++ b/winpr/libwinpr/utils/wlog/ConsoleAppender.c
@@ -105,7 +105,7 @@ static BOOL WLog_ConsoleAppender_WriteMessage(wLog* log, wLogAppender* appender,
__android_log_print(level, log->Name, "%s%s", prefix, cmessage->TextString);
#else
- FILE* fp = NULL;
+ FILE* fp = nullptr;
switch (consoleAppender->outputStream)
{
case WLOG_CONSOLE_STDOUT:
@@ -145,7 +145,7 @@ static BOOL WLog_ConsoleAppender_WriteDataMessage(WINPR_ATTR_UNUSED wLog* log,
return FALSE;
#else
int DataId = 0;
- char* FullFileName = NULL;
+ char* FullFileName = nullptr;
DataId = g_DataId++;
FullFileName = WLog_Message_GetOutputFileName(DataId, "dat");
@@ -168,7 +168,7 @@ static BOOL WLog_ConsoleAppender_WriteImageMessage(WINPR_ATTR_UNUSED wLog* log,
return FALSE;
#else
int ImageId = 0;
- char* FullFileName = NULL;
+ char* FullFileName = nullptr;
ImageId = g_ImageId++;
FullFileName = WLog_Message_GetOutputFileName(ImageId, "bmp");
@@ -191,7 +191,7 @@ static BOOL WLog_ConsoleAppender_WritePacketMessage(WINPR_ATTR_UNUSED wLog* log,
#if defined(ANDROID)
return FALSE;
#else
- char* FullFileName = NULL;
+ char* FullFileName = nullptr;
g_PacketId++;
@@ -253,7 +253,7 @@ wLogAppender* WLog_ConsoleAppender_New(WINPR_ATTR_UNUSED wLog* log)
(wLogConsoleAppender*)calloc(1, sizeof(wLogConsoleAppender));
if (!ConsoleAppender)
- return NULL;
+ return nullptr;
ConsoleAppender->common.Type = WLOG_APPENDER_CONSOLE;
ConsoleAppender->common.Open = WLog_ConsoleAppender_Open;
diff --git a/winpr/libwinpr/utils/wlog/DataMessage.c b/winpr/libwinpr/utils/wlog/DataMessage.c
index b1da83f65..db35719fc 100644
--- a/winpr/libwinpr/utils/wlog/DataMessage.c
+++ b/winpr/libwinpr/utils/wlog/DataMessage.c
@@ -27,7 +27,7 @@
BOOL WLog_DataMessage_Write(const char* filename, const void* data, size_t length)
{
- FILE* fp = NULL;
+ FILE* fp = nullptr;
BOOL ret = TRUE;
fp = winpr_fopen(filename, "w+b");
diff --git a/winpr/libwinpr/utils/wlog/FileAppender.c b/winpr/libwinpr/utils/wlog/FileAppender.c
index ccb6df381..9c89412cd 100644
--- a/winpr/libwinpr/utils/wlog/FileAppender.c
+++ b/winpr/libwinpr/utils/wlog/FileAppender.c
@@ -44,19 +44,19 @@ static BOOL WLog_FileAppender_SetOutputFileName(wLogFileAppender* appender, cons
appender->FileName = _strdup(filename);
- return appender->FileName != NULL;
+ return appender->FileName != nullptr;
}
static BOOL WLog_FileAppender_SetOutputFilePath(wLogFileAppender* appender, const char* filepath)
{
appender->FilePath = _strdup(filepath);
- return appender->FilePath != NULL;
+ return appender->FilePath != nullptr;
}
static BOOL WLog_FileAppender_Open(wLog* log, wLogAppender* appender)
{
- wLogFileAppender* fileAppender = NULL;
+ wLogFileAppender* fileAppender = nullptr;
if (!log || !appender)
return FALSE;
@@ -92,7 +92,7 @@ static BOOL WLog_FileAppender_Open(wLog* log, wLogAppender* appender)
if (!winpr_PathFileExists(fileAppender->FilePath))
{
- if (!winpr_PathMakePath(fileAppender->FilePath, 0))
+ if (!winpr_PathMakePath(fileAppender->FilePath, nullptr))
return FALSE;
UnixChangeFileMode(fileAppender->FilePath, 0xFFFF);
@@ -100,12 +100,12 @@ static BOOL WLog_FileAppender_Open(wLog* log, wLogAppender* appender)
fileAppender->FileDescriptor = winpr_fopen(fileAppender->FullFileName, "a+");
- return fileAppender->FileDescriptor != NULL;
+ return fileAppender->FileDescriptor != nullptr;
}
static BOOL WLog_FileAppender_Close(wLog* log, wLogAppender* appender)
{
- wLogFileAppender* fileAppender = NULL;
+ wLogFileAppender* fileAppender = nullptr;
if (!log || !appender)
return FALSE;
@@ -116,7 +116,7 @@ static BOOL WLog_FileAppender_Close(wLog* log, wLogAppender* appender)
return TRUE;
(void)fclose(fileAppender->FileDescriptor);
- fileAppender->FileDescriptor = NULL;
+ fileAppender->FileDescriptor = nullptr;
return TRUE;
}
@@ -145,7 +145,7 @@ static BOOL WLog_FileAppender_WriteDataMessage(wLog* log, wLogAppender* appender
const wLogMessage* message)
{
int DataId = 0;
- char* FullFileName = NULL;
+ char* FullFileName = nullptr;
if (!log || !appender || !message)
return FALSE;
@@ -163,7 +163,7 @@ static BOOL WLog_FileAppender_WriteImageMessage(wLog* log, wLogAppender* appende
const wLogMessage* message)
{
int ImageId = 0;
- char* FullFileName = NULL;
+ char* FullFileName = nullptr;
if (!log || !appender || !message)
return FALSE;
@@ -195,7 +195,7 @@ static BOOL WLog_FileAppender_Set(wLogAppender* appender, const char* setting, v
static void WLog_FileAppender_Free(wLogAppender* appender)
{
- wLogFileAppender* fileAppender = NULL;
+ wLogFileAppender* fileAppender = nullptr;
if (appender)
{
@@ -209,14 +209,14 @@ static void WLog_FileAppender_Free(wLogAppender* appender)
wLogAppender* WLog_FileAppender_New(WINPR_ATTR_UNUSED wLog* log)
{
- LPSTR env = NULL;
- LPCSTR name = NULL;
+ LPSTR env = nullptr;
+ LPCSTR name = nullptr;
DWORD nSize = 0;
- wLogFileAppender* FileAppender = NULL;
+ wLogFileAppender* FileAppender = nullptr;
FileAppender = (wLogFileAppender*)calloc(1, sizeof(wLogFileAppender));
if (!FileAppender)
- return NULL;
+ return nullptr;
FileAppender->common.Type = WLOG_APPENDER_FILE;
FileAppender->common.Open = WLog_FileAppender_Open;
@@ -227,7 +227,7 @@ wLogAppender* WLog_FileAppender_New(WINPR_ATTR_UNUSED wLog* log)
FileAppender->common.Free = WLog_FileAppender_Free;
FileAppender->common.Set = WLog_FileAppender_Set;
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_PATH";
- nSize = GetEnvironmentVariableA(name, NULL, 0);
+ nSize = GetEnvironmentVariableA(name, nullptr, 0);
if (nSize)
{
@@ -251,7 +251,7 @@ wLogAppender* WLog_FileAppender_New(WINPR_ATTR_UNUSED wLog* log)
}
name = "WLOG_FILEAPPENDER_OUTPUT_FILE_NAME";
- nSize = GetEnvironmentVariableA(name, NULL, 0);
+ nSize = GetEnvironmentVariableA(name, nullptr, 0);
if (nSize)
{
@@ -274,5 +274,5 @@ error_output_file_name:
free(FileAppender->FilePath);
error_free:
free(FileAppender);
- return NULL;
+ return nullptr;
}
diff --git a/winpr/libwinpr/utils/wlog/JournaldAppender.c b/winpr/libwinpr/utils/wlog/JournaldAppender.c
index 5c51b586a..b0d468b85 100644
--- a/winpr/libwinpr/utils/wlog/JournaldAppender.c
+++ b/winpr/libwinpr/utils/wlog/JournaldAppender.c
@@ -39,7 +39,7 @@ typedef struct
static BOOL WLog_JournaldAppender_Open(wLog* log, wLogAppender* appender)
{
int fd = 0;
- wLogJournaldAppender* journaldAppender = NULL;
+ wLogJournaldAppender* journaldAppender = nullptr;
if (!log || !appender)
return FALSE;
@@ -59,7 +59,7 @@ static BOOL WLog_JournaldAppender_Open(wLog* log, wLogAppender* appender)
return FALSE;
}
- setbuffer(journaldAppender->stream, NULL, 0);
+ setbuffer(journaldAppender->stream, nullptr, 0);
return TRUE;
}
@@ -74,8 +74,8 @@ static BOOL WLog_JournaldAppender_Close(wLog* log, wLogAppender* appender)
free(journaldAppender->identifier);
- journaldAppender->stream = NULL;
- journaldAppender->identifier = NULL;
+ journaldAppender->stream = nullptr;
+ journaldAppender->identifier = nullptr;
return TRUE;
}
@@ -87,7 +87,7 @@ static BOOL WLog_JournaldAppender_WriteMessage(wLog* log, wLogAppender* appender
wLogJournaldAppender* journaldAppender = (wLogJournaldAppender*)appender;
- const char* formatStr = NULL;
+ const char* formatStr = nullptr;
switch (cmessage->Level)
{
case WLOG_TRACE:
@@ -164,12 +164,12 @@ static BOOL WLog_JournaldAppender_Set(wLogAppender* appender, const char* settin
if (journaldAppender->identifier)
free(journaldAppender->identifier);
- return ((journaldAppender->identifier = _strdup((const char*)value)) != NULL);
+ return ((journaldAppender->identifier = _strdup((const char*)value)) != nullptr);
}
static void WLog_JournaldAppender_Free(wLogAppender* appender)
{
- wLogJournaldAppender* journaldAppender = NULL;
+ wLogJournaldAppender* journaldAppender = nullptr;
if (appender)
{
journaldAppender = (wLogJournaldAppender*)appender;
@@ -186,7 +186,7 @@ wLogAppender* WLog_JournaldAppender_New(wLog* log)
wLogJournaldAppender* appender = (wLogJournaldAppender*)calloc(1, sizeof(wLogJournaldAppender));
if (!appender)
- return NULL;
+ return nullptr;
appender->common.Type = WLOG_APPENDER_JOURNALD;
appender->common.Open = WLog_JournaldAppender_Open;
@@ -197,7 +197,7 @@ wLogAppender* WLog_JournaldAppender_New(wLog* log)
appender->common.Set = WLog_JournaldAppender_Set;
appender->common.Free = WLog_JournaldAppender_Free;
- const DWORD nSize = GetEnvironmentVariableA(name, NULL, 0);
+ const DWORD nSize = GetEnvironmentVariableA(name, nullptr, 0);
if (nSize)
{
appender->identifier = (LPSTR)malloc(nSize);
@@ -216,5 +216,5 @@ wLogAppender* WLog_JournaldAppender_New(wLog* log)
error_open:
free(appender->identifier);
free(appender);
- return NULL;
+ return nullptr;
}
diff --git a/winpr/libwinpr/utils/wlog/Layout.c b/winpr/libwinpr/utils/wlog/Layout.c
index b4b1f47ea..b7a0a563f 100644
--- a/winpr/libwinpr/utils/wlog/Layout.c
+++ b/winpr/libwinpr/utils/wlog/Layout.c
@@ -159,11 +159,11 @@ static const char* skip_if_null(const struct format_option* opt, const char* fmt
const char* str = &fmt[opt->fmtlen]; /* Skip first %{ from string */
const char* end = strstr(str, opt->replace);
if (!end)
- return NULL;
+ return nullptr;
*pskiplen = WINPR_ASSERTING_INT_CAST(size_t, end - fmt) + opt->replacelen;
if (!opt->arg.cpv)
- return NULL;
+ return nullptr;
const size_t replacelen = WINPR_ASSERTING_INT_CAST(size_t, end - str);
@@ -172,7 +172,7 @@ static const char* skip_if_null(const struct format_option* opt, const char* fmt
if (!replace_format_string(buffer, opt->recurse, opt->recurse->buffer,
ARRAYSIZE(opt->recurse->buffer)))
- return NULL;
+ return nullptr;
*preplacelen = strnlen(opt->recurse->buffer, ARRAYSIZE(opt->recurse->buffer));
return opt->recurse->buffer;
@@ -248,7 +248,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, const wLogMessa
GetLocalTime(&localTime);
struct format_option_recurse recurse = {
- .options = NULL, .nroptions = 0, .log = log, .layout = layout, .message = message
+ .options = nullptr, .nroptions = 0, .log = log, .layout = layout, .message = message
};
#define ENTRY(x) x, sizeof(x) - 1
@@ -257,71 +257,95 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, const wLogMessa
ENTRY("%s"),
log->custom,
{ .pv = log->context },
- NULL,
+ nullptr,
&recurse }, /* log context */
{ ENTRY("%dw"),
ENTRY("%u"),
- NULL,
+ nullptr,
{ .s = localTime.wDayOfWeek },
- NULL,
+ nullptr,
&recurse }, /* day of week */
- { ENTRY("%dy"), ENTRY("%u"), NULL, { .s = localTime.wDay }, NULL, &recurse }, /* day of year
- */
- { ENTRY("%fl"), ENTRY("%s"), NULL, { .cpv = message->FileName }, NULL, &recurse }, /* file
- */
+ { ENTRY("%dy"),
+ ENTRY("%u"),
+ nullptr,
+ { .s = localTime.wDay },
+ nullptr,
+ &recurse }, /* day of year
+ */
+ { ENTRY("%fl"),
+ ENTRY("%s"),
+ nullptr,
+ { .cpv = message->FileName },
+ nullptr,
+ &recurse }, /* file
+ */
{ ENTRY("%fn"),
ENTRY("%s"),
- NULL,
+ nullptr,
{ .cpv = message->FunctionName },
- NULL,
- &recurse }, /* function
- */
- { ENTRY("%hr"), ENTRY("%02u"), NULL, { .s = localTime.wHour }, NULL, &recurse }, /* hours */
+ nullptr,
+ &recurse }, /* function
+ */
+ { ENTRY("%hr"),
+ ENTRY("%02u"),
+ nullptr,
+ { .s = localTime.wHour },
+ nullptr,
+ &recurse }, /* hours
+ */
{ ENTRY("%ln"),
ENTRY("%" PRIuz),
- NULL,
+ nullptr,
{ .s = message->LineNumber },
- NULL,
+ nullptr,
&recurse }, /* line number */
{ ENTRY("%lv"),
ENTRY("%s"),
- NULL,
+ nullptr,
{ .cpv = WLOG_LEVELS[message->Level] },
- NULL,
+ nullptr,
&recurse }, /* log level */
{ ENTRY("%mi"),
ENTRY("%02u"),
- NULL,
+ nullptr,
{ .s = localTime.wMinute },
- NULL,
+ nullptr,
&recurse }, /* minutes
*/
{ ENTRY("%ml"),
ENTRY("%03u"),
- NULL,
+ nullptr,
{ .s = localTime.wMilliseconds },
- NULL,
+ nullptr,
&recurse }, /* milliseconds */
- { ENTRY("%mn"), ENTRY("%s"), NULL, { .cpv = log->Name }, NULL, &recurse }, /* module name */
- { ENTRY("%mo"), ENTRY("%u"), NULL, { .s = localTime.wMonth }, NULL, &recurse }, /* month */
+ { ENTRY("%mn"), ENTRY("%s"), nullptr, { .cpv = log->Name }, nullptr, &recurse }, /* module
+ name */
+ { ENTRY("%mo"),
+ ENTRY("%u"),
+ nullptr,
+ { .s = localTime.wMonth },
+ nullptr,
+ &recurse }, /* month
+ */
{ ENTRY("%pid"),
ENTRY("%u"),
- NULL,
+ nullptr,
{ .s = GetCurrentProcessId() },
- NULL,
+ nullptr,
&recurse }, /* process id */
{ ENTRY("%se"),
ENTRY("%02u"),
- NULL,
+ nullptr,
{ .s = localTime.wSecond },
- NULL,
- &recurse }, /* seconds
- */
- { ENTRY("%tid"), ENTRY("%s"), get_tid, { .pv = &targ }, NULL, &recurse }, /* thread id */
- { ENTRY("%yr"), ENTRY("%u"), NULL, { .s = localTime.wYear }, NULL, &recurse }, /* year */
+ nullptr,
+ &recurse }, /* seconds
+ */
+ { ENTRY("%tid"), ENTRY("%s"), get_tid, { .pv = &targ }, nullptr, &recurse }, /* thread id */
+ { ENTRY("%yr"), ENTRY("%u"), nullptr, { .s = localTime.wYear }, nullptr, &recurse }, /* year
+ */
{ ENTRY("%{"),
ENTRY("%}"),
- NULL,
+ nullptr,
{ .pv = log->context },
skip_if_null,
&recurse }, /* skip if no context */
@@ -345,7 +369,7 @@ BOOL WLog_Layout_GetMessagePrefix(wLog* log, wLogLayout* layout, const wLogMessa
wLogLayout* WLog_GetLogLayout(wLog* log)
{
- wLogAppender* appender = NULL;
+ wLogAppender* appender = nullptr;
appender = WLog_GetLogAppender(log);
return appender->Layout;
}
@@ -354,7 +378,7 @@ BOOL WLog_Layout_SetPrefixFormat(WINPR_ATTR_UNUSED wLog* log, wLogLayout* layout
const char* format)
{
free(layout->FormatString);
- layout->FormatString = NULL;
+ layout->FormatString = nullptr;
if (format)
{
@@ -371,14 +395,14 @@ wLogLayout* WLog_Layout_New(WINPR_ATTR_UNUSED wLog* log)
{
LPCSTR prefix = "WLOG_PREFIX";
DWORD nSize = 0;
- char* env = NULL;
- wLogLayout* layout = NULL;
+ char* env = nullptr;
+ wLogLayout* layout = nullptr;
layout = (wLogLayout*)calloc(1, sizeof(wLogLayout));
if (!layout)
- return NULL;
+ return nullptr;
- nSize = GetEnvironmentVariableA(prefix, NULL, 0);
+ nSize = GetEnvironmentVariableA(prefix, nullptr, 0);
if (nSize)
{
@@ -387,14 +411,14 @@ wLogLayout* WLog_Layout_New(WINPR_ATTR_UNUSED wLog* log)
if (!env)
{
free(layout);
- return NULL;
+ return nullptr;
}
if (GetEnvironmentVariableA(prefix, env, nSize) != nSize - 1)
{
free(env);
free(layout);
- return NULL;
+ return nullptr;
}
}
@@ -412,7 +436,7 @@ wLogLayout* WLog_Layout_New(WINPR_ATTR_UNUSED wLog* log)
if (!layout->FormatString)
{
free(layout);
- return NULL;
+ return nullptr;
}
}
@@ -426,7 +450,7 @@ void WLog_Layout_Free(WINPR_ATTR_UNUSED wLog* log, wLogLayout* layout)
if (layout->FormatString)
{
free(layout->FormatString);
- layout->FormatString = NULL;
+ layout->FormatString = nullptr;
}
free(layout);
diff --git a/winpr/libwinpr/utils/wlog/Message.c b/winpr/libwinpr/utils/wlog/Message.c
index ab3b5afed..bebba4c79 100644
--- a/winpr/libwinpr/utils/wlog/Message.c
+++ b/winpr/libwinpr/utils/wlog/Message.c
@@ -30,22 +30,22 @@
char* WLog_Message_GetOutputFileName(int id, const char* ext)
{
DWORD ProcessId = 0;
- char* FilePath = NULL;
- char* FileName = NULL;
- char* FullFileName = NULL;
+ char* FilePath = nullptr;
+ char* FileName = nullptr;
+ char* FullFileName = nullptr;
if (!(FileName = (char*)malloc(256)))
- return NULL;
+ return nullptr;
FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog");
if (!winpr_PathFileExists(FilePath))
{
- if (!winpr_PathMakePath(FilePath, NULL))
+ if (!winpr_PathMakePath(FilePath, nullptr))
{
free(FileName);
free(FilePath);
- return NULL;
+ return nullptr;
}
}
diff --git a/winpr/libwinpr/utils/wlog/PacketMessage.c b/winpr/libwinpr/utils/wlog/PacketMessage.c
index 28a84fc3f..80e97caf8 100644
--- a/winpr/libwinpr/utils/wlog/PacketMessage.c
+++ b/winpr/libwinpr/utils/wlog/PacketMessage.c
@@ -61,13 +61,13 @@ static BOOL Pcap_Write_Record(wPcap* pcap, wPcapRecord* record)
wPcap* Pcap_Open(char* name, BOOL write)
{
- wPcap* pcap = NULL;
+ wPcap* pcap = nullptr;
FILE* pcap_fp = winpr_fopen(name, write ? "w+b" : "rb");
if (!pcap_fp)
{
WLog_ERR(TAG, "opening pcap file");
- return NULL;
+ return nullptr;
}
pcap = (wPcap*)calloc(1, sizeof(wPcap));
@@ -111,7 +111,7 @@ out_fail:
if (pcap_fp)
(void)fclose(pcap_fp);
free(pcap);
- return NULL;
+ return nullptr;
}
void Pcap_Flush(wPcap* pcap)
@@ -141,7 +141,7 @@ void Pcap_Close(wPcap* pcap)
static BOOL WLog_PacketMessage_Write_EthernetHeader(wPcap* pcap, wEthernetHeader* ethernet)
{
- wStream* s = NULL;
+ wStream* s = nullptr;
wStream sbuffer = WINPR_C_ARRAY_INIT;
BYTE buffer[14] = WINPR_C_ARRAY_INIT;
BOOL ret = TRUE;
@@ -184,7 +184,7 @@ static UINT16 IPv4Checksum(const BYTE* ipv4, int length)
static BOOL WLog_PacketMessage_Write_IPv4Header(wPcap* pcap, wIPv4Header* ipv4)
{
- wStream* s = NULL;
+ wStream* s = nullptr;
wStream sbuffer = WINPR_C_ARRAY_INIT;
BYTE buffer[20] = WINPR_C_ARRAY_INIT;
int ret = TRUE;
@@ -217,7 +217,7 @@ static BOOL WLog_PacketMessage_Write_IPv4Header(wPcap* pcap, wIPv4Header* ipv4)
static BOOL WLog_PacketMessage_Write_TcpHeader(wPcap* pcap, wTcpHeader* tcp)
{
- wStream* s = NULL;
+ wStream* s = nullptr;
wStream sbuffer = WINPR_C_ARRAY_INIT;
BYTE buffer[20] = WINPR_C_ARRAY_INIT;
BOOL ret = TRUE;
@@ -350,7 +350,7 @@ BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, size_t length, DWORD flag
const uint32_t rloff = WINPR_ASSERTING_INT_CAST(uint32_t, record.length + offset);
record.header.incl_len = rloff;
record.header.orig_len = rloff;
- record.next = NULL;
+ record.next = nullptr;
UINT64 ns = winpr_GetUnixTimeNS();
record.header.ts_sec = (UINT32)WINPR_TIME_NS_TO_S(ns);
diff --git a/winpr/libwinpr/utils/wlog/SyslogAppender.c b/winpr/libwinpr/utils/wlog/SyslogAppender.c
index 10826ff55..60ec51c81 100644
--- a/winpr/libwinpr/utils/wlog/SyslogAppender.c
+++ b/winpr/libwinpr/utils/wlog/SyslogAppender.c
@@ -114,7 +114,7 @@ wLogAppender* WLog_SyslogAppender_New(WINPR_ATTR_UNUSED wLog* log)
{
wLogSyslogAppender* appender = (wLogSyslogAppender*)calloc(1, sizeof(wLogSyslogAppender));
if (!appender)
- return NULL;
+ return nullptr;
appender->common.Type = WLOG_APPENDER_SYSLOG;
diff --git a/winpr/libwinpr/utils/wlog/UdpAppender.c b/winpr/libwinpr/utils/wlog/UdpAppender.c
index 69dd0aae8..50a3928c0 100644
--- a/winpr/libwinpr/utils/wlog/UdpAppender.c
+++ b/winpr/libwinpr/utils/wlog/UdpAppender.c
@@ -37,12 +37,12 @@ typedef struct
static BOOL WLog_UdpAppender_Open(WINPR_ATTR_UNUSED wLog* log, wLogAppender* appender)
{
- wLogUdpAppender* udpAppender = NULL;
+ wLogUdpAppender* udpAppender = nullptr;
char addressString[256] = WINPR_C_ARRAY_INIT;
struct addrinfo hints = WINPR_C_ARRAY_INIT;
struct addrinfo* result = WINPR_C_ARRAY_INIT;
int status = 0;
- char* colonPos = NULL;
+ char* colonPos = nullptr;
if (!appender)
return FALSE;
@@ -135,12 +135,12 @@ static BOOL WLog_UdpAppender_Set(wLogAppender* appender, const char* setting, vo
free(udpAppender->host);
udpAppender->host = _strdup((const char*)value);
- return (udpAppender->host != NULL) && WLog_UdpAppender_Open(NULL, appender);
+ return (udpAppender->host != nullptr) && WLog_UdpAppender_Open(nullptr, appender);
}
static void WLog_UdpAppender_Free(wLogAppender* appender)
{
- wLogUdpAppender* udpAppender = NULL;
+ wLogUdpAppender* udpAppender = nullptr;
if (appender)
{
@@ -160,11 +160,11 @@ static void WLog_UdpAppender_Free(wLogAppender* appender)
wLogAppender* WLog_UdpAppender_New(wLog* log)
{
DWORD nSize = 0;
- LPCSTR name = NULL;
+ LPCSTR name = nullptr;
wLogUdpAppender* appender = (wLogUdpAppender*)calloc(1, sizeof(wLogUdpAppender));
if (!appender)
- return NULL;
+ return nullptr;
appender->common.Type = WLOG_APPENDER_UDP;
appender->common.Open = WLog_UdpAppender_Open;
@@ -180,7 +180,7 @@ wLogAppender* WLog_UdpAppender_New(wLog* log)
goto error_sock;
name = "WLOG_UDP_TARGET";
- nSize = GetEnvironmentVariableA(name, NULL, 0);
+ nSize = GetEnvironmentVariableA(name, nullptr, 0);
if (nSize)
{
@@ -209,5 +209,5 @@ error_open:
closesocket(appender->sock);
error_sock:
free(appender);
- return NULL;
+ return nullptr;
}
diff --git a/winpr/libwinpr/utils/wlog/wlog.c b/winpr/libwinpr/utils/wlog/wlog.c
index 62650c32e..e8c4be0d1 100644
--- a/winpr/libwinpr/utils/wlog/wlog.c
+++ b/winpr/libwinpr/utils/wlog/wlog.c
@@ -63,8 +63,8 @@ LPCSTR WLOG_LEVELS[7] = { "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "O
static INIT_ONCE g_WLogInitialized = INIT_ONCE_STATIC_INIT;
static DWORD g_FilterCount = 0;
-static wLogFilter* g_Filters = NULL;
-static wLog* g_RootLog = NULL;
+static wLogFilter* g_Filters = nullptr;
+static wLog* g_RootLog = nullptr;
static wLog* WLog_New(LPCSTR name, wLog* rootLogger);
static void WLog_Free(wLog* log);
@@ -76,7 +76,7 @@ static wLog* WLog_Get_int(wLog* root, LPCSTR name);
static void WLog_Uninit_(void)
{
- wLog* child = NULL;
+ wLog* child = nullptr;
wLog* root = g_RootLog;
if (!root)
@@ -89,7 +89,7 @@ static void WLog_Uninit_(void)
}
WLog_Free(root);
- g_RootLog = NULL;
+ g_RootLog = nullptr;
}
static void WLog_Lock(wLog* log)
@@ -106,7 +106,7 @@ static void WLog_Unlock(wLog* log)
static BOOL CALLBACK WLog_InitializeRoot(PINIT_ONCE InitOnce, PVOID Parameter, PVOID* Context)
{
- char* env = NULL;
+ char* env = nullptr;
DWORD nSize = 0;
DWORD logAppenderType = 0;
LPCSTR appender = "WLOG_APPENDER";
@@ -115,12 +115,12 @@ static BOOL CALLBACK WLog_InitializeRoot(PINIT_ONCE InitOnce, PVOID Parameter, P
WINPR_UNUSED(Parameter);
WINPR_UNUSED(Context);
- if (!(g_RootLog = WLog_New("", NULL)))
+ if (!(g_RootLog = WLog_New("", nullptr)))
return FALSE;
g_RootLog->IsRoot = TRUE;
logAppenderType = WLOG_APPENDER_CONSOLE;
- nSize = GetEnvironmentVariableA(appender, NULL, 0);
+ nSize = GetEnvironmentVariableA(appender, nullptr, 0);
if (nSize)
{
@@ -176,7 +176,7 @@ fail:
static BOOL log_recursion(LPCSTR file, LPCSTR fkt, size_t line)
{
BOOL status = FALSE;
- char** msg = NULL;
+ char** msg = nullptr;
size_t used = 0;
void* bt = winpr_backtrace(20);
#if defined(ANDROID)
@@ -286,7 +286,7 @@ static BOOL WLog_WriteData(wLog* log, const wLogMessage* message)
static BOOL WLog_WriteImage(wLog* log, wLogMessage* message)
{
BOOL status = 0;
- wLogAppender* appender = NULL;
+ wLogAppender* appender = nullptr;
appender = WLog_GetLogAppender(log);
if (!appender)
@@ -317,7 +317,7 @@ static BOOL WLog_WriteImage(wLog* log, wLogMessage* message)
static BOOL WLog_WritePacket(wLog* log, wLogMessage* message)
{
BOOL status = 0;
- wLogAppender* appender = NULL;
+ wLogAppender* appender = nullptr;
appender = WLog_GetLogAppender(log);
if (!appender)
@@ -513,8 +513,8 @@ static BOOL WLog_reset_log_filters(wLog* log)
static BOOL WLog_AddStringLogFilters_int(wLog* root, LPCSTR filter)
{
- LPSTR p = NULL;
- LPCSTR filterStr = NULL;
+ LPSTR p = nullptr;
+ LPCSTR filterStr = nullptr;
if (!filter)
return FALSE;
@@ -522,7 +522,7 @@ static BOOL WLog_AddStringLogFilters_int(wLog* root, LPCSTR filter)
DWORD count = 1;
LPCSTR cpp = filter;
- while ((cpp = strchr(cpp, ',')) != NULL)
+ while ((cpp = strchr(cpp, ',')) != nullptr)
{
count++;
cpp++;
@@ -567,7 +567,7 @@ static BOOL WLog_AddStringLogFilters_int(wLog* root, LPCSTR filter)
filterStr = p + 1;
p++;
}
- } while (p != NULL);
+ } while (p != nullptr);
g_FilterCount = size;
free(cp);
@@ -651,11 +651,11 @@ int WLog_ParseLogLevel(LPCSTR level)
BOOL WLog_ParseFilter(wLog* root, wLogFilter* filter, LPCSTR name)
{
- const char* pc = NULL;
- char* p = NULL;
- char* q = NULL;
+ const char* pc = nullptr;
+ char* p = nullptr;
+ char* q = nullptr;
size_t count = 0;
- LPSTR names = NULL;
+ LPSTR names = nullptr;
int iLevel = 0;
count = 1;
@@ -668,7 +668,7 @@ BOOL WLog_ParseFilter(wLog* root, wLogFilter* filter, LPCSTR name)
if (pc)
{
- while ((pc = strchr(pc, '.')) != NULL)
+ while ((pc = strchr(pc, '.')) != nullptr)
{
count++;
pc++;
@@ -690,7 +690,7 @@ BOOL WLog_ParseFilter(wLog* root, wLogFilter* filter, LPCSTR name)
return FALSE;
}
- filter->Names[count] = NULL;
+ filter->Names[count] = nullptr;
count = 0;
p = (char*)names;
filter->Names[count++] = p;
@@ -700,7 +700,7 @@ BOOL WLog_ParseFilter(wLog* root, wLogFilter* filter, LPCSTR name)
{
free(names);
free((void*)filter->Names);
- filter->Names = NULL;
+ filter->Names = nullptr;
filter->NameCount = 0;
return FALSE;
}
@@ -713,14 +713,14 @@ BOOL WLog_ParseFilter(wLog* root, wLogFilter* filter, LPCSTR name)
{
free(names);
free((void*)filter->Names);
- filter->Names = NULL;
+ filter->Names = nullptr;
filter->NameCount = 0;
return FALSE;
}
filter->Level = (DWORD)iLevel;
- while ((p = strchr(p, '.')) != NULL)
+ while ((p = strchr(p, '.')) != nullptr)
{
if (count < filter->NameCount)
filter->Names[count++] = p + 1;
@@ -736,12 +736,12 @@ BOOL WLog_ParseFilters(wLog* root)
{
LPCSTR filter = "WLOG_FILTER";
BOOL res = FALSE;
- char* env = NULL;
+ char* env = nullptr;
DWORD nSize = 0;
free(g_Filters);
- g_Filters = NULL;
+ g_Filters = nullptr;
g_FilterCount = 0;
- nSize = GetEnvironmentVariableA(filter, NULL, 0);
+ nSize = GetEnvironmentVariableA(filter, nullptr, 0);
if (nSize < 1)
return TRUE;
@@ -807,11 +807,11 @@ LONG WLog_GetFilterLogLevel(wLog* log)
static BOOL WLog_ParseName(wLog* log, LPCSTR name)
{
const char* cp = name;
- char* p = NULL;
+ char* p = nullptr;
size_t count = 1;
- LPSTR names = NULL;
+ LPSTR names = nullptr;
- while ((cp = strchr(cp, '.')) != NULL)
+ while ((cp = strchr(cp, '.')) != nullptr)
{
count++;
cp++;
@@ -831,12 +831,12 @@ static BOOL WLog_ParseName(wLog* log, LPCSTR name)
return FALSE;
}
- log->Names[count] = NULL;
+ log->Names[count] = nullptr;
count = 0;
p = (char*)names;
log->Names[count++] = p;
- while ((p = strchr(p, '.')) != NULL)
+ while ((p = strchr(p, '.')) != nullptr)
{
if (count < log->NameCount)
log->Names[count++] = p + 1;
@@ -850,14 +850,14 @@ static BOOL WLog_ParseName(wLog* log, LPCSTR name)
wLog* WLog_New(LPCSTR name, wLog* rootLogger)
{
- wLog* log = NULL;
- char* env = NULL;
+ wLog* log = nullptr;
+ char* env = nullptr;
DWORD nSize = 0;
int iLevel = 0;
log = (wLog*)calloc(1, sizeof(wLog));
if (!log)
- return NULL;
+ return nullptr;
log->Name = _strdup(name);
@@ -875,7 +875,7 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
if (!(log->Children = (wLog**)calloc(log->ChildrenSize, sizeof(wLog*))))
goto out_fail;
- log->Appender = NULL;
+ log->Appender = nullptr;
if (rootLogger)
{
@@ -886,7 +886,7 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
{
LPCSTR level = "WLOG_LEVEL";
log->Level = WLOG_INFO;
- nSize = GetEnvironmentVariableA(level, NULL, 0);
+ nSize = GetEnvironmentVariableA(level, nullptr, 0);
if (nSize)
{
@@ -926,7 +926,7 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger)
return log;
out_fail:
WLog_Free(log);
- return NULL;
+ return nullptr;
}
void WLog_Free(wLog* log)
@@ -936,7 +936,7 @@ void WLog_Free(wLog* log)
if (log->Appender)
{
WLog_Appender_Free(log, log->Appender);
- log->Appender = NULL;
+ log->Appender = nullptr;
}
free(log->Name);
@@ -953,8 +953,8 @@ void WLog_Free(wLog* log)
wLog* WLog_GetRoot(void)
{
- if (!InitOnceExecuteOnce(&g_WLogInitialized, WLog_InitializeRoot, NULL, NULL))
- return NULL;
+ if (!InitOnceExecuteOnce(&g_WLogInitialized, WLog_InitializeRoot, nullptr, nullptr))
+ return nullptr;
return g_RootLog;
}
@@ -967,13 +967,13 @@ static BOOL WLog_AddChild(wLog* parent, wLog* child)
if (parent->ChildrenCount >= parent->ChildrenSize)
{
- wLog** tmp = NULL;
+ wLog** tmp = nullptr;
parent->ChildrenSize *= 2;
if (!parent->ChildrenSize)
{
free((void*)parent->Children);
- parent->Children = NULL;
+ parent->Children = nullptr;
}
else
{
@@ -982,7 +982,7 @@ static BOOL WLog_AddChild(wLog* parent, wLog* child)
if (!tmp)
{
free((void*)parent->Children);
- parent->Children = NULL;
+ parent->Children = nullptr;
goto exit;
}
@@ -1005,11 +1005,11 @@ exit:
static wLog* WLog_FindChild(wLog* root, LPCSTR name)
{
- wLog* child = NULL;
+ wLog* child = nullptr;
BOOL found = FALSE;
if (!root)
- return NULL;
+ return nullptr;
WLog_Lock(root);
@@ -1026,25 +1026,25 @@ static wLog* WLog_FindChild(wLog* root, LPCSTR name)
WLog_Unlock(root);
- return (found) ? child : NULL;
+ return (found) ? child : nullptr;
}
static wLog* WLog_Get_int(wLog* root, LPCSTR name)
{
- wLog* log = NULL;
+ wLog* log = nullptr;
if (!(log = WLog_FindChild(root, name)))
{
if (!root)
- return NULL;
+ return nullptr;
if (!(log = WLog_New(name, root)))
- return NULL;
+ return nullptr;
if (!WLog_AddChild(root, log))
{
WLog_Free(log);
- return NULL;
+ return nullptr;
}
}
@@ -1060,7 +1060,7 @@ wLog* WLog_Get(LPCSTR name)
#if defined(WITH_WINPR_DEPRECATED)
BOOL WLog_Init(void)
{
- return WLog_GetRoot() != NULL;
+ return WLog_GetRoot() != nullptr;
}
BOOL WLog_Uninit(void)
@@ -1081,7 +1081,7 @@ BOOL WLog_Uninit(void)
WLog_Unlock(root);
WLog_Free(root);
- g_RootLog = NULL;
+ g_RootLog = nullptr;
return TRUE;
}
diff --git a/winpr/libwinpr/winsock/winsock.c b/winpr/libwinpr/winsock/winsock.c
index 23c692bbd..f05c07949 100644
--- a/winpr/libwinpr/winsock/winsock.c
+++ b/winpr/libwinpr/winsock/winsock.c
@@ -242,7 +242,7 @@ PCSTR winpr_inet_ntop(INT Family, PVOID pAddr, PSTR pStringBuf, size_t StringBuf
in.sin_family = AF_INET;
memcpy(&in.sin_addr, pAddr, sizeof(struct in_addr));
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in), pStringBuf, StringBufSize,
- NULL, 0, NI_NUMERICHOST);
+ nullptr, 0, NI_NUMERICHOST);
return pStringBuf;
}
else if (Family == AF_INET6)
@@ -252,11 +252,11 @@ PCSTR winpr_inet_ntop(INT Family, PVOID pAddr, PSTR pStringBuf, size_t StringBuf
in.sin6_family = AF_INET6;
memcpy(&in.sin6_addr, pAddr, sizeof(struct in_addr6));
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in6), pStringBuf, StringBufSize,
- NULL, 0, NI_NUMERICHOST);
+ nullptr, 0, NI_NUMERICHOST);
return pStringBuf;
}
- return NULL;
+ return nullptr;
}
INT winpr_inet_pton(INT Family, PCSTR pszAddrString, PVOID pAddrBuf)
@@ -267,7 +267,7 @@ INT winpr_inet_pton(INT Family, PCSTR pszAddrString, PVOID pAddrBuf)
if ((Family != AF_INET) && (Family != AF_INET6))
return -1;
- if (WSAStringToAddressA((char*)pszAddrString, Family, NULL, (struct sockaddr*)&addr,
+ if (WSAStringToAddressA((char*)pszAddrString, Family, nullptr, (struct sockaddr*)&addr,
&addr_len) != 0)
return 0;
@@ -722,7 +722,7 @@ int WSAGetLastError(void)
HANDLE WSACreateEvent(void)
{
- return CreateEvent(NULL, TRUE, FALSE, NULL);
+ return CreateEvent(nullptr, TRUE, FALSE, nullptr);
}
BOOL WSASetEvent(HANDLE hEvent)
@@ -801,7 +801,7 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, WINPR_ATTR_UNUSED LPVOID lpvInBuff
ULONG nFlags = 0;
size_t offset = 0;
size_t ifreq_len = 0;
- struct ifreq* ifreq = NULL;
+ struct ifreq* ifreq = nullptr;
struct ifconf ifconf = WINPR_C_ARRAY_INIT;
char address[128] = WINPR_C_ARRAY_INIT;
char broadcast[128] = WINPR_C_ARRAY_INIT;
@@ -809,11 +809,11 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, WINPR_ATTR_UNUSED LPVOID lpvInBuff
char buffer[4096] = WINPR_C_ARRAY_INIT;
size_t numInterfaces = 0;
size_t maxNumInterfaces = 0;
- INTERFACE_INFO* pInterface = NULL;
- INTERFACE_INFO* pInterfaces = NULL;
- struct sockaddr_in* pAddress = NULL;
- struct sockaddr_in* pBroadcast = NULL;
- struct sockaddr_in* pNetmask = NULL;
+ INTERFACE_INFO* pInterface = nullptr;
+ INTERFACE_INFO* pInterfaces = nullptr;
+ struct sockaddr_in* pAddress = nullptr;
+ struct sockaddr_in* pBroadcast = nullptr;
+ struct sockaddr_in* pNetmask = nullptr;
if ((dwIoControlCode != SIO_GET_INTERFACE_LIST) ||
(!lpvOutBuffer || !cbOutBuffer || !lpcbBytesReturned))
@@ -827,7 +827,7 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, WINPR_ATTR_UNUSED LPVOID lpvInBuff
maxNumInterfaces = cbOutBuffer / sizeof(INTERFACE_INFO);
#ifdef WSAIOCTL_IFADDRS
{
- struct ifaddrs* ifap = NULL;
+ struct ifaddrs* ifap = nullptr;
if (getifaddrs(&ifap) != 0)
{
@@ -966,7 +966,7 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, WINPR_ATTR_UNUSED LPVOID lpvInBuff
if ((ifreq->ifr_addr.sa_family != AF_INET) && (ifreq->ifr_addr.sa_family != AF_INET6))
goto next_ifreq;
- getnameinfo(&ifreq->ifr_addr, sizeof(ifreq->ifr_addr), address, sizeof(address), 0, 0,
+ getnameinfo(&ifreq->ifr_addr, sizeof(ifreq->ifr_addr), address, sizeof(address), nullptr, 0,
NI_NUMERICHOST);
inet_pton(ifreq->ifr_addr.sa_family, address, (void*)&pAddress->sin_addr);
@@ -976,8 +976,8 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, WINPR_ATTR_UNUSED LPVOID lpvInBuff
if ((ifreq->ifr_addr.sa_family != AF_INET) && (ifreq->ifr_addr.sa_family != AF_INET6))
goto next_ifreq;
- getnameinfo(&ifreq->ifr_addr, sizeof(ifreq->ifr_addr), broadcast, sizeof(broadcast), 0, 0,
- NI_NUMERICHOST);
+ getnameinfo(&ifreq->ifr_addr, sizeof(ifreq->ifr_addr), broadcast, sizeof(broadcast),
+ nullptr, 0, NI_NUMERICHOST);
inet_pton(ifreq->ifr_addr.sa_family, broadcast, (void*)&pBroadcast->sin_addr);
if (ioctl(fd, SIOCGIFNETMASK, ifreq) != 0)
@@ -986,7 +986,7 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, WINPR_ATTR_UNUSED LPVOID lpvInBuff
if ((ifreq->ifr_addr.sa_family != AF_INET) && (ifreq->ifr_addr.sa_family != AF_INET6))
goto next_ifreq;
- getnameinfo(&ifreq->ifr_addr, sizeof(ifreq->ifr_addr), netmask, sizeof(netmask), 0, 0,
+ getnameinfo(&ifreq->ifr_addr, sizeof(ifreq->ifr_addr), netmask, sizeof(netmask), nullptr, 0,
NI_NUMERICHOST);
inet_pton(ifreq->ifr_addr.sa_family, netmask, (void*)&pNetmask->sin_addr);
numInterfaces++;
@@ -1249,7 +1249,7 @@ SOCKET _socket(int af, int type, int protocol)
struct hostent* _gethostbyaddr(const char* addr, int len, int type)
{
- struct hostent* host = NULL;
+ struct hostent* host = nullptr;
// NOLINTNEXTLINE(concurrency-mt-unsafe)
host = gethostbyaddr((const void*)addr, (socklen_t)len, type);
return host;
diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c
index e48c0a394..e6dcd7328 100644
--- a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c
+++ b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c
@@ -8,14 +8,14 @@ int TestWtsApiEnumerateProcesses(int argc, char* argv[])
{
DWORD count = 0;
BOOL bSuccess = 0;
- HANDLE hServer = NULL;
- PWTS_PROCESS_INFOA pProcessInfo = NULL;
+ HANDLE hServer = nullptr;
+ PWTS_PROCESS_INFOA pProcessInfo = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
#ifndef _WIN32
- if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", NULL, 0))
+ if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", nullptr, 0))
{
printf("%s: No RDS environment detected, skipping test\n", __func__);
return 0;
@@ -25,7 +25,7 @@ int TestWtsApiEnumerateProcesses(int argc, char* argv[])
hServer = WTS_CURRENT_SERVER_HANDLE;
count = 0;
- pProcessInfo = NULL;
+ pProcessInfo = nullptr;
bSuccess = WTSEnumerateProcessesA(hServer, 0, 1, &pProcessInfo, &count);
diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateSessions.c b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateSessions.c
index afe48a9df..d10b965c4 100644
--- a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateSessions.c
+++ b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateSessions.c
@@ -8,14 +8,14 @@ int TestWtsApiEnumerateSessions(int argc, char* argv[])
{
DWORD count = 0;
BOOL bSuccess = 0;
- HANDLE hServer = NULL;
- PWTS_SESSION_INFOA pSessionInfo = NULL;
+ HANDLE hServer = nullptr;
+ PWTS_SESSION_INFOA pSessionInfo = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
#ifndef _WIN32
- if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", NULL, 0))
+ if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", nullptr, 0))
{
printf("%s: No RDS environment detected, skipping test\n", __func__);
return 0;
@@ -25,7 +25,7 @@ int TestWtsApiEnumerateSessions(int argc, char* argv[])
hServer = WTS_CURRENT_SERVER_HANDLE;
count = 0;
- pSessionInfo = NULL;
+ pSessionInfo = nullptr;
bSuccess = WTSEnumerateSessionsA(hServer, 0, 1, &pSessionInfo, &count);
diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiExtraStartRemoteSessionEx.c b/winpr/libwinpr/wtsapi/test/TestWtsApiExtraStartRemoteSessionEx.c
index a81db9439..b6fc75dff 100644
--- a/winpr/libwinpr/wtsapi/test/TestWtsApiExtraStartRemoteSessionEx.c
+++ b/winpr/libwinpr/wtsapi/test/TestWtsApiExtraStartRemoteSessionEx.c
@@ -17,13 +17,13 @@ int TestWtsApiExtraStartRemoteSessionEx(int argc, char* argv[])
if (bSuccess > 0)
{
errno = 0;
- logonId = strtoul(logonIdStr, NULL, 0);
+ logonId = strtoul(logonIdStr, nullptr, 0);
if (errno != 0)
return -1;
}
bSuccess = WTSStartRemoteControlSessionEx(
- NULL, logonId, VK_F10, REMOTECONTROL_KBDSHIFT_HOTKEY | REMOTECONTROL_KBDCTRL_HOTKEY,
+ nullptr, logonId, VK_F10, REMOTECONTROL_KBDSHIFT_HOTKEY | REMOTECONTROL_KBDCTRL_HOTKEY,
REMOTECONTROL_FLAG_DISABLE_INPUT);
if (!bSuccess)
diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiQuerySessionInformation.c b/winpr/libwinpr/wtsapi/test/TestWtsApiQuerySessionInformation.c
index bc232f0e8..43be80164 100644
--- a/winpr/libwinpr/wtsapi/test/TestWtsApiQuerySessionInformation.c
+++ b/winpr/libwinpr/wtsapi/test/TestWtsApiQuerySessionInformation.c
@@ -8,17 +8,17 @@ int TestWtsApiQuerySessionInformation(int argc, char* argv[])
{
DWORD count = 0;
BOOL bSuccess = 0;
- HANDLE hServer = NULL;
- LPSTR pBuffer = NULL;
+ HANDLE hServer = nullptr;
+ LPSTR pBuffer = nullptr;
DWORD sessionId = 0;
DWORD bytesReturned = 0;
- PWTS_SESSION_INFOA pSessionInfo = NULL;
+ PWTS_SESSION_INFOA pSessionInfo = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
#ifndef _WIN32
- if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", NULL, 0))
+ if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", nullptr, 0))
{
printf("%s: No RDS environment detected, skipping test\n", __func__);
return 0;
@@ -28,7 +28,7 @@ int TestWtsApiQuerySessionInformation(int argc, char* argv[])
hServer = WTS_CURRENT_SERVER_HANDLE;
count = 0;
- pSessionInfo = NULL;
+ pSessionInfo = nullptr;
bSuccess = WTSEnumerateSessionsA(hServer, 0, 1, &pSessionInfo, &count);
@@ -42,18 +42,18 @@ int TestWtsApiQuerySessionInformation(int argc, char* argv[])
for (DWORD index = 0; index < count; index++)
{
- char* Username = NULL;
- char* Domain = NULL;
- char* ClientName = NULL;
+ char* Username = nullptr;
+ char* Domain = nullptr;
+ char* ClientName = nullptr;
ULONG ClientBuildNumber = 0;
USHORT ClientProductId = 0;
ULONG ClientHardwareId = 0;
USHORT ClientProtocolType = 0;
- PWTS_CLIENT_DISPLAY ClientDisplay = NULL;
- PWTS_CLIENT_ADDRESS ClientAddress = NULL;
+ PWTS_CLIENT_DISPLAY ClientDisplay = nullptr;
+ PWTS_CLIENT_ADDRESS ClientAddress = nullptr;
WTS_CONNECTSTATE_CLASS ConnectState = WTSInit;
- pBuffer = NULL;
+ pBuffer = nullptr;
bytesReturned = 0;
sessionId = pSessionInfo[index].SessionId;
diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiSessionNotification.c b/winpr/libwinpr/wtsapi/test/TestWtsApiSessionNotification.c
index e83c27be3..6403af3ef 100644
--- a/winpr/libwinpr/wtsapi/test/TestWtsApiSessionNotification.c
+++ b/winpr/libwinpr/wtsapi/test/TestWtsApiSessionNotification.c
@@ -6,7 +6,7 @@
int TestWtsApiSessionNotification(int argc, char* argv[])
{
- HWND hWnd = NULL;
+ HWND hWnd = nullptr;
BOOL bSuccess = 0;
DWORD dwFlags = 0;
@@ -14,7 +14,7 @@ int TestWtsApiSessionNotification(int argc, char* argv[])
WINPR_UNUSED(argv);
#ifndef _WIN32
- if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", NULL, 0))
+ if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", nullptr, 0))
{
printf("%s: No RDS environment detected, skipping test\n", __func__);
return 0;
@@ -22,7 +22,7 @@ int TestWtsApiSessionNotification(int argc, char* argv[])
#else
/* We create a message-only window and use the predefined class name "STATIC" for simplicity */
hWnd = CreateWindowA("STATIC", "TestWtsApiSessionNotification", 0, 0, 0, 0, 0, HWND_MESSAGE,
- NULL, NULL, NULL);
+ nullptr, nullptr, nullptr);
if (!hWnd)
{
printf("%s: error creating message-only window: %" PRIu32 "\n", __func__, GetLastError());
@@ -47,7 +47,7 @@ int TestWtsApiSessionNotification(int argc, char* argv[])
if (hWnd)
{
DestroyWindow(hWnd);
- hWnd = NULL;
+ hWnd = nullptr;
}
#endif
diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiShutdownSystem.c b/winpr/libwinpr/wtsapi/test/TestWtsApiShutdownSystem.c
index 431424b71..24158be9b 100644
--- a/winpr/libwinpr/wtsapi/test/TestWtsApiShutdownSystem.c
+++ b/winpr/libwinpr/wtsapi/test/TestWtsApiShutdownSystem.c
@@ -6,14 +6,14 @@
int TestWtsApiShutdownSystem(int argc, char* argv[])
{
BOOL bSuccess = 0;
- HANDLE hServer = NULL;
+ HANDLE hServer = nullptr;
DWORD ShutdownFlag = 0;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
#ifndef _WIN32
- if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", NULL, 0))
+ if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", nullptr, 0))
{
printf("%s: No RDS environment detected, skipping test\n", __func__);
return 0;
diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiWaitSystemEvent.c b/winpr/libwinpr/wtsapi/test/TestWtsApiWaitSystemEvent.c
index 389c0beb5..0296ea425 100644
--- a/winpr/libwinpr/wtsapi/test/TestWtsApiWaitSystemEvent.c
+++ b/winpr/libwinpr/wtsapi/test/TestWtsApiWaitSystemEvent.c
@@ -7,7 +7,7 @@
int TestWtsApiWaitSystemEvent(int argc, char* argv[])
{
BOOL bSuccess = 0;
- HANDLE hServer = NULL;
+ HANDLE hServer = nullptr;
DWORD eventMask = 0;
DWORD eventFlags = 0;
@@ -15,7 +15,7 @@ int TestWtsApiWaitSystemEvent(int argc, char* argv[])
WINPR_UNUSED(argv);
#ifndef _WIN32
- if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", NULL, 0))
+ if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", nullptr, 0))
{
printf("%s: No RDS environment detected, skipping test\n", __func__);
return 0;
diff --git a/winpr/libwinpr/wtsapi/wtsapi.c b/winpr/libwinpr/wtsapi/wtsapi.c
index c2683f092..864cb334a 100644
--- a/winpr/libwinpr/wtsapi/wtsapi.c
+++ b/winpr/libwinpr/wtsapi/wtsapi.c
@@ -42,12 +42,12 @@
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa383464/
*/
-static HMODULE g_WtsApiModule = NULL;
+static HMODULE g_WtsApiModule = nullptr;
-static const WtsApiFunctionTable* g_WtsApi = NULL;
+static const WtsApiFunctionTable* g_WtsApi = nullptr;
#if defined(_WIN32)
-static HMODULE g_WtsApi32Module = NULL;
+static HMODULE g_WtsApi32Module = nullptr;
static WtsApiFunctionTable WtsApi32_WtsApiFunctionTable = WINPR_C_ARRAY_INIT;
#ifdef __MINGW32__
@@ -142,22 +142,22 @@ static BOOL WtsApi32_InitializeWtsApi(void)
static BOOL CALLBACK InitializeWtsApiStubs(PINIT_ONCE once, PVOID param, PVOID* context);
static INIT_ONCE wtsapiInitOnce = INIT_ONCE_STATIC_INIT;
-#define WTSAPI_STUB_CALL_VOID(_name, ...) \
- InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, NULL, NULL); \
- if (!g_WtsApi || !g_WtsApi->p##_name) \
- return; \
+#define WTSAPI_STUB_CALL_VOID(_name, ...) \
+ InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, nullptr, nullptr); \
+ if (!g_WtsApi || !g_WtsApi->p##_name) \
+ return; \
g_WtsApi->p##_name(__VA_ARGS__)
-#define WTSAPI_STUB_CALL_BOOL(_name, ...) \
- InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, NULL, NULL); \
- if (!g_WtsApi || !g_WtsApi->p##_name) \
- return FALSE; \
+#define WTSAPI_STUB_CALL_BOOL(_name, ...) \
+ InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, nullptr, nullptr); \
+ if (!g_WtsApi || !g_WtsApi->p##_name) \
+ return FALSE; \
return g_WtsApi->p##_name(__VA_ARGS__)
-#define WTSAPI_STUB_CALL_HANDLE(_name, ...) \
- InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, NULL, NULL); \
- if (!g_WtsApi || !g_WtsApi->p##_name) \
- return NULL; \
+#define WTSAPI_STUB_CALL_HANDLE(_name, ...) \
+ InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, nullptr, nullptr); \
+ if (!g_WtsApi || !g_WtsApi->p##_name) \
+ return nullptr; \
return g_WtsApi->p##_name(__VA_ARGS__)
BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, ULONG TargetLogonId,
@@ -566,7 +566,7 @@ BOOL CDECL WTSLogoffUser(HANDLE hServer)
DWORD WINAPI WTSGetActiveConsoleSessionId(void)
{
- InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, NULL, NULL);
+ InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, nullptr, nullptr);
if (!g_WtsApi || !g_WtsApi->pGetActiveConsoleSessionId)
return 0xFFFFFFFF;
@@ -689,8 +689,8 @@ BOOL WTSRegisterWtsApiFunctionTable(const WtsApiFunctionTable* table)
void* pv;
} cnv;
cnv.cpv = table;
- InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, cnv.pv, NULL);
- return g_WtsApi != NULL;
+ InitOnceExecuteOnce(&wtsapiInitOnce, InitializeWtsApiStubs, cnv.pv, nullptr);
+ return g_WtsApi != nullptr;
}
static BOOL LoadAndInitialize(char* library)
@@ -712,13 +712,13 @@ static BOOL LoadAndInitialize(char* library)
static void InitializeWtsApiStubs_Env(void)
{
DWORD nSize = 0;
- char* env = NULL;
+ char* env = nullptr;
LPCSTR wts = "WTSAPI_LIBRARY";
if (g_WtsApi)
return;
- nSize = GetEnvironmentVariableA(wts, NULL, 0);
+ nSize = GetEnvironmentVariableA(wts, nullptr, 0);
if (!nSize)
return;
@@ -736,9 +736,9 @@ static void InitializeWtsApiStubs_Env(void)
static void InitializeWtsApiStubs_FreeRDS(void)
{
- wIniFile* ini = NULL;
- const char* prefix = NULL;
- const char* libdir = NULL;
+ wIniFile* ini = nullptr;
+ const char* prefix = nullptr;
+ const char* libdir = nullptr;
if (g_WtsApi)
return;
@@ -759,8 +759,8 @@ static void InitializeWtsApiStubs_FreeRDS(void)
if (prefix && libdir)
{
- char* prefix_libdir = NULL;
- char* wtsapi_library = NULL;
+ char* prefix_libdir = nullptr;
+ char* wtsapi_library = nullptr;
prefix_libdir = GetCombinedPath(prefix, libdir);
wtsapi_library = GetCombinedPath(prefix_libdir, FREERDS_LIBRARY_NAME);
diff --git a/winpr/libwinpr/wtsapi/wtsapi_win32.c b/winpr/libwinpr/wtsapi/wtsapi_win32.c
index 127bcefc8..8f248b25a 100644
--- a/winpr/libwinpr/wtsapi/wtsapi_win32.c
+++ b/winpr/libwinpr/wtsapi/wtsapi_win32.c
@@ -62,15 +62,15 @@ typedef struct
} WTSAPI_CHANNEL;
static BOOL g_Initialized = FALSE;
-static HMODULE g_WinStaModule = NULL;
+static HMODULE g_WinStaModule = nullptr;
typedef HANDLE(WINAPI* fnWinStationVirtualOpen)(HANDLE hServer, DWORD SessionId,
LPSTR pVirtualName);
typedef HANDLE(WINAPI* fnWinStationVirtualOpenEx)(HANDLE hServer, DWORD SessionId,
LPSTR pVirtualName, DWORD flags);
-static fnWinStationVirtualOpen pfnWinStationVirtualOpen = NULL;
-static fnWinStationVirtualOpenEx pfnWinStationVirtualOpenEx = NULL;
+static fnWinStationVirtualOpen pfnWinStationVirtualOpen = nullptr;
+static fnWinStationVirtualOpenEx pfnWinStationVirtualOpenEx = nullptr;
static BOOL WINAPI Win32_WTSVirtualChannelClose(HANDLE hChannel);
@@ -183,19 +183,19 @@ static HANDLE WINAPI Win32_WTSVirtualChannelOpen_Internal(HANDLE hServer, DWORD
if (!virtualNameLen)
{
SetLastError(ERROR_INVALID_PARAMETER);
- return NULL;
+ return nullptr;
}
if (!pfnWinStationVirtualOpenEx)
{
SetLastError(ERROR_INVALID_FUNCTION);
- return NULL;
+ return nullptr;
}
hFile = pfnWinStationVirtualOpenEx(hServer, SessionId, pVirtualName, flags);
if (!hFile)
- return NULL;
+ return nullptr;
pChannel = (WTSAPI_CHANNEL*)_wts_calloc(1, sizeof(WTSAPI_CHANNEL));
@@ -203,7 +203,7 @@ static HANDLE WINAPI Win32_WTSVirtualChannelOpen_Internal(HANDLE hServer, DWORD
{
(void)CloseHandle(hFile);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
+ return nullptr;
}
hChannel = (HANDLE)pChannel;
@@ -217,7 +217,7 @@ static HANDLE WINAPI Win32_WTSVirtualChannelOpen_Internal(HANDLE hServer, DWORD
(void)CloseHandle(hFile);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
_wts_free(pChannel);
- return NULL;
+ return nullptr;
}
memcpy(pChannel->VirtualName, pVirtualName, virtualNameLen);
@@ -232,14 +232,14 @@ static HANDLE WINAPI Win32_WTSVirtualChannelOpen_Internal(HANDLE hServer, DWORD
pChannel->header = (CHANNEL_PDU_HEADER*)pChannel->readBuffer;
pChannel->chunk = &(pChannel->readBuffer[sizeof(CHANNEL_PDU_HEADER)]);
- pChannel->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ pChannel->hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
pChannel->overlapped.hEvent = pChannel->hEvent;
if (!pChannel->hEvent || !pChannel->VirtualName || !pChannel->readBuffer)
{
Win32_WTSVirtualChannelClose(hChannel);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
+ return nullptr;
}
return hChannel;
@@ -276,25 +276,25 @@ static BOOL WINAPI Win32_WTSVirtualChannelClose(HANDLE hChannel)
}
status = CloseHandle(pChannel->hFile);
- pChannel->hFile = NULL;
+ pChannel->hFile = nullptr;
}
if (pChannel->hEvent)
{
(void)CloseHandle(pChannel->hEvent);
- pChannel->hEvent = NULL;
+ pChannel->hEvent = nullptr;
}
if (pChannel->VirtualName)
{
_wts_free(pChannel->VirtualName);
- pChannel->VirtualName = NULL;
+ pChannel->VirtualName = nullptr;
}
if (pChannel->readBuffer)
{
_wts_free(pChannel->readBuffer);
- pChannel->readBuffer = NULL;
+ pChannel->readBuffer = nullptr;
}
pChannel->magic = 0;
@@ -735,7 +735,7 @@ static BOOL WINAPI Win32_WTSVirtualChannelQuery(HANDLE hChannelHandle,
*pBytesReturned = sizeof(HANDLE);
*ppBuffer = _wts_calloc(1, *pBytesReturned);
- if (*ppBuffer == NULL)
+ if (*ppBuffer == nullptr)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
@@ -748,7 +748,7 @@ static BOOL WINAPI Win32_WTSVirtualChannelQuery(HANDLE hChannelHandle,
*pBytesReturned = sizeof(HANDLE);
*ppBuffer = _wts_calloc(1, *pBytesReturned);
- if (*ppBuffer == NULL)
+ if (*ppBuffer == nullptr)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
diff --git a/winpr/tools/hash-cli/hash.c b/winpr/tools/hash-cli/hash.c
index 610a12aae..c6223726b 100644
--- a/winpr/tools/hash-cli/hash.c
+++ b/winpr/tools/hash-cli/hash.c
@@ -61,11 +61,11 @@ int main(int argc, char* argv[])
int format = 0;
unsigned long version = 1;
BYTE NtHash[16];
- char* User = NULL;
+ char* User = nullptr;
size_t UserLength = 0;
- char* Domain = NULL;
+ char* Domain = nullptr;
size_t DomainLength = 0;
- char* Password = NULL;
+ char* Password = nullptr;
size_t PasswordLength = 0;
errno = 0;
@@ -117,7 +117,7 @@ int main(int argc, char* argv[])
return usage_and_exit();
}
- version = strtoul(argv[index], NULL, 0);
+ version = strtoul(argv[index], nullptr, 0);
if (((version != 1) && (version != 2)) || (errno != 0))
{
diff --git a/winpr/tools/makecert-cli/main.c b/winpr/tools/makecert-cli/main.c
index fa01f7efd..65932ebf3 100644
--- a/winpr/tools/makecert-cli/main.c
+++ b/winpr/tools/makecert-cli/main.c
@@ -29,7 +29,7 @@
int main(int argc, char* argv[])
{
- MAKECERT_CONTEXT* context = NULL;
+ MAKECERT_CONTEXT* context = nullptr;
int ret = 0;
context = makecert_context_new();
diff --git a/winpr/tools/makecert/makecert.c b/winpr/tools/makecert/makecert.c
index f9e357511..6565fba4f 100644
--- a/winpr/tools/makecert/makecert.c
+++ b/winpr/tools/makecert/makecert.c
@@ -74,12 +74,12 @@ static char* makecert_read_str(BIO* bio, size_t* pOffset)
int status = -1;
size_t offset = 0;
size_t length = 0;
- char* x509_str = NULL;
+ char* x509_str = nullptr;
while (offset >= length)
{
size_t readBytes = 0;
- char* new_str = NULL;
+ char* new_str = nullptr;
size_t new_len = length + 2048ull;
if (new_len > INT_MAX)
@@ -116,7 +116,7 @@ static char* makecert_read_str(BIO* bio, size_t* pOffset)
free(x509_str);
if (pOffset)
*pOffset = 0;
- return NULL;
+ return nullptr;
}
x509_str[offset] = '\0';
@@ -127,8 +127,8 @@ static char* makecert_read_str(BIO* bio, size_t* pOffset)
static int makecert_print_command_line_help(COMMAND_LINE_ARGUMENT_A* args, int argc, char** argv)
{
- char* str = NULL;
- const COMMAND_LINE_ARGUMENT_A* arg = NULL;
+ char* str = nullptr;
+ const COMMAND_LINE_ARGUMENT_A* arg = nullptr;
if (!argv || (argc < 1))
return -1;
@@ -169,7 +169,7 @@ static int makecert_print_command_line_help(COMMAND_LINE_ARGUMENT_A* args, int a
printf("\t%s\n", arg->Text);
}
- } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != nullptr);
return 1;
}
@@ -178,13 +178,13 @@ static int makecert_print_command_line_help(COMMAND_LINE_ARGUMENT_A* args, int a
static int x509_add_ext(X509* cert, int nid, char* value)
{
X509V3_CTX ctx;
- X509_EXTENSION* ext = NULL;
+ X509_EXTENSION* ext = nullptr;
if (!cert || !value)
return 0;
- X509V3_set_ctx_nodb(&ctx) X509V3_set_ctx(&ctx, cert, cert, NULL, NULL, 0);
- ext = X509V3_EXT_conf_nid(NULL, &ctx, nid, value);
+ X509V3_set_ctx_nodb(&ctx) X509V3_set_ctx(&ctx, cert, cert, nullptr, nullptr, 0);
+ ext = X509V3_EXT_conf_nid(nullptr, &ctx, nid, value);
if (!ext)
return 0;
@@ -197,16 +197,16 @@ static int x509_add_ext(X509* cert, int nid, char* value)
static char* x509_name_parse(char* name, char* txt, size_t* length)
{
- char* p = NULL;
- char* entry = NULL;
+ char* p = nullptr;
+ char* entry = nullptr;
if (!name || !txt || !length)
- return NULL;
+ return nullptr;
p = strstr(name, txt);
if (!p)
- return NULL;
+ return nullptr;
entry = p + strlen(txt) + 1;
p = strchr(entry, '=');
@@ -223,21 +223,21 @@ static char* get_name(COMPUTER_NAME_FORMAT type)
{
DWORD nSize = 0;
- if (GetComputerNameExA(type, NULL, &nSize))
- return NULL;
+ if (GetComputerNameExA(type, nullptr, &nSize))
+ return nullptr;
if (GetLastError() != ERROR_MORE_DATA)
- return NULL;
+ return nullptr;
char* computerName = calloc(1, nSize);
if (!computerName)
- return NULL;
+ return nullptr;
if (!GetComputerNameExA(type, computerName, &nSize))
{
free(computerName);
- return NULL;
+ return nullptr;
}
return computerName;
@@ -278,7 +278,7 @@ static int makecert_context_parse_arguments(MAKECERT_CONTEXT* context,
{
int status = 0;
DWORD flags = 0;
- const COMMAND_LINE_ARGUMENT_A* arg = NULL;
+ const COMMAND_LINE_ARGUMENT_A* arg = nullptr;
if (!context || !argv || (argc < 0))
return -1;
@@ -289,8 +289,8 @@ static int makecert_context_parse_arguments(MAKECERT_CONTEXT* context,
*/
CommandLineClearArgumentsA(args);
flags = COMMAND_LINE_SEPARATOR_SPACE | COMMAND_LINE_SIGIL_DASH;
- status =
- CommandLineParseArgumentsA(argc, argv, args, flags, context, command_line_pre_filter, NULL);
+ status = CommandLineParseArgumentsA(argc, argv, args, flags, context, command_line_pre_filter,
+ nullptr);
if (status & COMMAND_LINE_STATUS_PRINT_HELP)
{
@@ -379,7 +379,7 @@ static int makecert_context_parse_arguments(MAKECERT_CONTEXT* context,
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
continue;
- val = strtol(arg->Value, NULL, 0);
+ val = strtol(arg->Value, nullptr, 0);
if ((errno != 0) || (val < 0) || (val > INT32_MAX))
return -1;
@@ -393,7 +393,7 @@ static int makecert_context_parse_arguments(MAKECERT_CONTEXT* context,
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
continue;
- val = strtol(arg->Value, NULL, 0);
+ val = strtol(arg->Value, nullptr, 0);
if ((errno != 0) || (val < 0))
return -1;
@@ -404,7 +404,7 @@ static int makecert_context_parse_arguments(MAKECERT_CONTEXT* context,
{
}
CommandLineSwitchEnd(arg)
- } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
+ } while ((arg = CommandLineFindNextArgumentA(arg)) != nullptr);
return 1;
}
@@ -415,7 +415,7 @@ int makecert_context_set_output_file_name(MAKECERT_CONTEXT* context, const char*
return -1;
free(context->output_file);
- context->output_file = NULL;
+ context->output_file = nullptr;
if (name)
context->output_file = _strdup(name);
@@ -429,16 +429,16 @@ int makecert_context_set_output_file_name(MAKECERT_CONTEXT* context, const char*
int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, const char* path)
{
#ifdef WITH_OPENSSL
- FILE* fp = NULL;
+ FILE* fp = nullptr;
int status = 0;
size_t length = 0;
size_t offset = 0;
- char* filename = NULL;
- char* fullpath = NULL;
- char* ext = NULL;
+ char* filename = nullptr;
+ char* fullpath = nullptr;
+ char* ext = nullptr;
int ret = -1;
- BIO* bio = NULL;
- char* x509_str = NULL;
+ BIO* bio = nullptr;
+ char* x509_str = nullptr;
if (!context)
return -1;
@@ -502,10 +502,10 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, const ch
#else
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS |
OPENSSL_INIT_LOAD_CONFIG,
- NULL);
+ nullptr);
#endif
context->pkcs12 = PKCS12_create(context->password, context->default_name, context->pkey,
- context->x509, NULL, 0, 0, 0, 0, 0);
+ context->x509, nullptr, 0, 0, 0, 0, 0);
if (!context->pkcs12)
goto out_fail;
@@ -551,9 +551,9 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, const ch
goto out_fail;
free(x509_str);
- x509_str = NULL;
+ x509_str = nullptr;
BIO_free_all(bio);
- bio = NULL;
+ bio = nullptr;
if (context->pemFormat)
{
@@ -562,7 +562,8 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, const ch
if (!bio)
goto out_fail;
- status = PEM_write_bio_PrivateKey(bio, context->pkey, NULL, NULL, 0, NULL, NULL);
+ status = PEM_write_bio_PrivateKey(bio, context->pkey, nullptr, nullptr, 0, nullptr,
+ nullptr);
if (status < 0)
goto out_fail;
@@ -599,14 +600,14 @@ out_fail:
int makecert_context_output_private_key_file(MAKECERT_CONTEXT* context, const char* path)
{
#ifdef WITH_OPENSSL
- FILE* fp = NULL;
+ FILE* fp = nullptr;
size_t length = 0;
size_t offset = 0;
- char* filename = NULL;
- char* fullpath = NULL;
+ char* filename = nullptr;
+ char* fullpath = nullptr;
int ret = -1;
- BIO* bio = NULL;
- char* x509_str = NULL;
+ BIO* bio = nullptr;
+ char* x509_str = nullptr;
if (!context->crtFormat)
return 1;
@@ -648,7 +649,7 @@ int makecert_context_output_private_key_file(MAKECERT_CONTEXT* context, const ch
if (!bio)
goto out_fail;
- if (!PEM_write_bio_PrivateKey(bio, context->pkey, NULL, NULL, 0, NULL, NULL))
+ if (!PEM_write_bio_PrivateKey(bio, context->pkey, nullptr, nullptr, 0, nullptr, nullptr))
goto out_fail;
x509_str = makecert_read_str(bio, &offset);
@@ -686,9 +687,9 @@ static BOOL makecert_create_rsa(EVP_PKEY** ppkey, size_t key_length)
WINPR_ASSERT(ppkey);
#if !defined(OPENSSL_VERSION_MAJOR) || (OPENSSL_VERSION_MAJOR < 3)
- RSA* rsa = NULL;
+ RSA* rsa = nullptr;
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
- rsa = RSA_generate_key(key_length, RSA_F4, NULL, NULL);
+ rsa = RSA_generate_key(key_length, RSA_F4, nullptr, nullptr);
#else
{
BIGNUM* bn = BN_secure_new();
@@ -705,7 +706,7 @@ static BOOL makecert_create_rsa(EVP_PKEY** ppkey, size_t key_length)
}
BN_set_word(bn, RSA_F4);
- const int res = RSA_generate_key_ex(rsa, key_length, bn, NULL);
+ const int res = RSA_generate_key_ex(rsa, key_length, bn, nullptr);
BN_clear_free(bn);
if (res != 1)
@@ -720,7 +721,7 @@ static BOOL makecert_create_rsa(EVP_PKEY** ppkey, size_t key_length)
}
rc = TRUE;
#else
- EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL);
+ EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_from_name(nullptr, "RSA", nullptr);
if (!pctx)
return FALSE;
@@ -752,47 +753,47 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
COMMAND_LINE_ARGUMENT_A args[] = {
/* Custom Options */
- { "rdp", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ { "rdp", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
"Unsupported - Generate certificate with required options for RDP usage." },
- { "silent", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ { "silent", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
"Silently generate certificate without verbose output." },
- { "live", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ { "live", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
"Generate certificate live in memory when used as a library." },
- { "format", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "format", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Specify certificate file format" },
- { "path", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "path", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Specify certificate file output path" },
- { "p", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "p", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Specify certificate export password" },
/* Basic Options */
- { "n", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "n", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Specifies the subject's certificate name. This name must conform to the X.500 standard. "
"The simplest method is to specify the name in double quotes, preceded by CN=; for "
"example, "
"-n \"CN=myName\"." },
- { "pe", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ { "pe", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
"Unsupported - Marks the generated private key as exportable. This allows the private "
"key to "
"be included in the certificate." },
- { "sk", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "sk", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the subject's key container location, which contains the "
"private "
"key. "
"If a key container does not exist, it will be created." },
- { "sr", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "sr", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the subject's certificate store location. location can be "
"either "
"currentuser (the default) or localmachine." },
- { "ss", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "ss", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the subject's certificate store name that stores the output "
"certificate." },
- { "#", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "#", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Specifies a serial number from 1 to 2,147,483,647. The default is a unique value "
"generated "
"by Makecert.exe." },
- { "$", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "$", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the signing authority of the certificate, which must be set to "
"either commercial "
"(for certificates used by commercial software publishers) or individual (for "
@@ -801,71 +802,71 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
/* Extended Options */
- { "a", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "a", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Specifies the signature algorithm. algorithm must be md5, sha1, sha256 (the default), "
"sha384, or sha512." },
- { "b", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "b", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the start of the validity period. Defaults to the current "
"date." },
- { "crl", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ { "crl", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
"Unsupported - Generates a certificate relocation list (CRL) instead of a certificate." },
- { "cy", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "cy", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the certificate type. Valid values are end for end-entity and "
"authority for certification authority." },
- { "e", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "e", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the end of the validity period. Defaults to 12/31/2039 11:59:59 "
"GMT." },
- { "eku", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "eku", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Inserts a list of comma-separated, enhanced key usage object identifiers "
"(OIDs) into the certificate." },
- { "h", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "h", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the maximum height of the tree below this certificate." },
- { "ic", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "ic", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the issuer's certificate file." },
- { "ik", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "ik", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the issuer's key container name." },
- { "iky", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "iky", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the issuer's key type, which must be one of the following: "
"signature (which indicates that the key is used for a digital signature), "
"exchange (which indicates that the key is used for key encryption and key exchange), "
"or an integer that represents a provider type. "
"By default, you can pass 1 for an exchange key or 2 for a signature key." },
- { "in", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "in", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the issuer's certificate common name." },
- { "ip", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "ip", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the issuer's CryptoAPI provider name. For information about the "
"CryptoAPI provider name, see the –sp option." },
- { "ir", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "ir", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the location of the issuer's certificate store. location can be "
"either currentuser (the default) or localmachine." },
- { "is", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "is", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the issuer's certificate store name." },
- { "iv", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "iv", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the issuer's .pvk private key file." },
- { "iy", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "iy", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the issuer's CryptoAPI provider type. For information about the "
"CryptoAPI provider type, see the –sy option." },
- { "l", COMMAND_LINE_VALUE_REQUIRED, " ", NULL, NULL, -1, NULL,
+ { "l", COMMAND_LINE_VALUE_REQUIRED, " ", nullptr, nullptr, -1, nullptr,
"Unsupported - Links to policy information (for example, to a URL)." },
- { "len", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "len", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Specifies the generated key length, in bits." },
- { "m", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "m", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Specifies the duration, in months, of the certificate validity period." },
- { "y", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "y", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Specifies the duration, in years, of the certificate validity period." },
- { "nscp", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ { "nscp", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
"Unsupported - Includes the Netscape client-authorization extension." },
- { "r", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
+ { "r", COMMAND_LINE_VALUE_FLAG, nullptr, nullptr, nullptr, -1, nullptr,
"Unsupported - Creates a self-signed certificate." },
- { "sc", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "sc", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the subject's certificate file." },
- { "sky", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "sky", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the subject's key type, which must be one of the following: "
"signature (which indicates that the key is used for a digital signature), "
"exchange (which indicates that the key is used for key encryption and key exchange), "
"or an integer that represents a provider type. "
"By default, you can pass 1 for an exchange key or 2 for a signature key." },
- { "sp", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "sp", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the subject's CryptoAPI provider name, which must be defined in "
"the "
"registry subkeys of "
@@ -874,11 +875,11 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
"–sy are present, "
"the type of the CryptoAPI provider must correspond to the Type value of the provider's "
"subkey." },
- { "sv", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "sv", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the subject's .pvk private key file. The file is created if "
"none "
"exists." },
- { "sy", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "sy", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the subject's CryptoAPI provider type, which must be defined in "
"the "
"registry subkeys of "
@@ -888,25 +889,25 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
"the name of the CryptoAPI provider must correspond to the Name value of the provider "
"type "
"subkey." },
- { "tbs", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL,
+ { "tbs", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr,
"Unsupported - Specifies the certificate or CRL file to be signed." },
/* Help */
- { "?", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "help",
- "print help" },
- { "!", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "help-ext",
- "print extended help" },
- { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
+ { "?", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, nullptr, nullptr, nullptr, -1,
+ "help", "print help" },
+ { "!", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, nullptr, nullptr, nullptr, -1,
+ "help-ext", "print extended help" },
+ { nullptr, 0, nullptr, nullptr, nullptr, -1, nullptr, nullptr }
};
#ifdef WITH_OPENSSL
size_t length = 0;
- char* entry = NULL;
+ char* entry = nullptr;
int key_length = 0;
long serial = 0;
- X509_NAME* name = NULL;
- const EVP_MD* md = NULL;
- const COMMAND_LINE_ARGUMENT_A* arg = NULL;
+ X509_NAME* name = nullptr;
+ const EVP_MD* md = nullptr;
+ const COMMAND_LINE_ARGUMENT_A* arg = nullptr;
int ret = 0;
ret = makecert_context_parse_arguments(context, args, argc, argv);
@@ -955,7 +956,7 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
{
- unsigned long val = strtoul(arg->Value, NULL, 0);
+ unsigned long val = strtoul(arg->Value, nullptr, 0);
if ((errno != 0) || (val > INT_MAX))
return -1;
@@ -970,7 +971,7 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
{
- serial = strtol(arg->Value, NULL, 0);
+ serial = strtol(arg->Value, nullptr, 0);
if (errno != 0)
return -1;
@@ -980,8 +981,8 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
ASN1_INTEGER_set(X509_get_serialNumber(context->x509), serial);
{
- ASN1_TIME* before = NULL;
- ASN1_TIME* after = NULL;
+ ASN1_TIME* before = nullptr;
+ ASN1_TIME* after = nullptr;
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
before = X509_get_notBefore(context->x509);
after = X509_get_notAfter(context->x509);
@@ -1065,9 +1066,9 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
if (!context->silent)
{
- BIO* bio = NULL;
+ BIO* bio = nullptr;
int status = 0;
- char* x509_str = NULL;
+ char* x509_str = nullptr;
bio = BIO_new(BIO_s_mem());
if (!bio)
@@ -1081,7 +1082,7 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
return -1;
}
- x509_str = makecert_read_str(bio, NULL);
+ x509_str = makecert_read_str(bio, nullptr);
if (!x509_str)
{
BIO_free_all(bio);
@@ -1101,7 +1102,7 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv)
{
if (!winpr_PathFileExists(context->output_path))
{
- if (!winpr_PathMakePath(context->output_path, NULL))
+ if (!winpr_PathMakePath(context->output_path, nullptr))
return -1;
}