Re: [Flightgear-devel] MAX_CALLSIGN_LEN

2007-02-22 Thread Csaba Halász
On 2/22/07, Nick Warne [EMAIL PROTECTED] wrote:

 Is this correct?

Yes. In C you need to terminate strings by a 0 byte. So you need 8
bytes for a maximum of 7 characters.

Greets,
Jester

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] MAX_CALLSIGN_LEN

2007-02-22 Thread Nick Warne
On Thursday 22 February 2007 16:13:59 Csaba Halász wrote:
 On 2/22/07, Nick Warne [EMAIL PROTECTED] wrote:
  Is this correct?

 Yes. In C you need to terminate strings by a 0 byte. So you need 8
 bytes for a maximum of 7 characters.

 Greets,
 Jester

Yes, I understand that - but what seems to be happening here is user is 
allowed to input callsign of 8 (or more) and only later is the string looked 
at.  Why not just parse the string to 7 + \0 at runtime?

It appears to me this is done every packet sent?

Nick

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] MAX_CALLSIGN_LEN

2007-02-22 Thread Nick Warne
missed the list off...

--  Forwarded Message  --

Subject: Re: [Flightgear-devel] MAX_CALLSIGN_LEN
Date: Thursday 22 February 2007
From: Nick Warne [EMAIL PROTECTED]
To: Csaba Halász [EMAIL PROTECTED]

On Thursday 22 February 2007 16:40:57 Csaba Halász wrote:
 On 2/22/07, Nick Warne [EMAIL PROTECTED] wrote:
  Yes, I understand that - but what seems to be happening here is user is
  allowed to input callsign of 8 (or more) and only later is the string
  looked at.  Why not just parse the string to 7 + \0 at runtime?
 
  It appears to me this is done every packet sent?

 It is just a string copy, which would have to be done anyway.
 Also, if later the protocol will support longer nicks, it will be
 totally transparent. And this limit is documented. Strictly IMHO.

Yes, OK, but why not do it at runtime?  MAX_CALLSIGN_LEN will determine the 
length no matter what when/if the protocol changes.

I don't see the sense (nor logic) in trimming a string _every_ packet when for 
all pretense and purpose it will not change during a session.  And if users 
can change callsign on the fly (I don't know if you can?), then only that 
update mechanism should address the string, surely?

Nick

---

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] MAX_CALLSIGN_LEN

2007-02-22 Thread Csaba Halász
On 2/22/07, Nick Warne [EMAIL PROTECTED] wrote:

 I don't see the sense (nor logic) in trimming a string _every_ packet when for
 all pretense and purpose it will not change during a session.

The string is not getting trimmed in the conventional sense. The
strncpy just copies at most MAX_CALLSIGN_LEN characters to the packet.
This copying would be necessary anyway, and it is always a good idea
to check that no more bytes are copied than there is space for (cf.
buffer overflow).

-- 
Jester

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel