por
pobrecito hablador
el Martes, 01 Abril de 2008, 15:35h
(#1030571)
On Sun, 2003-01-12 at 14:15, Linus Torvalds wrote: > if (spin_trylock(&tty_lock.lock)) > goto got_lock; > if (tsk == tty_lock.lock_owner) { > WARN_ON(!tty_lock.lock_count); > tty_lock.lock_count++; > return flags; > } > spin_lock(&tty_lock.lock); > got_lock: > WARN_ON(tty_lock.lock_owner);
La respuesta: if (!(spin_trylock(&tty_lock.lock))) { if (tsk ==tty_lock.lock_owner) { WRAN_ON(!tty_lock.lcok_count); tty_lock.lock_count++; return flags; } } WARN_ON(tty_lock.lock_owner);
Se puede escribir sin anidar IF: if (!spin_trylock(&tty_lock.lock) && tsk == tty_lock.lock_owner) { WRAN_ON(!tty_lock.lcok_count); tty_lock.lock_count++; return flags; } WARN_ON(tty_lock.lock_owner);
Sí, y si hubieras leído la respuesta completa hubieras visto que ya dice que también se podría escribir así. Pero da igual, porque como ya te han dicho, eso está mal.
10 PRINT "I WILL NEVER EVER USE GOTO AGAIN" 20 GOTO 10
Re:¿Ha salido?
(Puntos:0)> if (spin_trylock(&tty_lock.lock))
> goto got_lock;
> if (tsk == tty_lock.lock_owner) {
> WARN_ON(!tty_lock.lock_count);
> tty_lock.lock_count++;
> return flags;
> }
> spin_lock(&tty_lock.lock);
> got_lock:
> WARN_ON(tty_lock.lock_owner);
La respuesta:
if (!(spin_trylock(&tty_lock.lock))) {
if (tsk ==tty_lock.lock_owner) {
WRAN_ON(!tty_lock.lcok_count);
tty_lock.lock_count++;
return flags;
}
}
WARN_ON(tty_lock.lock_owner);
Se puede escribir sin anidar IF:
if (!spin_trylock(&tty_lock.lock) && tsk == tty_lock.lock_owner) {
WRAN_ON(!tty_lock.lcok_count);
tty_lock.lock_count++;
return flags;
}
WARN_ON(tty_lock.lock_owner);
Bye
Re:¿Ha salido?
(Puntos:2)( http://www.flawedcode.org/ )
10 PRINT "I WILL NEVER EVER USE GOTO AGAIN"
20 GOTO 10
Unix have fun [barrapunto.com]