[FFmpeg-devel] [PATCH 1/3] dnn/queue: fix redefining typedefs
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Wed Dec 30 12:03:59 EET 2020
Guo, Yejun:
> Signed-off-by: Guo, Yejun <yejun.guo at intel.com>
> ---
> libavfilter/dnn/queue.c | 8 ++++----
> libavfilter/dnn/safe_queue.c | 4 ++--
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavfilter/dnn/queue.c b/libavfilter/dnn/queue.c
> index 0a07c5473d..da0517968d 100644
> --- a/libavfilter/dnn/queue.c
> +++ b/libavfilter/dnn/queue.c
> @@ -25,17 +25,17 @@
>
> typedef struct _queue_entry queue_entry;
There is no point in using different type names and struct tags; and
both the type name as well as the struct tag do not abide by our naming
conventions: We use CamelCase for them. Remember
9beaf536fe5b52ed5af4d4dd5746277ee5ac9552? The deeper reason for this was
that the typedef name "thread_param" was masked by a variable of the
same name (of type thread_param *) and so sizeof(thread_param) referred
to the variable size (i.e. pointer size). Using sizeof with parentheses
didn't change this. If you had used our naming convention, this would
have never happened.
And both the non-internal type as well as the function names need the
correct prefix.
>
> -typedef struct _queue {
> +struct _queue {
> queue_entry *head;
> queue_entry *tail;
> size_t length;
> -}queue;
> +};
It is more logical to have this definition after the entry's definition.
>
> -typedef struct _queue_entry {
> +struct _queue_entry {
> void *value;
> queue_entry *prev;
> queue_entry *next;
> -} queue_entry;
> +};
>
> static inline queue_entry *create_entry(void *val)
> {
> diff --git a/libavfilter/dnn/safe_queue.c b/libavfilter/dnn/safe_queue.c
> index dba2e0fbbc..4298048454 100644
> --- a/libavfilter/dnn/safe_queue.c
> +++ b/libavfilter/dnn/safe_queue.c
> @@ -25,11 +25,11 @@
> #include "libavutil/avassert.h"
> #include "libavutil/thread.h"
>
> -typedef struct _safe_queue {
> +struct _safe_queue {
> queue *q;
> pthread_mutex_t mutex;
> pthread_cond_t cond;
> -}safe_queue;
> +};
>
> safe_queue *safe_queue_create(void)
> {
>
More information about the ffmpeg-devel
mailing list