返回资讯中心
外部精选
软件工程
#开发者实时流

Yet another place where a Linux man page is inaccurate

, but it's still a documented incompatibility with a standard: in glibc, initstate doesn't return NULL on error, despite posix requiring that it does:

Hacker News 最新birdculture2026/10/15 · 22 天前2 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

, but it's still a documented incompatibility with a standard: in glibc, initstate doesn't return NULL on error, despite posix requiring that it does:

// EINVAL: state array less than 8 bytes char *state = initstate(67, (char [1]){}, 1); assert(errno == EINVAL); // ok assert(state == NULL); // fails, despite posix requiring it to succeed

the man page initstate(3) very unhelpfully first describes the posix behavior in the RETURN VALUE section, as though it's the actual behavior:

The initstate() function returns a pointer to the previous state array. On failure, it returns NULL, and errno is set to indicate the error.

only at the very bottom in the BUGS section does it say that glibc behaves differently:

According to POSIX, initstate() should return NULL on error. In the glibc implementation, errno is (as specified) set on error, but the function does not return NULL.

however, i just got an email:

Hi, I read

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →