Date: Sat, 19 May 2001 19:26:16 +0100 From: Nik Clayton <nik@freebsd.org> To: John Reynolds <jjreynold@home.com> Cc: Nik Clayton <nik@freebsd.org>, doc@freebsd.org Subject: Re: Policy on image source files in the CVS tree Message-ID: <20010519192616.F1757@catkin.nothing-going-on.org> In-Reply-To: <15110.6647.401843.440974@whale.home-net>; from jjreynold@home.com on Sat, May 19, 2001 at 12:00:07AM -0700 References: <20010517113103.A25222@Odin.AC.HMC.Edu> <200105180028.f4I0Snn05073@bmah-freebsd-0.cisco.com> <20010518013645.A8358@catkin.nothing-going-on.org> <15109.16691.817238.944467@hip186.ch.intel.com> <20010518184813.B12846@catkin.nothing-going-on.org> <15109.25794.690992.994411@hip186.ch.intel.com> <20010518224728.C1757@catkin.nothing-going-on.org> <15109.43699.126204.944263@hip186.ch.intel.com> <20010519004606.E1757@catkin.nothing-going-on.org> <15110.6647.401843.440974@whale.home-net>
next in thread | previous in thread | raw e-mail | index | archive | help
--WIIRZ1HQ6FgrlPgb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, May 19, 2001 at 12:00:07AM -0700, John Reynolds wrote: > As a followup Nik, yes the one in the ports collection is hosed too. >=20 > if(!strcmp(MAGIC, header)) > err(1, "Expecting '%s', read '%s'", MAGIC, header); >=20 > strcmp will return '0' if 'header' matches MAGIC. In the case that you're= using > the right scrshot(1), it will. In all my test cases, it does. So: >=20 > if(!(0)) > err(1, "Expecting '%s', read '%s'", MAGIC, header); This puzzled me, because I never ran in to it. Then I worked out why it happened. 1. fread(header, sizeof(unsigned char), 8, stdin) reads in eight bytes, and does not NULL terminate "header". So the rest of "header" will contain whatever junk was already in memory. 2. I used strcmp() instead of strncmp() to do the comparison. In my=20 case there was non-NULL junk in "header" after the "STRSHOT_" string, so the test failed, but the logic of the test was inverted, so it didn't fail (if you see what I mean). I think I may have been damaged by too much Perl programming in the past few years. v1.1 of shot2{png,txt} will fix this. N --=20 FreeBSD: The Power to Serve http://www.freebsd.org/ FreeBSD Documentation Project http://www.freebsd.org/docproj/ --- 15B8 3FFC DDB4 34B0 AA5F 94B7 93A8 0764 2C37 E375 --- --WIIRZ1HQ6FgrlPgb Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.5 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjsGuscACgkQk6gHZCw343WueQCdEHZmPwnGXQTEoTd8g43liMUh a60An3CidX+SkPwoFKVtKg1ZhFZKAikt =qZid -----END PGP SIGNATURE----- --WIIRZ1HQ6FgrlPgb-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010519192616.F1757>