When I try to compile the piece of code below, I get this warning:
warning: suggest parentheses around assignment used as truth value
Why does this happen? This is a rather common idiom, I believe. I even use something like it earlier on my code.
struct PIDList*
getRecordForPID(struct PIDList* list, pid_t pid) {
while(list = list->next)
if (list->pid == pid)
return list;
return NULL;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…