extra argument 'error' in call

本文探讨了从Swift 1.0升级到Swift 2.0过程中出现的错误处理变化,特别是调用多余参数所导致的问题,并提供了一个具体的案例及解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误原因:调用了多余的参数。(下面是导致这种错误的一种)

在swift1.0到swift2.0 转化的过程中,对于错误的异常处理出现了较大的变动,所以在使用的时候经常会出现这种错误。我在网上找了个这样的例子(包含解决方法)

转载于:https://www.cnblogs.com/yaoyao0110/p/5499760.html

make[6]: Entering directory '/home/wuyilun/Desktop/NVMP/NVMP/nvmp/build_dir/host/e2fsprogs-1.42.4/lib/quota' CC mkquota.c In file included from mkquota.c:22: mkquota.c: In function 'quota_write_inode': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:133:3: note: in expansion of macro 'log_err' 133 | log_err("Unable to allocate quota handle", ""); | ^~~~~~~ common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:149:4: note: in expansion of macro 'log_err' 149 | log_err("Cannot initialize io on quotafile", ""); | ^~~~~~~ mkquota.c: In function 'quota_init_context': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:219:3: note: in expansion of macro 'log_err' 219 | log_err("Failed to allocate quota context", ""); | ^~~~~~~ common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:229:4: note: in expansion of macro 'log_err' 229 | log_err("Failed to allocate dictionary", ""); | ^~~~~~~ mkquota.c: In function 'get_dq': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:274:4: note: in expansion of macro 'log_err' 274 | log_err("Unable to allocate dquot", ""); | ^~~~~~~ mkquota.c: In function 'scan_dquots_callback': common.h:17:5: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 7 has type 'qsize_t' {aka 'long int'} [-Wformat=] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:421:3: note: in expansion of macro 'log_err' 421 | log_err("Usage inconsistent for ID %d: (%llu, %llu) != " | ^~~~~~~ mkquota.c:421:46: note: format string is defined here 421 | log_err("Usage inconsistent for ID %d: (%llu, %llu) != " | ~~~^ | | | long long unsigned int | %lu In file included from mkquota.c:22: common.h:17:5: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 8 has type 'qsize_t' {aka 'long int'} [-Wformat=] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:421:3: note: in expansion of macro 'log_err' 421 | log_err("Usage inconsistent for ID %d: (%llu, %llu) != " | ^~~~~~~ mkquota.c:421:52: note: format string is defined here 421 | log_err("Usage inconsistent for ID %d: (%llu, %llu) != " | ~~~^ | | | long long unsigned int | %lu In file included from mkquota.c:22: common.h:17:5: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 9 has type 'qsize_t' {aka 'long int'} [-Wformat=] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:421:3: note: in expansion of macro 'log_err' 421 | log_err("Usage inconsistent for ID %d: (%llu, %llu) != " | ^~~~~~~ mkquota.c:422:9: note: format string is defined here 422 | "(%llu, %llu)", dq->dq_id, dq->dq_dqb.dqb_curspace, | ~~~^ | | | long long unsigned int | %lu In file included from mkquota.c:22: common.h:17:5: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 10 has type 'qsize_t' {aka 'long int'} [-Wformat=] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:421:3: note: in expansion of macro 'log_err' 421 | log_err("Usage inconsistent for ID %d: (%llu, %llu) != " | ^~~~~~~ mkquota.c:422:15: note: format string is defined here 422 | "(%llu, %llu)", dq->dq_id, dq->dq_dqb.dqb_curspace, | ~~~^ | | | long long unsigned int | %lu In file included from mkquota.c:22: mkquota.c: In function 'quota_update_inode': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:488:3: note: in expansion of macro 'log_err' 488 | log_err("Unable to allocate quota handle", ""); | ^~~~~~~ common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:494:3: note: in expansion of macro 'log_err' 494 | log_err("Open quota file failed", ""); | ^~~~~~~ mkquota.c: In function 'quota_compare_and_update': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:534:3: note: in expansion of macro 'log_err' 534 | log_err("Open quota file failed", ""); | ^~~~~~~ common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ mkquota.c:544:3: note: in expansion of macro 'log_err' 544 | log_err("Error scanning dquots", ""); | ^~~~~~~ CC quotaio.c In file included from quotaio.c:21: quotaio.h:19: warning: "MAXQUOTAS" redefined 19 | #define MAXQUOTAS 2 | In file included from /usr/include/x86_64-linux-gnu/sys/quota.h:57, from quotaio.c:18: /usr/include/linux/quota.h:40: note: this is the location of the previous definition 40 | #define MAXQUOTAS 3 | In file included from quotaio.c:20: quotaio.c: In function 'quota_file_open': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio.c:245:3: note: in expansion of macro 'log_err' 245 | log_err("qh_ops->check_file failed", ""); | ^~~~~~~ common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio.c:251:3: note: in expansion of macro 'log_err' 251 | log_err("qh_ops->init_io failed", ""); | ^~~~~~~ quotaio.c: In function 'quota_inode_init_new': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio.c:266:3: note: in expansion of macro 'log_err' 266 | log_err("ex2fs_read_inode failed", ""); | ^~~~~~~ quotaio.c: In function 'quota_file_create': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio.c:318:3: note: in expansion of macro 'log_err' 318 | log_err("init_new_quota_inode failed", ""); | ^~~~~~~ common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio.c:341:3: note: in expansion of macro 'log_err' 341 | log_err("qh_ops->new_io failed", ""); | ^~~~~~~ quotaio.c: In function 'get_empty_dquot': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio.c:388:3: note: in expansion of macro 'log_err' 388 | log_err("Failed to allocate dquot", ""); | ^~~~~~~ CC quotaio_v2.c In file included from quotaio_v2.c:15: quotaio_v2.c: In function 'v2_check_file': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio_v2.c:163:4: note: in expansion of macro 'log_err' 163 | log_err("Your quota file is stored in wrong " | ^~~~~~~ quotaio_v2.c: In function 'v2_report': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio_v2.c:282:2: note: in expansion of macro 'log_err' 282 | log_err("Not Implemented.", ""); | ^~~~~~~ CC quotaio_tree.c In file included from quotaio_tree.c:15: quotaio_tree.c: In function 'getdqbuf': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio_tree.c:27:3: note: in expansion of macro 'log_err' 27 | log_err("Failed to allocate dqbuf", ""); | ^~~~~~~ quotaio_tree.c: In function 'get_free_dqblk': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio_tree.c:103:4: note: in expansion of macro 'log_err' 103 | log_err("Cannot allocate new quota block " | ^~~~~~~ quotaio_tree.c: In function 'find_free_dqentry': common.h:17:5: warning: too many arguments for format [-Wformat-extra-args] 17 | "[ERROR] %s:%d:%s:: " format "\n", \ | ^~~~~~~~~~~~~~~~~~~~~ quotaio_tree.c:233:3: note: in expansion of macro 'log_err' 233 | log_err("find_free_dqentry(): Data block full but it " | ^~~~~~~ CC ../../e2fsck/dict.c GEN_LIB libquota.a CONFIG.STATUS quota.pc
最新发布
08-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值