On Tue, 31 Mar 2015, François Armand wrote:
> Better send my real stuff, than making misleading typos :-)
>
> My code:
> #define MAX_RETRIES 3
>
> tmy_status
> my_getattr_timeout(tmy_ctx *ctx,
> u64 ino)
> {
> tmy_status ret;
> int tries = 0;
> int delay = 1;
>
> retry:
> ret = my_getattr(ctx, ino);
> if (MY_SUCCESS != ret)
> {
> if (MY_ENOENT != ret &&
> MY_EPERM != ret)
> {
> if (tries < MAX_RETRIES)
> {
> HANDLE_TIMEOUT(tries, delay, "ino %llu", ino);
> goto retry;
> }
> else
> {
> MY_TRACE(MY_ERROR, 0u, "getattr: ino %llu"": I/O error", ino);
> return MY_FAILURE;
> }
> }
> }
> return ret;
> }
>
> A working patch
> @@
> expression t;
> constant M;
> @@
> if (
> - t < M
> + foo(&ctx->retry_ctx)
> )
> {
> ...
> } else {
> ...
> }
>
> A patch I can't make to work. That last one exists w/o producing anything
>
> @@
> expression t;
> constant M;
> @@
> if (...)
> {
> if (...)
> {
> if (
> - t < M
> + foo(&ctx->retry_ctx)
> )
> {
> ...
> } else {
> ...
> }
> }
> }
It seems to work fine for me:
@@ -15,7 +15,7 @@ my_getattr_timeout(tmy_ctx *ctx,
if (MY_ENOENT != ret &&
MY_EPERM != ret)
{
- if (tries < MAX_RETRIES)
+ if (foo(&ctx->retry_ctx))
{
HANDLE_TIMEOUT(tries, delay, "ino %llu", ino);
goto retry;
What version of Coccinelle do you have?
julia_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci