* [RFC PATCH] block/file-posix: Remove a deprecation warning on macOS 12
@ 2022-01-05 23:56 Philippe Mathieu-Daudé
2022-01-14 14:09 ` Hanna Reitz
0 siblings, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-01-05 23:56 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Peter Maydell, qemu-block, Hanna Reitz,
Philippe Mathieu-Daudé, John Arbuckle, Roman Bolshakov,
Joelle van Dyne
When building on macOS 12 we get:
../block/file-posix.c:3335:18: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
^~~~~~~~~~~~
IOMainPort
Use IOMainPort (define it to IOMasterPort on macOS < 12),
and replace 'master' by 'main' in a variable name.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
block/file-posix.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index b283093e5b..0dcfce1856 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -3324,17 +3324,22 @@ BlockDriver bdrv_file = {
#if defined(__APPLE__) && defined(__MACH__)
static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath,
CFIndex maxPathSize, int flags);
+
+#if !defined(MAC_OS_VERSION_12_0)
+#define IOMainPort IOMasterPort
+#endif
+
static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
{
kern_return_t kernResult = KERN_FAILURE;
- mach_port_t masterPort;
+ mach_port_t mainPort;
CFMutableDictionaryRef classesToMatch;
const char *matching_array[] = {kIODVDMediaClass, kIOCDMediaClass};
char *mediaType = NULL;
- kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
+ kernResult = IOMainPort(MACH_PORT_NULL, &mainPort);
if ( KERN_SUCCESS != kernResult ) {
- printf( "IOMasterPort returned %d\n", kernResult );
+ printf("IOMainPort returned %d\n", kernResult);
}
int index;
@@ -3347,7 +3352,7 @@ static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
}
CFDictionarySetValue(classesToMatch, CFSTR(kIOMediaEjectableKey),
kCFBooleanTrue);
- kernResult = IOServiceGetMatchingServices(masterPort, classesToMatch,
+ kernResult = IOServiceGetMatchingServices(mainPort, classesToMatch,
mediaIterator);
if (kernResult != KERN_SUCCESS) {
error_report("Note: IOServiceGetMatchingServices returned %d",
--
2.33.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] block/file-posix: Remove a deprecation warning on macOS 12
2022-01-05 23:56 [RFC PATCH] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé
@ 2022-01-14 14:09 ` Hanna Reitz
2022-01-14 14:15 ` Philippe Mathieu-Daudé via
0 siblings, 1 reply; 4+ messages in thread
From: Hanna Reitz @ 2022-01-14 14:09 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Kevin Wolf, Peter Maydell, qemu-block, John Arbuckle,
Roman Bolshakov, Joelle van Dyne
On 06.01.22 00:56, Philippe Mathieu-Daudé wrote:
> When building on macOS 12 we get:
>
> ../block/file-posix.c:3335:18: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
> kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
> ^~~~~~~~~~~~
> IOMainPort
>
> Use IOMainPort (define it to IOMasterPort on macOS < 12),
> and replace 'master' by 'main' in a variable name.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> block/file-posix.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
I hope the [RFC] tag isn’t directed at me.
Still, I can give my comment, of course.
> diff --git a/block/file-posix.c b/block/file-posix.c
> index b283093e5b..0dcfce1856 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -3324,17 +3324,22 @@ BlockDriver bdrv_file = {
> #if defined(__APPLE__) && defined(__MACH__)
> static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath,
> CFIndex maxPathSize, int flags);
> +
> +#if !defined(MAC_OS_VERSION_12_0)
So AFAIU from my quick rather fruit-less googling, this macro is defined
(to some version-defining integer) on every macOS version starting from
12.0? (Just confirming because the name could also mean it’d be defined
only on 12.0.)
> +#define IOMainPort IOMasterPort
> +#endif
> +
> static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
> {
> kern_return_t kernResult = KERN_FAILURE;
> - mach_port_t masterPort;
> + mach_port_t mainPort;
> CFMutableDictionaryRef classesToMatch;
> const char *matching_array[] = {kIODVDMediaClass, kIOCDMediaClass};
> char *mediaType = NULL;
>
> - kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
> + kernResult = IOMainPort(MACH_PORT_NULL, &mainPort);
> if ( KERN_SUCCESS != kernResult ) {
> - printf( "IOMasterPort returned %d\n", kernResult );
> + printf("IOMainPort returned %d\n", kernResult);
> }
>
> int index;
> @@ -3347,7 +3352,7 @@ static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
> }
> CFDictionarySetValue(classesToMatch, CFSTR(kIOMediaEjectableKey),
> kCFBooleanTrue);
> - kernResult = IOServiceGetMatchingServices(masterPort, classesToMatch,
> + kernResult = IOServiceGetMatchingServices(mainPort, classesToMatch,
> mediaIterator);
> if (kernResult != KERN_SUCCESS) {
> error_report("Note: IOServiceGetMatchingServices returned %d",
“Looks good to me” ← here’s the comment you requested O:)
Hanna
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] block/file-posix: Remove a deprecation warning on macOS 12
2022-01-14 14:09 ` Hanna Reitz
@ 2022-01-14 14:15 ` Philippe Mathieu-Daudé via
2022-01-14 14:27 ` Hanna Reitz
0 siblings, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-01-14 14:15 UTC (permalink / raw)
To: Hanna Reitz, qemu-devel
Cc: Kevin Wolf, Roman Bolshakov, Joelle van Dyne, qemu-block,
John Arbuckle, Peter Maydell
On 14/1/22 15:09, Hanna Reitz wrote:
> On 06.01.22 00:56, Philippe Mathieu-Daudé wrote:
>> When building on macOS 12 we get:
>>
>> ../block/file-posix.c:3335:18: warning: 'IOMasterPort' is
>> deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
>> kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
>> ^~~~~~~~~~~~
>> IOMainPort
>>
>> Use IOMainPort (define it to IOMasterPort on macOS < 12),
>> and replace 'master' by 'main' in a variable name.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> block/file-posix.c | 13 +++++++++----
>> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> I hope the [RFC] tag isn’t directed at me.
>
> Still, I can give my comment, of course.
>
>> diff --git a/block/file-posix.c b/block/file-posix.c
>> index b283093e5b..0dcfce1856 100644
>> --- a/block/file-posix.c
>> +++ b/block/file-posix.c
>> @@ -3324,17 +3324,22 @@ BlockDriver bdrv_file = {
>> #if defined(__APPLE__) && defined(__MACH__)
>> static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char
>> *bsdPath,
>> CFIndex maxPathSize, int flags);
>> +
>> +#if !defined(MAC_OS_VERSION_12_0)
>
> So AFAIU from my quick rather fruit-less googling, this macro is defined
> (to some version-defining integer) on every macOS version starting from
> 12.0? (Just confirming because the name could also mean it’d be defined
> only on 12.0.)
Thanks, I posted up to v3 and macOS users helped me, I will post a v4 soon.
v3:
https://lore.kernel.org/qemu-devel/20220110131001.614319-1-f4bug@amsat.org/
>> +#define IOMainPort IOMasterPort
>> +#endif
>> +
>> static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
>> {
>> kern_return_t kernResult = KERN_FAILURE;
>> - mach_port_t masterPort;
>> + mach_port_t mainPort;
>> CFMutableDictionaryRef classesToMatch;
>> const char *matching_array[] = {kIODVDMediaClass, kIOCDMediaClass};
>> char *mediaType = NULL;
>> - kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
>> + kernResult = IOMainPort(MACH_PORT_NULL, &mainPort);
>> if ( KERN_SUCCESS != kernResult ) {
>> - printf( "IOMasterPort returned %d\n", kernResult );
>> + printf("IOMainPort returned %d\n", kernResult);
>> }
>> int index;
>> @@ -3347,7 +3352,7 @@ static char
>> *FindEjectableOpticalMedia(io_iterator_t *mediaIterator)
>> }
>> CFDictionarySetValue(classesToMatch,
>> CFSTR(kIOMediaEjectableKey),
>> kCFBooleanTrue);
>> - kernResult = IOServiceGetMatchingServices(masterPort,
>> classesToMatch,
>> + kernResult = IOServiceGetMatchingServices(mainPort,
>> classesToMatch,
>> mediaIterator);
>> if (kernResult != KERN_SUCCESS) {
>> error_report("Note: IOServiceGetMatchingServices
>> returned %d",
>
> “Looks good to me” ← here’s the comment you requested O:)
Thanks :)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] block/file-posix: Remove a deprecation warning on macOS 12
2022-01-14 14:15 ` Philippe Mathieu-Daudé via
@ 2022-01-14 14:27 ` Hanna Reitz
0 siblings, 0 replies; 4+ messages in thread
From: Hanna Reitz @ 2022-01-14 14:27 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Kevin Wolf, Peter Maydell, qemu-block, John Arbuckle,
Roman Bolshakov, Joelle van Dyne
On 14.01.22 15:15, Philippe Mathieu-Daudé wrote:
> On 14/1/22 15:09, Hanna Reitz wrote:
>> On 06.01.22 00:56, Philippe Mathieu-Daudé wrote:
>>> When building on macOS 12 we get:
>>>
>>> ../block/file-posix.c:3335:18: warning: 'IOMasterPort' is
>>> deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
>>> kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
>>> ^~~~~~~~~~~~
>>> IOMainPort
>>>
>>> Use IOMainPort (define it to IOMasterPort on macOS < 12),
>>> and replace 'master' by 'main' in a variable name.
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>> ---
>>> block/file-posix.c | 13 +++++++++----
>>> 1 file changed, 9 insertions(+), 4 deletions(-)
>>
>> I hope the [RFC] tag isn’t directed at me.
>>
>> Still, I can give my comment, of course.
>>
>>> diff --git a/block/file-posix.c b/block/file-posix.c
>>> index b283093e5b..0dcfce1856 100644
>>> --- a/block/file-posix.c
>>> +++ b/block/file-posix.c
>>> @@ -3324,17 +3324,22 @@ BlockDriver bdrv_file = {
>>> #if defined(__APPLE__) && defined(__MACH__)
>>> static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char
>>> *bsdPath,
>>> CFIndex maxPathSize, int flags);
>>> +
>>> +#if !defined(MAC_OS_VERSION_12_0)
>>
>> So AFAIU from my quick rather fruit-less googling, this macro is
>> defined (to some version-defining integer) on every macOS version
>> starting from 12.0? (Just confirming because the name could also
>> mean it’d be defined only on 12.0.)
>
> Thanks, I posted up to v3 and macOS users helped me, I will post a v4
> soon.
>
> v3:
> https://lore.kernel.org/qemu-devel/20220110131001.614319-1-f4bug@amsat.org/
I see. The MAC_OS_X_VERSION_M{IN,AX}_REQUIRED thing was exactly what I
didn’t really understand from said googling, but the important thing is
that you do. (Something to do with what runtime is actually in use
rather than what the system can provide? Well, I’ll just stop asking.) O:)
Hanna
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-14 15:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-05 23:56 [RFC PATCH] block/file-posix: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé
2022-01-14 14:09 ` Hanna Reitz
2022-01-14 14:15 ` Philippe Mathieu-Daudé via
2022-01-14 14:27 ` Hanna Reitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).