From owner-cvs-src@FreeBSD.ORG Mon Nov 13 09:35:25 2006 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A62B116A69E; Mon, 13 Nov 2006 09:35:25 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id 30E0243D58; Mon, 13 Nov 2006 09:35:24 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (critter.freebsd.dk [192.168.48.2]) by phk.freebsd.dk (Postfix) with ESMTP id 8D904170C5; Mon, 13 Nov 2006 09:35:23 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.13.8/8.13.8) with ESMTP id kAD9ZJto003802; Mon, 13 Nov 2006 09:35:23 GMT (envelope-from phk@critter.freebsd.dk) To: Bruce Evans From: "Poul-Henning Kamp" In-Reply-To: Your message of "Mon, 13 Nov 2006 19:30:11 +1100." <20061113173927.Q75708@delplex.bde.org> Date: Mon, 13 Nov 2006 09:35:19 +0000 Message-ID: <3801.1163410519@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: Joseph Koshy , src-committers@FreeBSD.org, cvs-all@FreeBSD.org, cvs-src@FreeBSD.org Subject: Re: cvs commit: src/include ar.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Nov 2006 09:35:25 -0000 In message <20061113173927.Q75708@delplex.bde.org>, Bruce Evans writes: >On Mon, 13 Nov 2006, Joseph Koshy wrote: > >> jkoshy 2006-11-13 04:28:29 UTC >> >> FreeBSD src repository >> >> Modified files: >> include ar.h >> Log: >> Attempt to improve application portability by marking `struct ar_hdr' >> as `packed'. >> >> The C standard leaves the alignment of individual members of a C >> struct upto the implementation, so pedantically speaking portable >> code cannot assume that the layout of a `struct ar_hdr' in memory >> will match its layout in a file. Using a __packed attribute >> declaration forces file and memory layouts for this structure to >> match. >> >> Submitted by: ru > >I don't see how this can be more portable. I agree with bruce that __packed is not the way to go. For things that represent communication protocols, even if they happen through files, I advocate using the functions in sys/endian.h to explicitly decode and encode fields into bytestrings. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.