[haiku-commits] Re: r40809 - haiku/trunk/src/kits/tracker

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 05 Mar 2011 00:09:42 +0100

On 2011-03-04 at 19:42:48 [+0100], jonas@xxxxxxxxxxx wrote:
> Author: kirilla
> Date: 2011-03-04 19:42:48 +0100 (Fri, 04 Mar 2011)
> New Revision: 40809
> Changeset: http://dev.haiku-os.org/changeset/40809
> 
> Modified:
>    haiku/trunk/src/kits/tracker/Utilities.cpp
> Log:
> Style fixes. Thanks, Axel!
> 
> Modified: haiku/trunk/src/kits/tracker/Utilities.cpp
> ===================================================================
> --- haiku/trunk/src/kits/tracker/Utilities.cpp    2011-03-04 18:04:10 UTC 
> (rev 40808)
> +++ haiku/trunk/src/kits/tracker/Utilities.cpp    2011-03-04 18:42:48 UTC 
> (rev 40809)
> @@ -1470,9 +1470,7 @@
>  }
>  
>  
> -/*!    \fn status_t GetLocalizedFileName(entry_ref& ref,
> -        BString& localizedFileName, bool traverse)
> -    \brief Looks up a localized filename in a catalog, using attribute data
> +/*!    \brief Looks up a localized filename in a catalog, using attribute 
> data
>          on the entry.
>      \param ref An entry_ref with an attribute holding data for catalog 
>      lookup.
>      \param localizedFileName A pre-allocated BString object for the result
> @@ -1521,14 +1519,14 @@
>  
>      char* signature = attribute;
>      char* context = strchr(signature, ':');
> -    if (context) {
> +    if (context != NULL) {
>          context[0] = '\0';
>          context++;
>      } else
>          return B_ENTRY_NOT_FOUND;

At the risk of being annoying: For sake of better readability I'd recommend 
the "immediate bail out on error" style, i.e. check for error (rather than 
success) and return an error immediately. So the main control flow can 
continue on the topmost level.

        if (context == NULL)
                return B_ENTRY_NOT_FOUND;

        context[0] = '\0';
        context++;
        ...

CU, Ingo

Other related posts: