[c23,winpr] replace NULL with nullptr

This commit is contained in:
Armin Novak
2026-02-26 14:32:50 +01:00
parent f38e03d982
commit 822257bf7c
276 changed files with 4138 additions and 4149 deletions

View File

@@ -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
*/

View File

@@ -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;

View File

@@ -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)

View File

@@ -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
*/

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)

View File

@@ -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)

View File

@@ -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,

View File

@@ -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)

View File

@@ -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.

View File

@@ -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);

View File

@@ -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.

View File

@@ -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);

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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("<HTML><BODY>", pDstData, DstSize, NULL))
if (!winpr_str_append("<HTML><BODY>", pDstData, DstSize, nullptr))
goto fail;
}
if (!winpr_str_append("<!--StartFragment-->", pDstData, DstSize, NULL))
if (!winpr_str_append("<!--StartFragment-->", 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("<!--EndFragment-->", pDstData, DstSize, NULL))
if (!winpr_str_append("<!--EndFragment-->", pDstData, DstSize, nullptr))
goto fail;
if (!body)
{
if (!winpr_str_append("</BODY></HTML>", pDstData, DstSize, NULL))
if (!winpr_str_append("</BODY></HTML>", 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);

View File

@@ -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;

View File

@@ -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++)

View File

@@ -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",

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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?
*/

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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))
{

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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());

View File

@@ -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)
{

View File

@@ -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());

View File

@@ -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());

View File

@@ -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());

View File

@@ -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());

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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)

View File

@@ -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)

View File

@@ -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
{

View File

@@ -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,

View File

@@ -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);

View File

@@ -141,16 +141,16 @@
#include <winpr/crt.h>
#include <winpr/collections.h>
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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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++)
{

View File

@@ -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
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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)
{

View File

@@ -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)

View File

@@ -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;

View File

@@ -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));

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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))

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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");

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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))

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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),

View File

@@ -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)

View File

@@ -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)

View File

@@ -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);

View File

@@ -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__,

View File

@@ -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);

View File

@@ -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);

View File

@@ -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,

View File

@@ -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
}

View File

@@ -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,
&currentSession);
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)

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)

View File

@@ -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
}

Some files were not shown because too many files have changed in this diff Show More