]> git.ipfire.org Git - thirdparty/git.git/blobdiff - compat/mingw.c
Merge branch 'ep/maint-equals-null-cocci' for maint-2.35
[thirdparty/git.git] / compat / mingw.c
index 5e42191fa4acb4ec353df177488ec4d7d1555a05..3b8adf8ed5d449d7a5b709f601e47e35dbf4df51 100644 (file)
@@ -9,6 +9,8 @@
 #include "win32/lazyload.h"
 #include "../config.h"
 #include "dir.h"
+#define SECURITY_WIN32
+#include <sspi.h>
 
 #define HCAST(type, handle) ((type)(intptr_t)handle)
 
@@ -1009,7 +1011,7 @@ size_t mingw_strftime(char *s, size_t max,
        /* a pointer to the original strftime in case we can't find the UCRT version */
        static size_t (*fallback)(char *, size_t, const char *, const struct tm *) = strftime;
        size_t ret;
-       DECLARE_PROC_ADDR(ucrtbase.dll, size_t, strftime, char *, size_t,
+       DECLARE_PROC_ADDR(ucrtbase.dll, size_t, __cdecl, strftime, char *, size_t,
                const char *, const struct tm *);
 
        if (INIT_PROC_ADDR(strftime))
@@ -1043,7 +1045,7 @@ char *mingw_mktemp(char *template)
 int mkstemp(char *template)
 {
        char *filename = mktemp(template);
-       if (filename == NULL)
+       if (!filename)
                return -1;
        return open(filename, O_RDWR | O_CREAT, 0600);
 }
@@ -1126,6 +1128,10 @@ char *mingw_getcwd(char *pointer, int len)
        }
        if (!ret || ret >= ARRAY_SIZE(wpointer))
                return NULL;
+       if (GetFileAttributesW(wpointer) == INVALID_FILE_ATTRIBUTES) {
+               errno = ENOENT;
+               return NULL;
+       }
        if (xwcstoutf(pointer, wpointer, len) < 0)
                return NULL;
        convert_slashes(pointer);
@@ -2186,7 +2192,7 @@ enum EXTENDED_NAME_FORMAT {
 
 static char *get_extended_user_info(enum EXTENDED_NAME_FORMAT type)
 {
-       DECLARE_PROC_ADDR(secur32.dll, BOOL, GetUserNameExW,
+       DECLARE_PROC_ADDR(secur32.dll, BOOL, SEC_ENTRY, GetUserNameExW,
                enum EXTENDED_NAME_FORMAT, LPCWSTR, PULONG);
        static wchar_t wbuffer[1024];
        DWORD len;
@@ -2311,7 +2317,7 @@ int setitimer(int type, struct itimerval *in, struct itimerval *out)
        static const struct timeval zero;
        static int atexit_done;
 
-       if (out != NULL)
+       if (out)
                return errno = EINVAL,
                        error("setitimer param 3 != NULL not implemented");
        if (!is_timeval_eq(&in->it_interval, &zero) &&
@@ -2340,7 +2346,7 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
        if (sig != SIGALRM)
                return errno = EINVAL,
                        error("sigaction only implemented for SIGALRM");
-       if (out != NULL)
+       if (out)
                return errno = EINVAL,
                        error("sigaction: param 3 != NULL not implemented");