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

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

概述我在openssl源代码中注意到一个奇怪的成语, here并重复如下: if ((in == NULL) && (passwds == NULL)) { if (1) { (* <---- HERE *)#ifndef OPENSSL_NO_UI /* build a null-term 我在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语言是什么(if(1))?全部内容,希望文章能够帮你解决这个C语言是什么(if(1))?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1255439.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存