hyc, (edited )
@hyc@mastodon.social avatar

Gag, puke, retch... This sample code for communicating with is abominable. https://www.freedesktop.org/software/systemd/man/devel/sd_notify.html

From gratuitous use of superfluous language features (a cleanup handler, for a single fd, srsly?) to inappropriate use of standard POSIX APIs (using connect+write on a socket that only sends one message and then gets closed, really?) Older compilers don't even support a cleanup attribute, and this code is used as a model of portability??

's version is better.

bluca,
@bluca@fosstodon.org avatar

@hyc "abominable" -> you somehow managed in 2024 to have a compiler that doesn't provide the cleanup attribute (you should really ask for your money back), and there's a connect+write instead of a sendmsg? Wow, with these kind of standards your code must always be a work of art! <checks Gitlab> Oh. Oh no. Oh dear. Never mind.

hyc,
@hyc@mastodon.social avatar

@bluca If you want to write C++, write C++. A competent C programmer doesn't need that bloat.

I haven't touched gitlab in years.

The only reason we're even looking at this garbage is because libsystemd is a security vulnerability that we had to remove.

bluca,
@bluca@fosstodon.org avatar

@hyc "RAII patterns supported by all compilers that matter and used by the kernel and other major Linux projects are garbage bloat, asckchyually" is exactly the kind of elitist drivel and delusion of grandeur that I was expecting, bravo, bullseye, 9/10

hyc,
@hyc@mastodon.social avatar

@bluca the idiomatic C code is ~10 lines shorter and doesn't require any non-standard compiler features, so yeah, your version is bloated garbage.

hyc,
@hyc@mastodon.social avatar

The code we adopted is cleaner, simpler, more portable, and more efficient. https://git.openldap.org/openldap/openldap/-/merge_requests/703/diffs#diff-content-36a775c78596e0a216eae9bc91be74f644d418a5

systemd, blech.

wednesday,
@wednesday@ni.hil.ist avatar

@hyc

attribute(cleanup)? is this what C developers are coming up with to convince themselves they really don't need C++? :-)

hyc,
@hyc@mastodon.social avatar

@wednesday it's utterly stupid.

wednesday,
@wednesday@ni.hil.ist avatar

@hyc

now that _Generic is in C, i won't be surprised to see _Cleanup in a future version.

(or is it already there? i don't really follow C.)

not to get into a C/C++ debate, but at some point if you're going to 'backport' half of C++ to C, what's the point of using C?

hyc,
@hyc@mastodon.social avatar

@wednesday Yeah it's ridiculous.

Anyway, the sample code is highly non-portable as given on their website. They need to either fix it or document which version of C compiler and which revision of C spec they require.

pid_eins,
@pid_eins@mastodon.social avatar

@hyc @wednesday well, any compiler used on any Linux from the last decade or more supports the cleanup stuff. And that pretty much matches systemd's intended audience.

hyc, (edited )
@hyc@mastodon.social avatar

@pid_eins @wednesday Never mind the fact that using it is totally unnecessary?

Read the code we used https://mastodon.social/@hyc/112451470052965728

There was absolutely no need to write such non-portable code.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines