- Remove unnecessary line from FreeEnvironmentStringsW.
[reactos.git] / reactos / dll / win32 / kernel32 / misc / env.c
index ab6c2d7..b132abf 100644 (file)
@@ -21,7 +21,7 @@
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetEnvironmentVariableA (
        LPCSTR  lpName,
        LPSTR   lpBuffer,
@@ -124,7 +124,7 @@ GetEnvironmentVariableA (
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetEnvironmentVariableW (
        LPCWSTR lpName,
        LPWSTR  lpBuffer,
@@ -139,7 +139,7 @@ GetEnvironmentVariableW (
                              lpName);
 
        VarValue.Length = 0;
-       VarValue.MaximumLength = (USHORT)(nSize != 0 ? (nSize - 1) * sizeof(WCHAR) : 0);
+       VarValue.MaximumLength = (USHORT) (nSize ? nSize - 1 : 0) * sizeof(WCHAR);
        VarValue.Buffer = lpBuffer;
 
        Status = RtlQueryEnvironmentVariable_U (NULL,
@@ -147,13 +147,13 @@ GetEnvironmentVariableW (
                                                &VarValue);
        if (!NT_SUCCESS(Status))
        {
-               SetLastErrorByStatus (Status);
                if (Status == STATUS_BUFFER_TOO_SMALL)
                {
                        return (VarValue.Length / sizeof(WCHAR)) + 1;
                }
                else
                {
+                       SetLastErrorByStatus (Status);
                        return 0;
                }
        }
@@ -162,7 +162,7 @@ GetEnvironmentVariableW (
         {
             /* make sure the string is NULL-terminated! RtlQueryEnvironmentVariable_U
                only terminates it if MaximumLength < Length */
-           VarValue.Buffer[VarValue.Length / sizeof(WCHAR)] = L'\0';
+           lpBuffer[VarValue.Length / sizeof(WCHAR)] = L'\0';
        }
 
        return (VarValue.Length / sizeof(WCHAR));
@@ -173,7 +173,7 @@ GetEnvironmentVariableW (
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 SetEnvironmentVariableA (
        LPCSTR  lpName,
        LPCSTR  lpValue
@@ -229,7 +229,7 @@ SetEnvironmentVariableA (
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 SetEnvironmentVariableW (
        LPCWSTR lpName,
        LPCWSTR lpValue
@@ -244,21 +244,12 @@ SetEnvironmentVariableW (
        RtlInitUnicodeString (&VarName,
                              lpName);
 
-       if (lpValue)
-       {
-               RtlInitUnicodeString (&VarValue,
-                                     lpValue);
+       RtlInitUnicodeString (&VarValue,
+                             lpValue);
 
-               Status = RtlSetEnvironmentVariable (NULL,
-                                                   &VarName,
-                                                   &VarValue);
-       }
-       else
-       {
-               Status = RtlSetEnvironmentVariable (NULL,
-                                                   &VarName,
-                                                   NULL);
-       }
+       Status = RtlSetEnvironmentVariable (NULL,
+                                           &VarName,
+                                           &VarValue);
 
        if (!NT_SUCCESS(Status))
        {
@@ -274,7 +265,7 @@ SetEnvironmentVariableW (
  * @implemented
  */
 LPSTR
-STDCALL
+WINAPI
 GetEnvironmentStringsA (
        VOID
        )
@@ -353,7 +344,7 @@ GetEnvironmentStringsA (
  * @implemented
  */
 LPWSTR
-STDCALL
+WINAPI
 GetEnvironmentStringsW (
        VOID
        )
@@ -366,7 +357,7 @@ GetEnvironmentStringsW (
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 FreeEnvironmentStringsA (
        LPSTR   EnvironmentStrings
        )
@@ -386,12 +377,11 @@ FreeEnvironmentStringsA (
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 FreeEnvironmentStringsW (
        LPWSTR  EnvironmentStrings
        )
 {
- (void)EnvironmentStrings;
  return TRUE;
 }
 
@@ -400,7 +390,7 @@ FreeEnvironmentStringsW (
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 ExpandEnvironmentStringsA (
        LPCSTR  lpSrc,
        LPSTR   lpDst,
@@ -480,7 +470,7 @@ ExpandEnvironmentStringsA (
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 ExpandEnvironmentStringsW (
        LPCWSTR lpSrc,
        LPWSTR  lpDst,