From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C12AF470FE for ; Sun, 27 Aug 2023 12:39:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 24C1D68C40B; Sun, 27 Aug 2023 15:39:05 +0300 (EEST) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 149A4680AA3 for ; Sun, 27 Aug 2023 15:38:59 +0300 (EEST) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5007abb15e9so3588443e87.0 for ; Sun, 27 Aug 2023 05:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693139937; x=1693744737; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=FXcCNXEpvHkm4k+lVBGFNlzKOsrnKTSsQguCDXx3THo=; b=CveulhgME8rjEZfj9sHhvwf6K3CFTAXK8mE65yTKJgj+XQwFrgsEWvgf3eOb4xZ/IU 4hCWGZBVgkb3OEYEqPTxPcL0b9pPb2zVAg11z3cs/pshsBtt61mGCnSLKb8XGDy9wVJP o94I9aUFzFJbuw3aXrTFFR3JCb70IfF1EhlzVFyrkRpUeCkSFZs4ZQlUsGDyglS6MBgh 9KvMz3Sohy1N3DtRmbEqlHHUF5q9s1LOg2t3rJqT3M8vvNhTD71mdMcsYkrihMz9yA1E 9ZqnhWDQBWtJnDAkKziIWVYPyCdUYhDXEVoocZU2A9Z5374c1VN8QozgLOQjb2F/Fwx1 J15Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693139937; x=1693744737; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FXcCNXEpvHkm4k+lVBGFNlzKOsrnKTSsQguCDXx3THo=; b=OUAxf1b2N0ZhWjgOo71biapVlbfkn55/cdr7gBPKJLGERQ6TWKggWbNQPjg4bDRZgx N5acDImIDpt+aUaSuQNxeYpKb2ml8erC1F48l+g2x/Yzq8mAYB7tF7ocjbY1S7QVP83p sdHuAoninXPxUVCBgbuuh9g1ZYd/RJlZidN8M3nbk5ib+N8nL0cW5FqKAUuuFbV5U1kt uC0teBzY+OIWUthX8+9IHq6SHjBiwtb9AN122GWRW2kCiCW5KeSg5T5KBmBMhy70tcj9 ysFnYAAELwYMiONNgkkc5eM+5NMw2PQeKmVXmpswThTbwlUT2O9UOn9/sL2+dI1V8p1Y rzWg== X-Gm-Message-State: AOJu0YxbxpdA/DCBk7dqnOwvDRaNpUSmC8oUIYqfOPPolJVAIV304+fJ QcQc0dE4h6UvpKRsIfH63DQJzE0dlADvEMjJMvir57Od X-Google-Smtp-Source: AGHT+IGrqp/MG5ZC/QnydQcTfNO7/ZzRkMbbNPvD4geqS8Hq0c9Ckm5iy8oxnKGkcocAUlKuOakw3zELPYch6e8fL84= X-Received: by 2002:a05:6512:477:b0:4fe:2c6:1d76 with SMTP id x23-20020a056512047700b004fe02c61d76mr14612357lfd.21.1693139936951; Sun, 27 Aug 2023 05:38:56 -0700 (PDT) MIME-Version: 1.0 References: <20230826180748.15977-1-anton@khirnov.net> <20230826180748.15977-4-anton@khirnov.net> In-Reply-To: <20230826180748.15977-4-anton@khirnov.net> From: Stefano Sabatini Date: Sun, 27 Aug 2023 14:38:44 +0200 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH 4/6] doc/developer: add a code behaviour section to development policy X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Il sab 26 ago 2023, 20:08 Anton Khirnov ha scritto: > Document our longstanding de facto policies on things like correctness, > thread-safety, UB, etc. > UB? --- > doc/developer.texi | 50 +++++++++++++++++++++++++++++++++------------- > 1 file changed, 36 insertions(+), 14 deletions(-) > > diff --git a/doc/developer.texi b/doc/developer.texi > index df43119f98..afa0148137 100644 > --- a/doc/developer.texi > +++ b/doc/developer.texi > @@ -274,10 +274,6 @@ symbols. If in doubt, just avoid names starting with > @code{_} altogether. > @section Miscellaneous conventions > > @itemize @bullet > -@item > -fprintf and printf are forbidden in libavformat and libavcodec, > -please use av_log() instead. > - > @item > Casts should be used only when necessary. Unneeded parentheses > should also be avoided if they don't make the code easier to understand. > @@ -286,6 +282,42 @@ should also be avoided if they don't make the code > easier to understand. > @anchor{Development Policy} > @chapter Development Policy > > +@section Code behaviour > + > +@subheading Correctness > +The code must be valid. It must not crash, abort, access invalid > pointers, leak > +memory, cause data races or signed integer overflow, or otherwise invoke > +undefined behaviour. Invoke => assume? Error codes should be checked and, when applicable, > +forwarded to the caller. > + > +@subheading Thread- and library-safety > +Our libraries may be called by multiple independent callers in the same > process. > +These calls may happen from any number of threads and the different call > sites > +may not be aware of each other - e.g. a user program may be calling us > directly, > Calling us -> calling the/our libraries +and use one or more libraries that also call us. The code must behave > correctly > +under such conditions. > + > +@subheading Robustness > +The code must treat as untrusted any bytestream received from a caller or > read > +from a file, network, etc. It must not misbehave when arbitrary data is > sent to > +it - typically it should print an error message and return > +@code{AVERROR_INVALIDDATA} on encountering invalid input data. > + > +@subheading Memory allocation > +The code must use the @code{av_malloc()} family of functions from > +@file{libavutil/mem.h} to perform all memory allocation, except in > special cases > +(e.g. when interacting with an external library that requires a specific > +allocator to be used). > + > +All allocations should be checked and @code{AVERROR(ENOMEM)} returned on > +failure. A common mistake is that error paths leak memory - make sure > that does > +not happen. > + > +@subheading stdio > +Our libraries must not access the stdio streams stdin/stdout/stderr > directly > +(e.g. via @code{printf()} family of functions), as that is not > library-safe. For > +logging, use @code{av_log()}. Lgtm otherwise, thanks. > > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".