Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-11 Thread Konstantin Tokarev
11.05.2017, 11:18, "Osztrogonác Csaba" : > Hi, > > On 2017.05.11. 0:32, Andy Estes wrote: >>>  On May 10, 2017, at 3:17 PM, Michael Catanzaro >>> wrote: >>> >>>  On Tue, May 9, 2017 at 2:57 PM, Ryosuke Niwa wrote:  One

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-11 Thread Osztrogonác Csaba
Hi, On 2017.05.11. 0:32, Andy Estes wrote: On May 10, 2017, at 3:17 PM, Michael Catanzaro wrote: On Tue, May 9, 2017 at 2:57 PM, Ryosuke Niwa wrote: One annoying thing is that I've seen clang complaining about that return statement being an

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-10 Thread Andy Estes
> On May 10, 2017, at 3:17 PM, Michael Catanzaro wrote: > > On Tue, May 9, 2017 at 2:57 PM, Ryosuke Niwa wrote: >> One annoying thing is that I've seen clang complaining about that >> return statement being an unreachable statement while gcc doesn't

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-10 Thread Michael Catanzaro
On Tue, May 9, 2017 at 2:57 PM, Ryosuke Niwa wrote: One annoying thing is that I've seen clang complaining about that return statement being an unreachable statement while gcc doesn't :(. So we probably shouldn't have return statement, not to mention that 0 may not be a valid

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-09 Thread Ryosuke Niwa
On Tue, May 9, 2017 at 12:11 PM, Maciej Stachowiak wrote: > > >> On May 9, 2017, at 11:35 AM, Michael Catanzaro wrote: >> >> On Tue, May 9, 2017 at 1:13 PM, Maciej Stachowiak wrote: >>> I think this second option may suppress the warning

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-09 Thread Alex Christensen
I like switch statements without defaults when possible because if someone adds another enum value, it causes compiler warnings/errors and forces us to update all necessary code. ___ webkit-dev mailing list webkit-dev@lists.webkit.org

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-09 Thread Maciej Stachowiak
> On May 9, 2017, at 12:05 PM, Alfonso Guerra wrote: > > > > On May 9, 2017 2:07 PM, "Michael Catanzaro" > wrote: > Hi, > > Consider this function: > >        static WKAutoplayEvent

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-09 Thread Maciej Stachowiak
> On May 9, 2017, at 11:35 AM, Michael Catanzaro wrote: > > On Tue, May 9, 2017 at 1:13 PM, Maciej Stachowiak wrote: >> I think this second option may suppress the warning when you have forgotten >> to list one of the enum values, since there is now a

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-09 Thread Alfonso Guerra
On May 9, 2017 2:07 PM, "Michael Catanzaro" wrote: Hi, Consider this function: static WKAutoplayEvent toWKAutoplayEvent(WebCore::AutoplayEvent event) { switch (event) { case WebCore::AutoplayEvent::DidEndMediaPlaybackWithoutUserInterf

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-09 Thread Andy Estes
> On May 9, 2017, at 11:35 AM, Michael Catanzaro wrote: > > Andy suggests returning one of the enumeration values directly, then we can > use ASSERT_NOT_REACHED() instead of RELEASE_ASSERT_NOT_REACHED(). That would > work too, though it forces me to think about which

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-09 Thread Andy Estes
> On May 9, 2017, at 11:06 AM, Michael Catanzaro wrote: > > https://bugs.webkit.org/show_bug.cgi?id=171851 > suggests this approach: > > static WKAutoplayEvent toWKAutoplayEvent(WebCore::AutoplayEvent event) >

Re: [webkit-dev] Idiom for functions with all return values in a switch case

2017-05-09 Thread Maciej Stachowiak
> On May 9, 2017, at 11:06 AM, Michael Catanzaro wrote: > > Hi, > > Consider this function: > > static WKAutoplayEvent toWKAutoplayEvent(WebCore::AutoplayEvent event) > { > switch (event) { > case >

[webkit-dev] Idiom for functions with all return values in a switch case

2017-05-09 Thread Michael Catanzaro
Hi, Consider this function: static WKAutoplayEvent toWKAutoplayEvent(WebCore::AutoplayEvent event) { switch (event) { case WebCore::AutoplayEvent::DidEndMediaPlaybackWithoutUserInterference: return