Tarsnap / tarsnap

Command-line client code for Tarsnap.
https://tarsnap.com
Other
864 stars 60 forks source link

Misc #582

Closed gperciva closed 11 months ago

gperciva commented 11 months ago

Rebased, updated commit message.

Since the commit messages are primarily for us, I went with more detail than you proposed. If the question came up again, I didn't want to be digging through github discussions to find that info.

If you really don't like it, I'll prune it down to what you wrote last night.

New commit message:

Some compilers object to using a function pointer which can point to functions which have different const qualifiers, i.e.

ssize_t send(int s, const void *msg, size_t len, int flags);
ssize_t recv(int s, void *buf, size_t len, int flags);

This is allowed:

(In the determination of type compatibility and of a composite type,
each parameter declared with function or array type is taken as
having the adjusted type and each parameter declared with qualified
type is taken as having the unqualified version of its declared
type.)

- C99, 6.7.5.3 para 15

but that's a somewhat esoteric detail.

Also, using a flag might generate better code than indirecting via a function pointer.

Reported by: clang-16

EDIT: "pointer to qualified T" is not compatible with "pointer to T", which is the issue with "void msg" v "const void msg".

gperciva commented 11 months ago

I received an email pointing out flaws in my previous commit message.

Rebased the PR. There's now a rather vague commit message:

Using a flag will probably generate better code than indirecting via a function pointer, and some compilers object to using a function pointer to refer to both:

ssize_t send(int s, const void *msg, size_t len, int flags);
ssize_t recv(int s, void *buf, size_t len, int flags);