[Webkit-unassigned] [Bug 234306] Simplify accesses to SystemVersion.plist

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jan 24 10:01:37 PST 2022


https://bugs.webkit.org/show_bug.cgi?id=234306

Darin Adler <darin at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |darin at apple.com

--- Comment #4 from Darin Adler <darin at apple.com> ---
Comment on attachment 447149
  --> https://bugs.webkit.org/attachment.cgi?id=447149
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=447149&action=review

> Source/WebCore/platform/cocoa/SystemVersion.mm:27
>  #import "SystemVersion.h"
> +#import <pal/spi/cf/CFUtilitiesSPI.h>

WebKit coding style says there should be a blank line after the file’s own header before the other includes.

> Source/WebCore/platform/cocoa/SystemVersion.mm:35
> +    CFStringRef productVersion = static_cast<CFStringRef>(CFDictionaryGetValue(systemVersionDictionary.get(), _kCFSystemVersionProductVersionKey));

Typically in newly-written WebKit code we would use auto for the type rather than repeating the same type in both on the left and in the static_cast, and either checked_cf_cast or dynamic_cf_cast instead of static_cast.

> Source/WebCore/platform/cocoa/SystemVersion.mm:36
> +    return adoptNS([(__bridge NSString *)productVersion copy]);

WebKit has bridge_cast for this:

    return adoptNS([bridge_cast(productVersion) copy]);

> Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:793
> +    NSDictionary *plist = adoptCF(_CFCopySystemVersionDictionary()).bridgingAutorelease();

We’d like to avoid introducing any autorelease, and there’s no need for it here, we can have a RetainPtr local variable.

    auto plistCF = adoptCF(_CFCopySystemVersionDictionary());
    auto plist = bridge_cast(plistCF.get());

> Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:799
> +    result.targetBuildVersion = plist[static_cast<NSString *>(_kCFSystemVersionBuildVersionKey)];
> +    result.targetProductVersion = plist[static_cast<NSString *>(_kCFSystemVersionProductUserVisibleVersionKey)];

bridge_cast(_kCFSystemVersionBuildVersionKey)
bridge_cast(_kCFSystemVersionProductUserVisibleVersionKey)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220124/331f539f/attachment-0001.htm>


More information about the webkit-unassigned mailing list