Author: tkreuzer
Date: Sun Dec 16 16:38:36 2012
New Revision: 57928
URL:
http://svn.reactos.org/svn/reactos?rev=57928&view=rev
Log:
[CRT]
Fix / silence a number of warnings/errors detected with VS-analyze
Modified:
trunk/reactos/lib/sdk/crt/include/internal/mingw-w64/internal.h
trunk/reactos/lib/sdk/crt/include/internal/rterror.h
trunk/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h
trunk/reactos/lib/sdk/crt/mbstring/mbclen.c
trunk/reactos/lib/sdk/crt/mbstring/mbstrlen.c
trunk/reactos/lib/sdk/crt/stdio/popen.c
trunk/reactos/lib/sdk/crt/stdio/stat64.c
trunk/reactos/lib/sdk/crt/stdlib/getenv.c
trunk/reactos/lib/sdk/crt/string/_mbstrnlen.c
trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c
trunk/reactos/lib/sdk/crt/string/scanf.h
trunk/reactos/lib/sdk/crt/string/splitp.c
trunk/reactos/lib/sdk/crt/string/strtoi64.c
trunk/reactos/lib/sdk/crt/string/wcstombs_s.c
trunk/reactos/lib/sdk/crt/time/ctime.c
trunk/reactos/lib/sdk/crt/time/strftime.c
trunk/reactos/lib/sdk/crt/time/timezone.c
trunk/reactos/lib/sdk/crt/wine/undname.c
Modified: trunk/reactos/lib/sdk/crt/include/internal/mingw-w64/internal.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/intern…
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/mingw-w64/internal.h [iso-8859-1]
(original)
+++ trunk/reactos/lib/sdk/crt/include/internal/mingw-w64/internal.h [iso-8859-1] Sun Dec
16 16:38:36 2012
@@ -139,7 +139,7 @@
/* __CRTIMP extern wchar_t *_wcmdln; */
#endif
- _CRTIMP void __cdecl _amsg_exit(int);
+ _CRTIMP __declspec(noreturn) void __cdecl _amsg_exit(int);
int __CRTDECL _setargv(void);
int __CRTDECL __setargv(void);
Modified: trunk/reactos/lib/sdk/crt/include/internal/rterror.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/intern…
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/rterror.h [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/rterror.h [iso-8859-1] Sun Dec 16 16:38:36
2012
@@ -25,7 +25,7 @@
#define _RT_STDIOINIT 15 /* not enough space for stdio initialization */
#define _RT_LOWIOINIT 16 /* not enough space for lowio initialization */
-void _amsg_exit (int errnum);
+__declspec(noreturn) void _amsg_exit (int errnum);
/* not in any other header */
void _dosmaperr(unsigned long oserrcode);
Modified: trunk/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/include/intern…
==============================================================================
--- trunk/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h [iso-8859-1] Sun Dec 16
16:38:36 2012
@@ -31,7 +31,7 @@
extern const unsigned short _ctype [257];
void __cdecl _purecall(void);
-void __cdecl _amsg_exit(int errnum);
+__declspec(noreturn) void __cdecl _amsg_exit(int errnum);
extern char **_environ;
extern wchar_t **_wenviron;
Modified: trunk/reactos/lib/sdk/crt/mbstring/mbclen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/mbcle…
==============================================================================
--- trunk/reactos/lib/sdk/crt/mbstring/mbclen.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/mbstring/mbclen.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -34,7 +34,7 @@
{
if (str && *str && size)
{
- return !isleadbyte(*str) ? 1 : (size>1 ? 2 : -1);
+ return !isleadbyte((unsigned char)*str) ? 1 : (size>1 ? 2 : -1);
}
return 0;
}
Modified: trunk/reactos/lib/sdk/crt/mbstring/mbstrlen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/mbstring/mbstr…
==============================================================================
--- trunk/reactos/lib/sdk/crt/mbstring/mbstrlen.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/mbstring/mbstrlen.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -30,7 +30,7 @@
/* FIXME: According to the documentation we are supposed to test for
* multi-byte character validity. Whatever that means
*/
- str += isleadbyte(*str) ? 2 : 1;
+ str += isleadbyte((unsigned char)*str) ? 2 : 1;
len++;
}
return len;
Modified: trunk/reactos/lib/sdk/crt/stdio/popen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/popen.c?…
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/popen.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/popen.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -109,6 +109,7 @@
}
CloseHandle(ProcessInformation.hThread);
+ CloseHandle(ProcessInformation.hProcess);
if ( *md == 'r' )
{
Modified: trunk/reactos/lib/sdk/crt/stdio/stat64.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/stat64.c…
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/stat64.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/stat64.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -45,7 +45,7 @@
Also a letter as first char isn't enough to be classified
as a drive letter
*/
- if (isalpha(*path)&& (*(path+1)==':'))
+ if (isalpha((unsigned char)*path)&& (*(path+1)==':'))
buf->st_dev = buf->st_rdev = _totupper(*path) - 'A'; /* drive num */
else
buf->st_dev = buf->st_rdev = _getdrive() - 1;
Modified: trunk/reactos/lib/sdk/crt/stdlib/getenv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdlib/getenv.…
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdlib/getenv.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdlib/getenv.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -16,12 +16,12 @@
*/
char *getenv(const char *name)
{
- char **environ;
+ char **env;
size_t length = strlen(name);
- for (environ = *__p__environ(); *environ; environ++)
+ for (env = *__p__environ(); *env; env++)
{
- char *str = *environ;
+ char *str = *env;
char *pos = strchr(str,'=');
if (pos && ((unsigned int)(pos - str) == length) && !_strnicmp(str,
name, length))
return pos + 1;
@@ -34,12 +34,12 @@
*/
wchar_t *_wgetenv(const wchar_t *name)
{
- wchar_t **environ;
+ wchar_t **env;
size_t length = wcslen(name);
- for (environ = *__p__wenviron(); *environ; environ++)
+ for (env = *__p__wenviron(); *env; env++)
{
- wchar_t *str = *environ;
+ wchar_t *str = *env;
wchar_t *pos = wcschr(str, L'=');
if (pos && ((unsigned int)(pos - str) == length) && !_wcsnicmp(str,
name, length))
return pos + 1;
Modified: trunk/reactos/lib/sdk/crt/string/_mbstrnlen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/_mbstrn…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/_mbstrnlen.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/_mbstrnlen.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -10,6 +10,7 @@
#include <mbctype.h>
#include <specstrings.h>
+_Success_(return>0)
_Check_return_
_CRTIMP
size_t
Modified: trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/mbstowc…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -9,8 +9,9 @@
#include <precomp.h>
#include <mbstring.h>
+_Success_(return!=EINVAL)
+_Check_return_opt_
_CRTIMP
-_Check_return_opt_
errno_t
__cdecl
mbstowcs_s(
Modified: trunk/reactos/lib/sdk/crt/string/scanf.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/scanf.h…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/scanf.h [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/scanf.h [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -37,8 +37,8 @@
#define _CHAR_ char
#define _EOF_ EOF
#define _EOF_RET EOF
-#define _ISSPACE_(c) isspace(c)
-#define _ISDIGIT_(c) isdigit(c)
+#define _ISSPACE_(c) isspace((unsigned char)(c))
+#define _ISDIGIT_(c) isdigit((unsigned char)(c))
#define _WIDE2SUPPORTED_(c) c /* FIXME: convert wide char to char */
#define _CHAR2SUPPORTED_(c) c /* No conversion needed (char to char) */
#define _CHAR2DIGIT_(c, base) char2digit((c), (base))
Modified: trunk/reactos/lib/sdk/crt/string/splitp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/splitp.…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/splitp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/splitp.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -31,6 +31,8 @@
return;
}
#endif
+
+ _Analysis_assume_(path != 0);
#if WINVER == 0x600
/* Skip '\\?\' prefix */
Modified: trunk/reactos/lib/sdk/crt/string/strtoi64.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/strtoi6…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/strtoi64.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/strtoi64.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -7,7 +7,7 @@
BOOL negative = FALSE;
__int64 ret = 0;
- while(isspace(*nptr)) nptr++;
+ while(isspace((unsigned char)*nptr)) nptr++;
if(*nptr == '-') {
negative = TRUE;
@@ -31,7 +31,7 @@
char cur = tolower(*nptr);
int v;
- if(isdigit(cur)) {
+ if(isdigit((unsigned char)cur)) {
if(cur >= '0'+base)
break;
v = cur-'0';
Modified: trunk/reactos/lib/sdk/crt/string/wcstombs_s.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcstomb…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wcstombs_s.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/wcstombs_s.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -8,6 +8,7 @@
#include <precomp.h>
+_Success_(return!=EINVAL)
_Check_return_wat_
_CRTIMP
errno_t
Modified: trunk/reactos/lib/sdk/crt/time/ctime.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/time/ctime.c?r…
==============================================================================
--- trunk/reactos/lib/sdk/crt/time/ctime.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/time/ctime.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -7,12 +7,11 @@
*/
#define MINGW_HAS_SECURE_API 1
+#include <errno.h>
#define RC_INVOKED 1 // to prevent inline functions
#include <tchar.h>
#include <time.h>
#include "bitsfixup.h"
-
-#define EINVAL -1
/* Doesn't really exist, but we need it here */
_CRTIMP errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time);
Modified: trunk/reactos/lib/sdk/crt/time/strftime.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/time/strftime.…
==============================================================================
--- trunk/reactos/lib/sdk/crt/time/strftime.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/time/strftime.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -2,8 +2,8 @@
* COPYRIGHT: LGPL, See LGPL.txt in the top level directory
* PROJECT: ReactOS CRT library
* FILE: lib/sdk/crt/time/strftime.c
- * PURPOSE:
- * PROGRAMER:
+ * PURPOSE:
+ * PROGRAMER:
*/
#include <precomp.h>
@@ -258,7 +258,7 @@
else
tmp = mstm->tm_wday-1;
- tmp = mstm->tm_yday/7 + (tmp<=mstm->tm_yday%7);
+ tmp = mstm->tm_yday/7 + (tmp <= ((unsigned)mstm->tm_yday%7));
if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 2, 0, 53))
return 0;
break;
Modified: trunk/reactos/lib/sdk/crt/time/timezone.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/time/timezone.…
==============================================================================
--- trunk/reactos/lib/sdk/crt/time/timezone.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/time/timezone.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -219,31 +219,33 @@
*/
int CDECL _get_tzname(size_t *ret, char *buf, size_t bufsize, int index)
{
- char *timezone;
-
- switch(index)
+ char *str_timezone;
+
+ switch (index)
{
case 0:
- timezone = tz_name;
+ str_timezone = tz_name;
break;
+
case 1:
- timezone = tz_dst_name;
+ str_timezone = tz_dst_name;
break;
+
default:
*_errno() = EINVAL;
return EINVAL;
}
- if(!ret || (!buf && bufsize > 0) || (buf && !bufsize))
+ if (!ret || (!buf && (bufsize > 0)) || (buf && !bufsize))
{
*_errno() = EINVAL;
return EINVAL;
}
- *ret = strlen(timezone)+1;
+ *ret = strlen(str_timezone) + 1;
if(!buf && !bufsize)
return 0;
- strcpy(buf, timezone);
+ strncpy(buf, str_timezone, bufsize);
return 0;
}
Modified: trunk/reactos/lib/sdk/crt/wine/undname.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/wine/undname.c…
==============================================================================
--- trunk/reactos/lib/sdk/crt/wine/undname.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/wine/undname.c [iso-8859-1] Sun Dec 16 16:38:36 2012
@@ -216,8 +216,8 @@
for (i = a->max - 1; i >= 0; i--)
{
c = '>';
- if (i < a->start) c = '-';
- else if (i >= a->num) c = '}';
+ if ((unsigned)i < a->start) c = '-';
+ else if ((unsigned)i >= a->num) c = '}';
/* This check is as useless as the unused-but-set gcc warning that we want to
silence here */
if (c != 0) TRACE("%p\t%d%c %s\n", a, i, c, a->elts[i]);
}
@@ -861,7 +861,7 @@
if (!get_modified_type(ct, sym, pmt_ref, in_args ? dt : 'P', in_args))
goto done;
break;
case 'P': /* Pointer */
- if (isdigit(*sym->current))
+ if (isdigit((unsigned char)*sym->current))
{
/* FIXME: P6 = Function pointer, others who knows.. */
if (*sym->current++ == '6')