Path: csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Casting the return value of ... Date: Mon, 08 Apr 2024 23:01:17 -0700 Organization: A noiseless patient Spider Lines: 51 Message-ID: <86frvv2hxu.fsf@linuxsc.com> References: <20240328105203.773@kylheku.com> <86le5zipzo.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 09 Apr 2024 06:01:20 +0200 (CEST) Injection-Info: dont-email.me; posting-host="47558c70f7e061adbec47d824d7ff660"; logging-data="71395"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19h4afvaD42RTj4pNrKBKtItdl7oGAyGfg=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:athRc7eP2bk52rtmpq2o95Lgpis= sha1:XI1sochqFkBtZc2y/Fsn4TlzqP8= Xref: csiph.com comp.lang.c:384222 scott@slp53.sl.home (Scott Lurndal) writes: > Tim Rentsch writes: > >> scott@slp53.sl.home (Scott Lurndal) writes: >> >>> Kaz Kylheku <433-929-6894@kylheku.com> writes: >>> >>>> On 2024-03-28, Kenny McCormack wrote: >>> >>> * Each shared object that simulates a Data Link Processor (DLP), >>> * will contain a single namespace-scope function get_dlp >>> * which constructs a DLP object of the specified type (for example, >>> * a #c_uniline_dlp, #c_card_reader_dlp, et alia). get_dlp >>> * returns the constructed object as a #c_dlp object to the #channel >>> * function, which is then used by the I/O subsystem to request >>> * services of the DLP at the MLI level. >>> */ >>> typedef c_dlp* (*get_dlp_t)(const char *, uint64_t, c_logger *); >>> ... >>> get_dlp_t sym; >>> ... >>> >>> sym = (get_dlp_t)dlsym(handle, "get_dlp"); >>> if (sym == NULL) { >>> lp->log("Invalid DLP shared object format: %s\n", dlerror()); >>> unregister_handle(channel); >>> dlclose(handle); >>> return 1; >>> } >>> >>> >>>> I think there was a time in the development of GCC when there was >>>> a warning even with the cast. I don't think it's enabled by default >>>> now? >>> >>> We compile with -Wall -Werror and have never seen any warnings related >>> to casting the result of dlsym(), and we build with GCC[4..13]. >> >> Do you use -pedantic? Compiling with -pedantic using gcc 8.4.0 >> gives a warning diagnostic (and a fatal error if -pedantic-errors >> is specified in place of -pedantic). > > Of course not. We write production code not standard C (or in this > case, C++) code. Portability to compilers other than gcc is > not a requirement for the several million line codebase. It's quite amusing to hear of a team that insists on -Wall but avoids -pedantic, saving a tiny drizzle of cases (all of which are easy to remedy) while enduring the ever-changing force 5 blizzard of conditions tested by -Wall.