[Libreoffice] Question about sal/qa/osl/process/osl_Thread.cxx

Norbert Thiebaud nthiebaud at gmail.com
Sat Jun 18 04:12:59 PDT 2011


On Sat, Jun 18, 2011 at 5:39 AM, Julien Nabet <serval2412 at yahoo.fr> wrote:
> Hello,
>
> Last "git version" of cppcheck says this :
> [sal/qa/osl/process/osl_Thread.cxx:1099]: (warning) Redundant assignment of
> "sPrioStr" in switch
> Here is the switch :
>                switch (_aPriority)
>                {
>                case osl_Thread_PriorityHighest:
>                    sPrioStr = "Highest";
>                    break;
>
>                case osl_Thread_PriorityAboveNormal:
>                    sPrioStr = "AboveNormal";
>
>                case osl_Thread_PriorityNormal:
>                    sPrioStr = "Normal";
>
>                case osl_Thread_PriorityBelowNormal:
>                    sPrioStr = "BelowNormal";
>                    break;
>
>                case osl_Thread_PriorityLowest:
>                    sPrioStr = "Lowest";
>                    break;
>                default:
>                    sPrioStr = "unknown";
>                }
>
> Do the break instructions lack for "AboveNormal" and "Normal" cases ?
> If no, it could be better to have this :
>                // we want to have the same treatment for these 3 cases
>                case osl_Thread_PriorityAboveNormal:
>                case osl_Thread_PriorityNormal:
>                case osl_Thread_PriorityBelowNormal:
>                    sPrioStr = "BelowNormal";
>                    break;
>
> Somebody to answer this ?

* It looks like this has been like that since day-1 (i.e for as long
as we have history for it.
* That function seems to be only used for display purpose at only place only.
* It looks like there should be break after each case and no
fall-through. I don't see the reason why one would want to obfuscate
the true value of priority in a trace message.

Norbert


>
> Julien.
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice
>


More information about the LibreOffice mailing list