Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3525840pxb; Wed, 14 Apr 2021 07:30:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4C+IpGpG2yOqmQfHxELcZP3LcZEohndKOMHGkpeV6ywNVTDlv0qlmcrg3X7+93+XBifs5 X-Received: by 2002:a17:906:f1cb:: with SMTP id gx11mr19221758ejb.106.1618410602943; Wed, 14 Apr 2021 07:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618410602; cv=none; d=google.com; s=arc-20160816; b=IRNtXyCwsq3RGsqKI5VedlzI4kosKdosa/DSEmex20iZSnid8YfZ+f8cdXIPh/p+QI R7ap3op7VEqvuyySmIzYXrpmRdq4xQKeNk0Rumv8DYA1ANPXU4Uqz5pRV/OfkAwJoXrl yM5w5ipQV5j8K/FFb5+Ev/X442ZomVIqI7DOQOHq8ZXeDKL0cY4ITl3529fQslPz/mpd 4XPD9ILCsop7sXonJjyLLkCYNhsxGmb80hPQs3bzmQHJ84OGW3TrHncvmZjQgo9Cz/u9 jEwPyNh8AK0/2XmnWuecq3LRe/DOkkrn2HU1sBHSTZyhmjwcFBewjZKJjXUkJ/XQGSKs n3vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=xU8WG5+NcR3eTLPyi1wo1D3S3/zOx39I7p4dBbe6EwU=; b=dMoziWicjww+PTwOymhx3tAXblXDBTyDndeO1xxFdqIkegr7UdB0jDIynSNqgG0MDc dDmcHSAfMsh/BObukKgfpleSGxv2BwuaUIjgQ36aJbiL7UFYm7QZ4IKShi6k5tFb/9AA qaANFg44Cp7aJjNRXAq7Fa2106BZL6uIzFFtrKseFgdTGz3BobAeZUUcuHRZrlbJF8Kf fh/56RU7WP8eSC4g9XL5FKRLlH1E7DW/nWQc+BzIeCi35g75aC0PdLG91NrlQCQOXsZ8 a64vFP/vA9s3a/mGiJF14dN4ETtpT7ylr129XE9L/FfO9SKX87f00UX8T3BZupzpTKGV eqfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mforney-org.20150623.gappssmtp.com header.s=20150623 header.b=nYrpIc9P; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oq24si10046931ejb.208.2021.04.14.07.29.36; Wed, 14 Apr 2021 07:30:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mforney-org.20150623.gappssmtp.com header.s=20150623 header.b=nYrpIc9P; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230488AbhDNHma (ORCPT + 99 others); Wed, 14 Apr 2021 03:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349580AbhDNHm3 (ORCPT ); Wed, 14 Apr 2021 03:42:29 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49430C061574 for ; Wed, 14 Apr 2021 00:42:08 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id z16so13801388pga.1 for ; Wed, 14 Apr 2021 00:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mforney-org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=xU8WG5+NcR3eTLPyi1wo1D3S3/zOx39I7p4dBbe6EwU=; b=nYrpIc9PHHZ/LhMMSwMIkPMzKQWwl6aXom7z6/i7LVQIikFs7DCPtOUIMpf9snGwJ9 t+bdbCyoxkC8qxYih4ts96TyghNw7gBtaY2y0lAFKOoHJ8JKIjfKqCPc4TBAvPWLwoFR RWUw8QJOgfF1qBVjU5UKKKVA0Pl0Y8I01ar3Mj7zuruPF+5M1TCiL27aiCom+zeySUyi Pb7zj8Tw/GSzaGcxLDJ5t8+8cr2g0NVUKoTneYvyJH11TwMLvJjRVhP6yTsn9Sje+lfm 9Ucwnr2DeQOJLl3r3LlXEwTMbdfA5F72YqHmpucAAeBWg4hZjmbEtdLoykSapVmwMKR8 BNEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=xU8WG5+NcR3eTLPyi1wo1D3S3/zOx39I7p4dBbe6EwU=; b=YrPsQDgO0+NCV9EJPjC0RCi7mE+3C+zRViZVOSagPihQqFcqyun9BHyQUQH64i6rzx xFn95zQqMZJYxpZKSert/Tq4K5ZuClOAPl3RWIeY/k+5s4ws7phbt/A/QCpkL2OiXXem 39EwPvA/2MBmpKet0a7zNuKz1ao+VFXfoB9yhle8yOXAh0ECXnm5G+0MWaivj1ADX8QE 6/huk/s3Lqwb+cAphmxxI8TatfTBu8S/55e79aGUDbn2faJn4R/sXjtCIKPUSdKxR2ck QqyfaFbFGp4zw6GoNeNgF5YGemyEKg3Ez2vZLaX+8zgEblkBChg2En9SE/K+cfwEmWO+ yCwQ== X-Gm-Message-State: AOAM530INRs8kwzMdPJRBz9RKlTnp1VAC3czVKBERj+XZ4NCEwCRQ/M9 E8VYw5RlPC6aTzWbD17Xf1QABg/T2mhbAwdEDQA= X-Received: by 2002:aa7:850c:0:b029:24c:b470:cc79 with SMTP id v12-20020aa7850c0000b029024cb470cc79mr13740297pfn.69.1618386127599; Wed, 14 Apr 2021 00:42:07 -0700 (PDT) Received: from localhost ([2601:647:5180:4570:16dd:a9ff:fee7:6b79]) by smtp.gmail.com with ESMTPSA id x62sm1175268pfb.71.2021.04.14.00.42.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Apr 2021 00:42:07 -0700 (PDT) From: Michael Forney To: linux-ext4@vger.kernel.org Subject: [PATCH 1/2] libext2fs: use statement-expression for container_of only on GNU-compatible compilers Date: Wed, 14 Apr 2021 00:41:27 -0700 Message-Id: <20210414074128.31268-1-mforney@mforney.org> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Functionally, the statement-expression is not necessary here; it just gives a bit of type-safety to make sure the pointer really does have a compatible type with the specified member of the struct. When statement expressions are not available, we can just use a portable fallback macro that skips this member type check. Signed-off-by: Michael Forney --- lib/ext2fs/compiler.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ext2fs/compiler.h b/lib/ext2fs/compiler.h index 9aa9b4ec..03c35ab8 100644 --- a/lib/ext2fs/compiler.h +++ b/lib/ext2fs/compiler.h @@ -14,9 +14,14 @@ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif +#ifdef __GNUC__ #define container_of(ptr, type, member) ({ \ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) +#else +#define container_of(ptr, type, member) \ + ((type *)((char *)(ptr) - offsetof(type, member))) +#endif #endif /* _EXT2FS_COMPILER_H */ -- 2.30.1