Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <87v85o4i1v.fsf@nosuchdomain.example.com>
Deutsch   English   Français   Italiano  
<87v85o4i1v.fsf@nosuchdomain.example.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Word For Today: =?utf-8?Q?=E2=80=9CUglification=E2=80=9D?=
Date: Thu, 14 Mar 2024 14:31:08 -0700
Organization: None to speak of
Lines: 97
Message-ID: <87v85o4i1v.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
	<86v85opw22.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="c21b1ebd01dd0ccb23ead5461c6d1b5d";
	logging-data="1963357"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/RKkxCMNi7SRqus7nInI/T"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:ZBAvnyKA4ggq6KMJAMT5aFmvYUE=
	sha1:PrQkLf/vHY/7ZvCKTEzS9adR3JY=
Bytes: 5038

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>
> [some editing of white space done]
>
>> On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>
>>> From /usr/include/<<arch>>/bits/select.h on my Debian system:
>>>
>>>   #define __FD_ZERO(s)                                                  \
>>>     do {                                                                \
>>>       unsigned int __i;                                                 \
>>>       fd_set *__arr = (s);                                              \
>>
>> This assignment has value;  it checks that, loosely speaking,
>> s is an "assignment compatible" pointer with a fd_set *,
>> so that there is a diagnostic if the macro is applied to
>> an object of the wrong type.
>
> More to the point, if the macro is applied to a value of the wrong
> type.
>
>>>       for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i)  \
>>>         __FDS_BITS (__arr)[__i] = 0;                                    \
>>
>> Here, I would have done memset(__arr, 0, sizeof *__arr).
>
> That assumes that it is the entire fd_set that needs to be zeroed,
> which may not be right.  Note the call to the __FDS_BITS() macro.
>
> Better:
>
>   #define __FD_ZERO(s) (                                                  \
>     (void) memset(                                                        \
>       __FDS_BITS( (fd_set*){(s)} ), 0, sizeof __FDS_BITS( (fd_set*){0} )  \
>     )                                                                     \
>   )
>
> This definition:  avoids introducing any new identifiers;  checks
> that the argument s yields an assignment compatible pointer;  and
> provides a macro that can be used as a void expression (unlike the
> original macro definition, which can be used only as a statement).

For context, here's the entire file from my system (Ubuntu 24.0.4,
package libc6-dev:amd64 2.35-0ubuntu3.6).  I get the impression that the
author(s) decided not to use memset to avoid the required #include,
which might increase compilation times for code that indirectly includes
this header.  (I offer no opinion on whether that's a good tradeoff.)

Note that __FD_ZERO is very clearly *not* intended to be invoked by
arbitrary code.

```
/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <https://www.gnu.org/licenses/>.  */

#ifndef _SYS_SELECT_H
# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
#endif


/* We don't use `memset' because this would require a prototype and
   the array isn't too big.  */
#define __FD_ZERO(s) \
  do {									      \
    unsigned int __i;							      \
    fd_set *__arr = (s);						      \
    for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i)	      \
      __FDS_BITS (__arr)[__i] = 0;					      \
  } while (0)
#define __FD_SET(d, s) \
  ((void) (__FDS_BITS (s)[__FD_ELT(d)] |= __FD_MASK(d)))
#define __FD_CLR(d, s) \
  ((void) (__FDS_BITS (s)[__FD_ELT(d)] &= ~__FD_MASK(d)))
#define __FD_ISSET(d, s) \
  ((__FDS_BITS (s)[__FD_ELT (d)] & __FD_MASK (d)) != 0)

```

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */