Message ID | eef4e4802f2b495497117163e61476ec@gmail.com |
---|---|
State | New |
Headers | show |
Michael Witten (12021-08-11): > However, {2} is presented as a bunch of tiny little transformations > that are intended to aid comprehension; they can be squashed into > one commit as the maintainer sees fit (indeed, as shown below, the > squashed diff is already quite comprehensible): This is my my opinion, but better squash related changes: what matters is the final code, how readable it is. Regards,
| Michael Witten: | | > However, {2} is presented as a bunch of tiny little transformations | > that are intended to aid comprehension; they can be squashed into | > one commit as the maintainer sees fit (indeed, as shown below, the | > squashed diff is already quite comprehensible): | | Nicholas George: | | > This is my my opinion, but better squash related changes: what matters | > is the final code, how readable it is. | > | > Regards, | > Nicolas George In my discussion with Lynn, I realized that I was using: for( instead of: for ( If a squash is desired, then it would be easy enough for the committer to to alter the patch that is embedded in the cover-letter, and thereby get both a squash and a fix the missing space. Otherwise, if more changes are necessary, I can make this improvement in a followup series. Sincerely, Michael Witten
Michael Witten (12021-08-20): > This series improves the following function: > > libavformat/protocols.c: avio_enum_protocols() > > There are only 2 commits: > > [1] Quash warning about const-correctness > [2] Refactoring Please do not hijack threads. See the mailing-list FAQ.
Nicolas George (12021-08-20):
> Please do not hijack threads. See the mailing-list FAQ.
Please disregard this, I made a mistake.
Sorry for wasting everybody's time.
diff --git a/libavformat/avio.h b/libavformat/avio.h index 0b35409787..3b92cf742a 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -786,7 +786,7 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); * * @return A static string containing the name of current protocol or NULL */ -const char *avio_enum_protocols(void **opaque, int output); +const char *avio_enum_protocols(void **const opaque, const int output); /** * Get AVClass by names of available protocols. diff --git a/libavformat/protocols.c b/libavformat/protocols.c index e0b3405ab8..4cb8ae0b63 100644 --- a/libavformat/protocols.c +++ b/libavformat/protocols.c @@ -91,19 +91,35 @@ const AVClass *ff_urlcontext_child_class_iterate(void **iter) return ret; } -const char *avio_enum_protocols(void **opaque, int output) +#define AVIO_ENUM_PROTOCOLS(METHOD) \ + typedef const URLProtocol *const *Iterator; \ + for(Iterator p = *opaque ? (Iterator)(*opaque) + 1 : url_protocols; *p; ++p) { \ + if ((*p)->METHOD) { \ + *opaque = (void *)p; \ + return (*p)->name; \ + } \ + } \ + *opaque = NULL; \ + return NULL; + +static inline +const char *avio_enum_protocols_for_output(void **const opaque) { - const URLProtocol *const *p = *opaque; + AVIO_ENUM_PROTOCOLS(url_write); +} - p = p ? p + 1 : url_protocols; - *opaque = (void *)p; - if (!*p) { - *opaque = NULL; - return NULL; - } - if ((output && (*p)->url_write) || (!output && (*p)->url_read)) - return (*p)->name; - return avio_enum_protocols(opaque, output); +static inline +const char *avio_enum_protocols_for_input(void **const opaque) +{ + AVIO_ENUM_PROTOCOLS(url_read); +} + +const char *avio_enum_protocols(void **const opaque, const int output) +{ + if (output) + return avio_enum_protocols_for_output(opaque); + else + return avio_enum_protocols_for_input(opaque); } const AVClass *avio_protocol_get_class(const char *name)