在以下代码段中被认为是最佳做法:
int foo(struct data *bar, struct info bla) {
if (!bar) {
bla->status = 0;
return;
}
...
}
Run Code Online (Sandbox Code Playgroud)
事实上,它工作正常.但是在gcc给我一个警告时我感到很不舒服.
这是实际的代码:
static int pop(struct stack **stack, struct info *info) {
int ret;
struct stack *tmp;
if (!*stack) {
info->error = 0;
return;
}
ret = (*stack)->data;
tmp = *stack;
*stack = (*stack)->next;
free(tmp);
return ret;
}
Run Code Online (Sandbox Code Playgroud)