登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
登录
注册
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
16
Star
0
Fork
35
src-openEuler
/
cups
代码
Issues
1
Pull Requests
5
Wiki
统计
流水线
服务
JavaDoc
PHPDoc
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
我知道了,不再自动展开
169
Fix clang build incompatible integer to pointer conversion error
开启的
存在冲突
严莹:yy-master
src-openEuler:master
严莹
创建于 2024-10-17 12:13
克隆/下载
HTTPS
SSH
复制
下载 Email Patch
下载 Diff 文件
- 本PR基于[这个oEEP](https://gitee.com/openeuler/TC/blob/master/oEEP/oEEP-0003%20LLVM%E5%B9%B3%E8%A1%8C%E5%AE%87%E5%AE%99%E8%AE%A1%E5%88%92--%E5%9F%BA%E4%BA%8ELLVM%E6%8A%80%E6%9C%AF%E6%A0%88%E6%9E%84%E5%BB%BAoE%E8%BD%AF%E4%BB%B6%E5%8C%85.md),旨在使得该软件包可以同时支持GCC和LLVM构建。 - 原pr:[Fix clang build incompatible integer to pointer conversion error · Pull Request !158 · src-openEuler/cups - Gitee.com](https://gitee.com/src-openeuler/cups/pulls/158) 该pr提出时仓库中代码版本仍为2.4.7,但由于版本升级后目前仍然会出现clang构建不成功的情况故需要进行修改。 ### 报错信息 修改前 clang 构建在 `testhttp.c` 出现报错: ``` testhttp.c:395:32: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *' [-Wint-conversion] 395 | addrlist = httpAddrGetList(gethostname(localhostname, sizeof(localhostname)), AF_UNSPEC, NULL); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../cups/http.h:526:53: note: passing argument to parameter 'hostname' here 526 | extern http_addrlist_t *httpAddrGetList(const char *hostname, int family, const char *service) _CUPS_API_1_2; | ^ 1 error generated. ``` ### 修复过程 - 该报错由openEuler中间仓的Patch: `fix-httpAddrGetList-test-case-fail.patch` 引入。`-Wint-conversion`在clang中默认为error,而在gcc中为warning,故当使用gcc构建时,不会报上述错误。该Patch对应PR为:[fix build error · Pull Request !103](https://gitee.com/src-openeuler/cups/pulls/103)。上游社区中报错这行代码至今仍未改变,为: ```c addrlist = httpAddrGetList(hostname, AF_UNSPEC, NULL); ``` 若将该Patch删除可以用clang构建成功,但目前版本(v2.4.7)中仍能复现[fix build error · Pull Request !103](https://gitee.com/src-openeuler/cups/pulls/103)中的构建失败问题,故选择在`fix-httpAddrGetList-test-case-fail.patch`的基础上修改,使得修改后使用clang也能构建成功。 - 错误信息表明试图将一个整数(`int`)类型的值传递给需要字符指针(`const char *`)类型的参数的函数。`gethostname`函数的参数和返回值要求如下: ```c int gethostname(char *name, size_t len); ``` `httpAddrGetList`需要的参数则是: ```c extern http_addrlist_t *httpAddrGetList(const char *hostname, int family, const char *service) _CUPS_PUBLIC; ``` `gethostname` 函数会将当前主机的名字复制到不超过 `len` 字节的`name` 指向的缓冲区中,如果 `len` 足够大,能够容纳完整的主机名以及末尾的空字符终止符,那么 `name` 缓冲区中的字符串将以空字符终止。返回的int值代表是否成功。 - 修改建议:按照原本的含义来说,传入`httpAddrGetList`的应该是`hostname`而非`gethostname`的返回值。因此应当将代码改为 ```c gethostname(localhostname, sizeof(localhostname)); addrlist = httpAddrGetList(localhostname, AF_UNSPEC, NULL); ```
此 Pull Request 无法自动合并
尝试通过 WebIDE 解决冲突
怎样手动合并此 Pull Request
git checkout master
git pull https://gitee.com/yanyir/cups_2.git yy-master
git push origin master
评论
11
提交
1
文件
2
检查
代码问题
0
批量操作
展开设置
折叠设置
审查
Code Owner
审查人员
douyan
dou33
small_leek
small_leek
t.feng
t_feng
Randy.Wang
wangxp006
wenlongd
dwl301
yanan-rock
yanan-rock
open-bot
open-bot
Lostway
Lostwayzxc
technology208
technology208
wei dong
weidongkl
未设置
最少人数
0
测试
douyan
dou33
small_leek
small_leek
t.feng
t_feng
Randy.Wang
wangxp006
wenlongd
dwl301
yanan-rock
yanan-rock
open-bot
open-bot
Lostway
Lostwayzxc
technology208
technology208
wei dong
weidongkl
未设置
最少人数
0
优先级
不指定
严重
主要
次要
不重要
标签
openeuler-cla/yes
ci_successful
sig/Desktop
关联 Issue
未关联
Pull Request 合并后将关闭上述关联 Issue
里程碑
未关联里程碑
合并选项
合并后删除提交分支
提交分支为默认分支,无法删除
合并后关闭提到的 Issue
接受 Pull Request 时使用扁平化(Squash)合并
勾选此选项后,将建议使用 Squash Merge 方式合并以精简提交历史记录
参与者
(4)
1
https://gitee.com/src-openeuler/cups.git
git@gitee.com:src-openeuler/cups.git
src-openeuler
cups
cups
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册