这个C语言是什么(if(1))?

我在openssl源代码中注意到一个奇怪的成语,here并重复如下:
if ((in == NULL) && (passwds == NULL)) {
        if (1) {                                    (* <---- HERE *)
#ifndef OPENSSL_NO_UI
            /* build a null-terminated list */
            static char *passwds_static[2] = { NULL,NULL };

            passwds = passwds_static;
            if (in == NULL)
                if (EVP_read_pw_string
                    (passwd_malloc,passwd_malloc_size,"Password: ",!(passed_salt || in_noverify)) != 0)
                    goto end;
            passwds[0] = passwd_malloc;
        } else {
#endif
            BIO_printf(bio_err,"password required\n");
            goto end;
        }
}

看来这段代码相当于:

if ((in == NULL) && (passwds == NULL)) {
#ifndef OPENSSL_NO_UI
        /* build a null-terminated list */
        static char *passwds_static[2] = { NULL,NULL };

        passwds = passwds_static;
        if (in == NULL)
            if (EVP_read_pw_string
                (passwd_malloc,!(passed_salt || in_noverify)) != 0)
                goto end;
        passwds[0] = passwd_malloc;
#else
        BIO_printf(bio_err,"password required\n");
        goto end;
#endif
}

我排除了一些解释:

>它可能是为passwds_static引入块范围,但是如果将为类似的目的提供封闭的范围
>它可能是一个通过几个有意义的变换变得没有意义的结构,但那个结构就是since the introduction of OPENSSL_NO_UI.

在这里遗漏了什么吗? (1)有什么好处?这是否用于其他代码库?

谢谢!

解决方法

看了其他类似的地方,I found an explanation
if (1) { /* This is a trick we use to avoid bit rot.
          * at least the "else" part will always be
          * compiled.
          */
#ifdef AF_INET6
    family = AF_INET6;
} else {
#endif
    BIOerr(BIO_F_ACPT_STATE,BIO_R_UNAVAILABLE_IP_FAMILY);
    goto exit_loop;
}

在大多数情况下(包括其CI我猜),OPENSSL_NO_UI没有定义,所以两个分支都被编译.如果其中一个分支机构使用了更改,那么它将被编译器发现,它可以被修复,而无需测试所有的编译时交换机.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...