• [^] # Re: Le cas goto

    Posté par (Mastodon) . En réponse au journal Apple, le SSL les goto et les accolades. Évalué à 2.

    Pour reprendre l'exemple de CrEv :

    try {
     // bla bla bla
     if (/* comportement pas glop */) {
     throw;
     }
     // bla bla
    } catch {
     // traitement des cas en erreur
     return k_fail;
    }

    Et pour reprendre l'exemple du journal :

    static OSStatus SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams, uint8_t *signature, UInt16 signatureLen) {
    OSStatus err;
    // ...
    try {
     if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0) {
     throw;
     }
     if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) {
     throw;
     }
     if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0) {
     throw;
     }
    } catch {
    }
    SSLFreeBuffer(&signedHashes);
    SSLFreeBuffer(&hashCtx);
    return err;
    }