diff options
author | Chris Kuethe <ckuethe@users.berlios.de> | 2010-12-25 23:53:27 -0600 |
---|---|---|
committer | Chris Kuethe <ckuethe@users.berlios.de> | 2010-12-25 23:53:27 -0600 |
commit | 1ebbebbbf0b83b6904d17db2590af295ec674601 (patch) | |
tree | 8519116321ec3deb3e2e9f09dbaf862de19a7656 /www | |
parent | c7e9d8622b4b3a6fa9f87a6b0d955d99245d73cf (diff) | |
download | gpsd-1ebbebbbf0b83b6904d17db2590af295ec674601.tar.gz |
sizeof(long) is not portable
More Commits from the Caribbean.
The geostar driver operates on 4-byte words, so change increments to 4 bytes.
Add a note to the prototype driver and the hacking guide to indicate that the
sizeof(<std int type>) should be avoided for extracting fixed size blocks from
a packet.
Diffstat (limited to 'www')
-rw-r--r-- | www/hacking.html | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/www/hacking.html b/www/hacking.html index 67fc7324..cd528926 100644 --- a/www/hacking.html +++ b/www/hacking.html @@ -81,6 +81,7 @@ file in the source distribution.</p> <li><a href="#options">Don't add invocation options!</a></li> <li><a href="#statics">Don't create static variables in the libraries!</li> <li><a href="#malloc">Don't use malloc!</a></li> +<li><a href="#sizeof">Avoid use of sizeof(<int type>)!</a></li> </ol> <li><a href="#understanding">Understanding the code</a></li> <ol> @@ -441,6 +442,13 @@ to be embedding a PATH_MAX-sized buffer in the gpsd.h structure.</p> <p>Don't undo this by using malloc/free in a driver or anywhere else.</p> +<h2 id="sizeof">Avoid use of sizeof(<int type>)!</h2> +<p>It's tempting to extract parts of packets with by using a loop of the +form "<code>for(i = 0; i < len; i += sizeof(long))</code>". Don't do that; +not all integer types have the same length across architectures. A long may +be 4 bytes on a 32-bit machine and 8 bytes on a 64-bit. If you mean to skip +4 bytes in a packet, then say so.</p> + <h1 id="understanding">Understanding the code</h1> <h2 id="debugging">Debugging</h2> |