[Flightgear-devel] warning: suggest parentheses around assignment used as truth value

2002-02-12 Thread D Luff

In net_send.cxx, in NetworkOLK, we have the following at line 262:

   if (host_info = gethostbyname( src_host)) {

at line 270:

   if (host_info = gethostbyname( fgd_host)) {

and at line 298:

   if (host_info = gethostbyname( fgd_host_check)) {


Surely these are mistakes?

Cheers - Dave

--
[EMAIL PROTECTED]

___
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel



Re: [Flightgear-devel] warning: suggest parentheses around assignment used as truth value

2002-02-12 Thread Curtis L. Olson

gethostbyname() returns NULL if an error occured.

Expressions such as (a = b + c) evaluate to whatever value is assigned
to a so we can do things like

if ( a = b + c ) {
  // a != 0
} else {
  // a == 0
}

This is a little tricky, so if gethostbyname() fails, host_info will
be assigned a value of NULL and the whole entire expression then
evaluates to NULL so this should work (at least on systems that define
NULL to be 0x00.)

That said, the entire NetworkOLK module is only half implimented, and
not really useful at this point.  We really need someone to come along
and finish it, or perhaps reimpliment this functionality from scratch
using the plib networking libs.

Regards,

Curt.


D Luff writes:
 In net_send.cxx, in NetworkOLK, we have the following at line 262:
 
if (host_info = gethostbyname( src_host)) {
 
 at line 270:
 
if (host_info = gethostbyname( fgd_host)) {
 
 and at line 298:
 
if (host_info = gethostbyname( fgd_host_check)) {
 
 
 Surely these are mistakes?
 
 Cheers - Dave
 
 --
 [EMAIL PROTECTED]
 
 ___
 Flightgear-devel mailing list
 [EMAIL PROTECTED]
 http://mail.flightgear.org/mailman/listinfo/flightgear-devel

-- 
Curtis Olson   IVLab / HumanFIRST Program   FlightGear Project
Twin Cities[EMAIL PROTECTED]  [EMAIL PROTECTED]
Minnesota  http://www.menet.umn.edu/~curt   http://www.flightgear.org

___
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel



Re: [Flightgear-devel] warning: suggest parentheses around assignment used as truth value

2002-02-12 Thread Christian Mayer

Curtis L. Olson wrote:
 
 That said, the entire NetworkOLK module is only half implimented, and
 not really useful at this point.  We really need someone to come along
 and finish it, or perhaps reimpliment this functionality from scratch
 using the plib networking libs.

Please use the PLIB approach as IIRC NetworkOLK doesn't compile at all
under MSVC...

CU,
Christian

--
The idea is to die young as late as possible.-- Ashley Montague

Whoever that is/was; (c) by Douglas Adams would have been better...

___
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel



Re: [Flightgear-devel] warning: suggest parentheses around assignment used as truth value

2002-02-12 Thread D Luff

Curtis L. Olson writes:

 gethostbyname() returns NULL if an error occured.
 
 Expressions such as (a = b + c) evaluate to whatever value is assigned
 to a so we can do things like
 
 if ( a = b + c ) {
   // a != 0
 } else {
   // a == 0
 }
 
 This is a little tricky, so if gethostbyname() fails, host_info will
 be assigned a value of NULL and the whole entire expression then
 evaluates to NULL so this should work (at least on systems that define
 NULL to be 0x00.)
 

Thanks, I see whats going on now.  I don't particularly like it 
though! 

a = b + c;
if(a) {
...
} else {
...
}

seems like a much better construct to me - trading a touch of 
consiseness (is that a word?) for complete clarity as to the authors 
intent.

 That said, the entire NetworkOLK module is only half implimented, and
 not really useful at this point.  We really need someone to come along
 and finish it, or perhaps reimpliment this functionality from scratch
 using the plib networking libs.

I must confess I wasn't looking at doing anything with NetworkOLK, 
simply compiling with -Wall.

Cheers - Dave



--
[EMAIL PROTECTED]

___
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel



Re: [Flightgear-devel] warning: suggest parentheses around assignment used as truth value

2002-02-12 Thread Cameron Moore

Fixes...

* [EMAIL PROTECTED] (D Luff) [2002.02.12 07:42]:
 In net_send.cxx, in NetworkOLK, we have the following at line 262:
if (host_info = gethostbyname( src_host)) {

 if ((host_info = gethostbyname( src_host)) != NULL) {


 at line 270:
if (host_info = gethostbyname( fgd_host)) {

 if ((host_info = gethostbyname( fgd_host) != NULL) {

 and at line 298:
if (host_info = gethostbyname( fgd_host_check)) {

 if ((host_info = gethostbyname( fgd_host_check)) != NULL) {
-- 
Cameron Moore
[ I'm trying to daydream, but my mind keeps wandering. ]

___
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel