Subject: [ libssh2-Bugs-2787839 ] Warnings when compiling under MSVC2008

[ libssh2-Bugs-2787839 ] Warnings when compiling under MSVC2008

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Tue, 12 May 2009 09:49:56 +0000

Bugs item #2787839, was opened at 2009-05-06 14:50
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=2787839&group_id=125852

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: misc
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Steven Van Ingelgem (g00fy)
Assigned to: Daniel Stenberg (bagder)
Summary: Warnings when compiling under MSVC2008

Initial Comment:
..\..\externals\libssh2\src\sftp.c(381) : warning C4244: 'initializing' : conversion from 'time_t' to 'long', possible loss of data
..\..\externals\libssh2\src\sftp.c(1657) : warning C4244: 'return' : conversion from 'libssh2_uint64_t' to 'size_t', possible loss of data

..\..\externals\libssh2\src\scp.c(750) : warning C4244: '=' : conversion from 'long' to 'unsigned short', possible loss of data

..\..\externals\libssh2\src\packet.c(1081) : warning C4244: 'initializing' : conversion from 'time_t' to 'long', possible loss of data
..\..\externals\libssh2\src\packet.c(1190) : warning C4244: 'initializing' : conversion from 'time_t' to 'long', possible loss of data

----------------------------------------------------------------------

>Comment By: Daniel Stenberg (bagder)
Date: 2009-05-12 11:49

Message:
any chance you could provide a patch that fixes the warnings?

----------------------------------------------------------------------

Comment By: Steven Van Ingelgem (g00fy)
Date: 2009-05-08 12:19

Message:
Hi badger,

I just checked out the provided .dsw (converted it with "MS Visual Studio
2008, version 9.0.30729.1 SP" (VS Studio Express C++))...
What I did:
* checkout from CVS the latest version
* open libssh2/win32/libssh2.dsw with my VSStudio
* press "yes to all" at the conversion question
* build everything in debug mode

I get these errors:
1>------ Build started: Project: libssh2_lib, Configuration: Debug Win32
------
2>------ Build started: Project: libssh2_dll, Configuration: Debug Win32
------
1>Compiling...
2>Compiling...
1>comp.c
2>channel.c
1>crypt.c
1>hostkey.c
2>libssh2\src\channel.c(1233) : warning C4996: 'sprintf': This function or
variable may be unsafe. Consider using sprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
2>comp.c
2>crypt.c
2>hostkey.c
2>libssh2\include\libssh2.h(566) : error C2061: syntax error : identifier
'libssh2_channel_read_ex'
2>libssh2\include\libssh2.h(566) : error C2059: syntax error : ';'
2>libssh2\include\libssh2.h(566) : error C2059: syntax error : 'type'
2>libssh2\include\libssh2.h(596) : error C2061: syntax error : identifier
'libssh2_channel_write_ex'
1>libssh2\include\libssh2.h(566) : error C2061: syntax error : identifier
'libssh2_channel_read_ex'
1>libssh2\include\libssh2.h(566) : error C2059: syntax error : ';'
2>libssh2\include\libssh2.h(596) : error C2059: syntax error : ';'
2>libssh2\include\libssh2.h(596) : error C2059: syntax error : 'type'
2>libssh2\src\hostkey.c(445) : error C2491: 'libssh2_hostkey_hash' :
definition of dllimport function not allowed
2>libssh2\src\hostkey.c(468) : error C2491: 'libssh2_session_hostkey' :
definition of dllimport function not allowed
2>kex.c
1>libssh2\include\libssh2.h(566) : error C2059: syntax error : 'type'
1>libssh2\include\libssh2.h(596) : error C2061: syntax error : identifier
'libssh2_channel_write_ex'
1>libssh2\include\libssh2.h(596) : error C2059: syntax error : ';'
1>libssh2\include\libssh2.h(596) : error C2059: syntax error : 'type'
1>libssh2\src\hostkey.c(445) : error C2491: 'libssh2_hostkey_hash' :
definition of dllimport function not allowed
1>libssh2\src\hostkey.c(468) : error C2491: 'libssh2_session_hostkey' :
definition of dllimport function not allowed
1>kex.c
2>mac.c
2>misc.c
2>libssh2\src\misc.c(282) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
2>libssh2\src\misc.c(288) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
2>libssh2\src\misc.c(295) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
1>mac.c
2>openssl.c
2>packet.c
1>misc.c
1>libssh2\src\misc.c(282) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2>libssh2\src\packet.c(1081) : warning C4244: 'initializing' : conversion
from 'time_t' to 'long', possible loss of data
1> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
1>libssh2\src\misc.c(288) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
2>libssh2\src\packet.c(1190) : warning C4244: 'initializing' : conversion
from 'time_t' to 'long', possible loss of data
1>libssh2\src\misc.c(295) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
2>pem.c
1>openssl.c
1>packet.c
2>publickey.c
1>libssh2\src\packet.c(1081) : warning C4244: 'initializing' : conversion
from 'time_t' to 'long', possible loss of data
1>libssh2\src\packet.c(1190) : warning C4244: 'initializing' : conversion
from 'time_t' to 'long', possible loss of data
2>scp.c
1>pem.c
2>libssh2\src\scp.c(292) : warning C4996: 'sprintf': This function or
variable may be unsafe. Consider using sprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
2>libssh2\src\scp.c(750) : warning C4244: '=' : conversion from 'long' to
'unsigned short', possible loss of data
2>libssh2\src\scp.c(792) : warning C4996: 'sprintf': This function or
variable may be unsafe. Consider using sprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
2>libssh2\src\scp.c(877) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
2>libssh2\src\scp.c(939) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
2>session.c
1>publickey.c
2>sftp.c
1>scp.c
2>libssh2\src\sftp.c(381) : warning C4244: 'initializing' : conversion
from 'time_t' to 'long', possible loss of data
1>libssh2\src\scp.c(292) : warning C4996: 'sprintf': This function or
variable may be unsafe. Consider using sprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2>libssh2\src\sftp.c(1657) : warning C4244: 'return' : conversion from
'libssh2_uint64_t' to 'size_t', possible loss of data
1> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
1>libssh2\src\scp.c(750) : warning C4244: '=' : conversion from 'long' to
'unsigned short', possible loss of data
1>libssh2\src\scp.c(792) : warning C4996: 'sprintf': This function or
variable may be unsafe. Consider using sprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
1>libssh2\src\scp.c(877) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
1>libssh2\src\scp.c(939) : warning C4996: '_snprintf': This function or
variable may be unsafe. Consider using _snprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(358) : see declaration of '_snprintf'
2>transport.c
1>session.c
1>sftp.c
2>userauth.c
2>libssh2\src\userauth.c(490) : warning C4996: 'fopen': This function or
variable may be unsafe. Consider using fopen_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
2> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(237) : see declaration of 'fopen'
2>Generating Code...
1>libssh2\src\sftp.c(381) : warning C4244: 'initializing' : conversion
from 'time_t' to 'long', possible loss of data
1>libssh2\src\sftp.c(1657) : warning C4244: 'return' : conversion from
'libssh2_uint64_t' to 'size_t', possible loss of data
1>transport.c
2>Build log was saved at "file://libssh2\win32\Debug_dll\BuildLog.htm"
2>libssh2_dll - 8 error(s), 14 warning(s)
1>userauth.c
3>------ Build started: Project: tests, Configuration: Debug Win32 ------
3>Compiling...
1>libssh2\src\userauth.c(490) : warning C4996: 'fopen': This function or
variable may be unsafe. Consider using fopen_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(237) : see declaration of 'fopen'
3>simple.c
1>channel.c
3>libssh2\include\libssh2.h(566) : error C2061: syntax error : identifier
'libssh2_channel_read_ex'
3>libssh2\include\libssh2.h(566) : error C2059: syntax error : ';'
3>libssh2\include\libssh2.h(566) : error C2059: syntax error : 'type'
3>libssh2\include\libssh2.h(596) : error C2061: syntax error : identifier
'libssh2_channel_write_ex'
3>libssh2\include\libssh2.h(596) : error C2059: syntax error : ';'
3>libssh2\include\libssh2.h(596) : error C2059: syntax error : 'type'
3>Build log was saved at "file://libssh2\win32\Debug\BuildLog.htm"
3>tests - 6 error(s), 0 warning(s)
1>libssh2\src\channel.c(1233) : warning C4996: 'sprintf': This function or
variable may be unsafe. Consider using sprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio
9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
1>Generating Code...
1>Build log was saved at "file://libssh2\win32\Debug_lib\BuildLog.htm"
1>libssh2_lib - 8 error(s), 14 warning(s)
========== Build: 0 succeeded, 3 failed, 0 up-to-date, 0 skipped
==========

I think the error level is fine (W3 is good enough), and the warnings it
give are all reasonable in fact...

For example a time_t is generally an "unsigned int", but nowadays (as we
aproach 2038) this is generally an unsigned long long or so. Converting
this to a long might pose problems in the "near" future.

Same goes for the other warnings...

W4 would be way too high, but it might be usefull to have a look at them
to see if you might have some very hard to debug errors (like comparing
(DWORD)-1==-1 or so):
"conditional expression is constant"
"unreferenced formal parameter"
"'=' : conversion from 'int' to 'char', possible loss of data"
"nonstandard extension, function/data pointer conversion in expression"
"'==' : signed/unsigned mismatch"
"potentially uninitialized local variable 'data' used"

Grtz,
Steven

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2009-05-07 21:40

Message:
So what "error levels" are you guys using and what do you think we should
consider a "sensible" level to be?

----------------------------------------------------------------------

Comment By: Steven Van Ingelgem (g00fy)
Date: 2009-05-06 15:08

Message:
Probably this is because you use the default projects. I re-create my
project via CMake so I could hang it in my current build-tree.

Very probably the error level is higher than the one in the default
projects?

----------------------------------------------------------------------

Comment By: Neil Gierman (roadrunn)
Date: 2009-05-06 15:05

Message:
I am using VS2008 and don't get any warnings. In my pre-build events, I am
copying the libssh2_config.h from the win32 directory in the source to the
src directory.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=2787839&group_id=125852

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-05-12