Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%d printf specifier for key_t fails if the type is actually long (which is allowed by POSIX) #500

Closed
gdt opened this issue Dec 4, 2023 · 0 comments

Comments

@gdt
Copy link

gdt commented Dec 4, 2023

Compiling 5.1.23 under NetBSD/amd64, I got a printf format error because %d was used to print key_t, which was of type long. POSIX requires only that it be an arithmetic type, and long certainly is within reason. I think it's reasonable to assume it is an integral type. One option is to cast to long and use %ld, but I (in adding a patch to pkgsrc) chose to cast to intmax_t.

--- apc_shm.c.orig      2023-12-04 01:27:07.199895899 +0000
+++ apc_shm.c
@@ -53,7 +53,7 @@ int apc_shm_create(int proj, size_t size
 
        oflag = IPC_CREAT | SHM_R | SHM_A;
        if ((shmid = shmget(key, size, oflag)) < 0) {
-               zend_error_noreturn(E_CORE_ERROR, "apc_shm_create: shmget(%d, %zd, %d) failed: %s. It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of 32MB per segment.", key, size, oflag, strerror(errno));
+               zend_error_noreturn(E_CORE_ERROR, "apc_shm_create: shmget(%jd, %zd, %d) failed: %s. It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of
 32MB per segment.", (intmax_t) key, size, oflag, strerror(errno));
        }
 
        return shmid;
@nikic nikic closed this as completed in 0797ccc Dec 9, 2023
KitanoTom pushed a commit to link-u/apcu that referenced this issue Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant