From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 0C7303858C41 for ; Fri, 19 May 2023 21:31:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0C7303858C41 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f24cfb8539so4328732e87.3 for ; Fri, 19 May 2023 14:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684531861; x=1687123861; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=soaz8pGWxx4ezcUt+8yADIO+mhgwkawicydjQxoIxjc=; b=ZY/THugRpOPT+7bHd1siRALJbrLyxRgrIcznmFXcW35lpY5//AKvLoENmYGskX8EbN MdkfQzZKqTpcJH8Xp+dSN28tho1ry7VG9R3OWFSQirPouqXAsNjbFBWYkTRWyLcTPaoP +xWte+Hxt68ZOBzwV85YYbXJoZioFbUtjDXsPR/xb+iUdJU/fF3Z6GQYbPX7zluNWMFs xYm7qQ5akB6YQ+W3QfCbYNTcTY2xBea6zp/ppqBG0ccUiqCRDUzUB9gO4zVAN1F9kDZV pADXDPnz0W2hAxzUuOyF8SM42Zj1AGahuQrjzu8QDp7BxuMEYpQIBjnYBTKqPtwX+6nM Gi9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684531861; x=1687123861; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=soaz8pGWxx4ezcUt+8yADIO+mhgwkawicydjQxoIxjc=; b=WGCPenj57QSxOViawewFgiAaViHRACFxqQfZyryXAqv+MQE9DVHeqmjLDHk/ZZRloJ nXMew+sFF+DFr/0jb6eUsHS1xo5XbXMUoVXAuEAC0Favc/Ysk5KeKCakV2b9ldtX1iIU 3g1t/cupXcx2ZIp8413JUKE0tAfmY+7Pb84HTbFb0R/Q1mIkFvjvl2UWzT+n9nQhZc9L swNIxOEn8k3UWfch83SpSJBFrU3CqehxbgY2SUU4+SvmE4/woJsEh5xmuJUSiVIQfLLS 90LfSpIgzs+ORKeS7J4ri6OAt97ciwUZUwogB2OeR8OmISC8aJaf49da11dTKnhrqvnv 0Z+w== X-Gm-Message-State: AC+VfDycDPtrXmTtj8hhpo7Mm9fw+zNfYBQ0eHaycRDmqBs3HkvsyvZ5 iqgLzsvT7x69bUOACwTmNF0ppm0K/RQ= X-Google-Smtp-Source: ACHHUZ4zn8yhxZqMpyVkHWMg/tMsev6hYhaVg6akpjYhMrXQHKwFO/UrROBvdqBL3XMcePi7tvo3+Q== X-Received: by 2002:ac2:44ac:0:b0:4f3:b07e:7eb8 with SMTP id c12-20020ac244ac000000b004f3b07e7eb8mr962365lfm.29.1684531861104; Fri, 19 May 2023 14:31:01 -0700 (PDT) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:c81f:63f8:270e:be79]) by smtp.gmail.com with ESMTPSA id w25-20020a05651204d900b004f38717ca34sm33069lfq.97.2023.05.19.14.31.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 14:31:00 -0700 (PDT) From: Sergey Bugaev To: libc-alpha@sourceware.org Subject: [RFC PATCH 0/1] Attempt to detect missing fcntl argument at compile time Date: Sat, 20 May 2023 00:30:58 +0300 Message-Id: <20230519213059.3812385-1-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello, here goes another attempt to step out of the comfort zone into the "I don't know what I'm doing" zone -- this time with fcntl and inline wrappers and FORTIFY_SOURCE. It *appears* to build and work and not break anything; I've tried x86_64-gnu, i686-gnu, i686-linux-gnu, and x86_64-linux-gnu. On i686-linux-gnu I've tried defining various macros, such as _LARGEFILE64_SOURCE and _FILE_OFFSET_BITS (to 32 or 64). Things *appear* to work just as I expect them to; the build breaks when I try to compile an fcntl () without a required argument, and I do get an error at runtime as expected too. All the right symbols appear to get referenced in all configurations, too. Still, I'm not very sure I've handled all the possible configurations correctly. The reasoning for __fcntl_cmd_needs_arg () being a function and not a macro is that the definition needs to use multiple #ifdefs and that would be awkward with a macro. Hopefully I have handled various combinations of fcntl commands being defined / not defined correctly too, so the user never gets a compilation error just because __fcntl_cmd_needs_arg () wants to handle some command that is not defined in their configuration. When building fcntl{,64}_2.c, all the commands (that are supported on this kernel, i.e. not Linux specifics on the Hurd) should be defined, and so the runtime calls to __fcntl_cmd_needs_arg () get this full version. When building user code, some commands may not be defined (depending on enabled feature macros), but then the expectation is the user cannot use those commands they do not have enabled. Sergey