[dev] [st patch queue 07/12] Remove unnecessary break;s
--- st.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/st.c b/st.c index 9de7f81..061dafd 100644 --- a/st.c +++ b/st.c @@ -1778,7 +1778,6 @@ tsetmode(bool priv, bool set, int *args, int narg) { for(lim = args + narg; args lim; ++args) { if(priv) { switch(*args) { - break; case 1: /* DECCKM -- Cursor key */ MODBIT(term.mode, set, MODE_APPCURSOR); break; @@ -1897,7 +1896,6 @@ tsetmode(bool priv, bool set, int *args, int narg) { fprintf(stderr, erresc: unknown set/reset mode %d\n, *args); - break; } } } -- 1.8.4
Re: [dev] [st patch queue 07/12] Remove unnecessary break;s
noname wrote: @@ -1897,7 +1896,6 @@ tsetmode(bool priv, bool set, int *args, int narg) { fprintf(stderr, erresc: unknown set/reset mode %d\n, *args); - break; } } } Heyho, although a break statement in the last case is unnecessary, I think it should be left there. If someone appends a new case, he could forget to break this one and get an unwanted fallthrough. The style in st.c is not consistent, there are multiple places without the break in the last case and multiples with it. For a switch(pid = fork()) it is pretty unlikely, that someone legitimately adds a new case other than -1, 0 or default, but it would not harm and help a more consistent style. If we can agree on it, I'll write the patch to add break;s for the last switch-cases, where they are missing. --Markus
Re: [dev] [st patch queue 07/12] Remove unnecessary break;s
although a break statement in the last case is unnecessary, I think it should be left there. If someone appends a new case, he could forget to break this one and get an unwanted fallthrough. The style in st.c is not consistent, there are multiple places without the break in the last case and multiples with it. For a Yeah, usually it is a good idea put the break in the last case to avoid a unwanted fallthrough. Maybe, if you put always default case in the end of the switch, then it is also posible to remove the break in this case, but due to the kind of switch you can find in st, it is impossible ensure you are going to have always a default, so I vote for putting always a break in the last. switch(pid = fork()) it is pretty unlikely, that someone legitimately adds a new case other than -1, 0 or default, but it would not harm and help a more consistent style. If we can agree on it, I'll write the patch to add break;s for the last switch-cases, where they are missing. Yeah, I agree, and I am going to commit the patch of nonamed only with the break in the beginnig of the switch. Regards, -- Roberto E. Vargas Caballero