void *calloc(size_t nelem, size_t elsize); Why the test for calloc limit is passing pointer difference limit as an argument? The limit is defined as SIZE_MAX in C99 standard. #include #include #include #include #include void main(){ void * a = calloc(SIZE_MAX, 1); printf("a: %p, errno: %d, strerror: %s\n", a, errno, strerror(errno)); } $ uname -a SunOS ST-ul-cbe 5.11 11.4.75.178.0 i86pc i386 i86pc virtualbox $ ./a.out a: 0, errno: 12, strerror: Cannot allocate memory $ uname -a SunOS S11-3-SRU 5.11 11.3 i86pc i386 i86pc $ ./a.out a: 0, errno: 12, strerror: Not enough space $ ggrep -r ENOMEM /usr/include/sys/errno.h #define ENOMEM 12 /* Not enough core */ --- a2ps-4.15.8/m4/malloc.m4.~1~ +++ a2ps-4.15.8/m4/malloc.m4 @@ -187,44 +187,6 @@ [gl_cv_func_malloc_posix="guessing yes"], [gl_cv_func_malloc_posix="guessing no"]) ;; - solaris*) - dnl On Solaris 11.3, the three functions return NULL with errno set - dnl to EAGAIN, not ENOMEM, when the argument is larger than - dnl PTRDIFF_MAX. - dnl Here is a test program: -m4_divert_push([KILL]) -#include -#include -#include -#define ptrdiff_t long -#ifndef PTRDIFF_MAX -# define PTRDIFF_MAX ((ptrdiff_t) ((1UL << (8 * sizeof (ptrdiff_t) - 1)) - 1)) -#endif - -int main () -{ - void *p; - - fprintf (stderr, "PTRDIFF_MAX = %lu\n", (unsigned long) PTRDIFF_MAX); - - errno = 0; - p = malloc ((unsigned long) PTRDIFF_MAX + 1); - fprintf (stderr, "p=%p errno=%d\n", p, errno); - - errno = 0; - p = calloc (PTRDIFF_MAX / 2 + 1, 2); - fprintf (stderr, "p=%p errno=%d\n", p, errno); - - errno = 0; - p = realloc (NULL, (unsigned long) PTRDIFF_MAX + 1); - fprintf (stderr, "p=%p errno=%d\n", p, errno); - - return 0; -} -m4_divert_pop([KILL]) - gl_cv_func_malloc_posix=no ;; - *) - gl_cv_func_malloc_posix=yes ;; esac ]) ]) This is a fix for: 38408752 Fix a2ps-lpr-wrapper to properly detect /usr/bin/lp --- a/src/a2ps-lpr-wrapper +++ b/src/a2ps-lpr-wrapper @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # # a2ps-lpr-wrapper - lp/lpr wrapper script for GNU a2ps