Earlier quoted context omitted.
I still prefer this: if( b != nil && b->qid.type == a->qid.type && b->qid.path == a->qid.path && b->qid.vers == a->qid.vers && b->dev == a->dev && b->type == a->type ) { fprint(2, "cp: %s and %s are the same file\n", an, bn); ret = 1; }
We can go deeper... if( b != nil && b->qid.type == a->qid.type && b->qid.path == a->qid.path && b->qid.vers == a->qid.vers && b->dev == a->dev && b->type == a->type ) { fprint(2, "cp: %s and %s are the same file\n", an, bn); ret = 1; } (Lined up the "a"s to make it obvious that they're all the same.)
int samedirfile( Dir *a, Dir *b )
{
if( a == b )
return 1;
return ( a && b ) &&
( a->qid.type == b->qid.type ) &&
( a->qid.path == b->qid.path ) &&
( a->qid.vers == b->qid.vers ) &&
( a->dev == b->dev ) &&
( a->type == b->type );
}
...
if( samedirfile( a, b ) ) {
fprint(2, "cp: %s and %s are the same file\n", an, bn);
ret = 1;
}