Skip to contentSkip to conversation

Darwin CoreAudio warning fixes

PATCH Superseded Andreas Färber 3 participants 11 messages Jun 23, 2011 – Jun 29, 2011

lore
Share & tools
lore
#0 lore raw

cover Darwin CoreAudio warning fixes

Hello,

These patches fix two format related warnings noticed on Darwin/ppc64 host (LP64). They will probably affect Darwin/x86_64, too.

Three warnings remain: 1x CoreAudioAddIOProc, 2x CoreAudioRemoveIOProc being deprecated.

Regards,
Andreas

Andreas Färber (2):
coreaudio: Fix OSStatus format specifier
coreaudio: Fix format for UInt32 type

 audio/coreaudio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.5.3
#1 lore raw

PATCH 1/2 coreaudio: Fix OSStatus format specifier

OSStatus type is defined as SInt32.
Use %d format instead of %ld to avoid a warning on ppc64.

---
Alexandre, Could you please test this on v10.6? Thanks!

 audio/coreaudio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
audio/coreaudio.c +1 -1
index 3bd75cd..d2b9248 100644
@@ -104,7 +104,7 @@ static void coreaudio_logstatus (OSStatus status)
         break;
 
     default:
-        AUD_log (AUDIO_CAP, "Reason: status code %ld\n", status);
+        AUD_log (AUDIO_CAP, "Reason: status code %d\n", status);
         return;
     }
 
Signature · 1 line
1.7.5.3
#2 lore raw

PATCH 2/2 coreaudio: Fix format for UInt32 type

coreaudioVoiceOut's audioDevicePropertyBufferFrameSize is defined as UInt32. Use %u instead of %ld to avoid a warning on ppc64.

---
 audio/coreaudio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
audio/coreaudio.c +1 -1
index d2b9248..69a0f05 100644
@@ -360,7 +360,7 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)
         &core->audioDevicePropertyBufferFrameSize);
     if (status != kAudioHardwareNoError) {
         coreaudio_logerr2 (status, typ,
-                           "Could not set device buffer frame size %ld\n",
+                           "Could not set device buffer frame size %u\n",
                            core->audioDevicePropertyBufferFrameSize);
         return -1;
     }
Signature · 1 line
1.7.5.3
#10 lore raw
In reply to Andreas Färber

Am 23.06.2011 um 13:43 schrieb Andreas Färber:

Quoted 6 lines

Hello,

These patches fix two format related warnings noticed on Darwin/ppc64 host (LP64). They will probably affect Darwin/x86_64, too.

Three warnings remain: 1x CoreAudioAddIOProc, 2x CoreAudioRemoveIOProc being deprecated.

Erm, AudioDevice{Add,Remove}IOProc.

Quoted 13 lines

Regards,
Andreas

Andreas Färber (2):
coreaudio: Fix OSStatus format specifier
coreaudio: Fix format for UInt32 type

audio/coreaudio.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.5.3
#3 lore raw

Re: [Qemu-devel] [PATCH RFT 1/2] coreaudio: Fix OSStatus format specifier

In reply to Andreas Färber
Quoted 2 lines · Andreas F?rber

OSStatus type is defined as SInt32.
Use %d format instead of %ld to avoid a warning on ppc64.

Which itself is defined as

typedef signed long SInt32;

(here on ppc32 inside:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/libkern/OSTypes.h)

So i'd suggest to just cast the thing to appropriate long type and be done with it.

Quoted 24 lines

---
Alexandre, Could you please test this on v10.6? Thanks!

 audio/coreaudio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
audio/coreaudio.c +1 -1
index 3bd75cd..d2b9248 100644
@@ -104,7 +104,7 @@ static void coreaudio_logstatus (OSStatus status)
         break;
 
     default:
-        AUD_log (AUDIO_CAP, "Reason: status code %ld\n", status);
+        AUD_log (AUDIO_CAP, "Reason: status code %d\n", status);
         return;
     }
 
Signature · 1 line
mailto:[email protected]
#5 lore raw

PATCH 2/2 coreaudio: Avoid formatting UInt32 type

In reply to Andreas Färber

coreaudioVoiceOut's audioDevicePropertyBufferFrameSize is defined as UInt32 and is being used by reference for AudioDevice{Get,Set}Property(). UInt32 is unsigned int on __LP64__ but unsigned long otherwise.

Cast to POSIX type and use PRIu32 format specifier to hide the details. This avoids a warning on ppc64.

---
 audio/coreaudio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
audio/coreaudio.c +2 -2
index 508bcbe..5964c62 100644
@@ -360,8 +360,8 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)
         &core->audioDevicePropertyBufferFrameSize);
     if (status != kAudioHardwareNoError) {
         coreaudio_logerr2 (status, typ,
-                           "Could not set device buffer frame size %ld\n",
-                           core->audioDevicePropertyBufferFrameSize);
+                           "Could not set device buffer frame size %" PRIu32 "\n",
+                           (uint32_t)core->audioDevicePropertyBufferFrameSize);
         return -1;
     }
 
Signature · 1 line
1.7.5.3
#4 lore raw

PATCH v2 1/2 coreaudio: Fix OSStatus format specifier

In reply to malc

OSStatus type is defined as SInt32. That's signed int on __LP64__ and signed long otherwise.
Since it is an explicit 32-bit-width type, cast to corresponsing POSIX type and use PRId32 format specifier. This avoids a warning on ppc64.

---
 audio/coreaudio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
audio/coreaudio.c +1 -1
index 3bd75cd..508bcbe 100644
@@ -104,7 +104,7 @@ static void coreaudio_logstatus (OSStatus status)
         break;
 
     default:
-        AUD_log (AUDIO_CAP, "Reason: status code %ld\n", status);
+        AUD_log (AUDIO_CAP, "Reason: status code %" PRId32 "\n", (int32_t)status);
         return;
     }
 
Signature · 1 line
1.7.5.3
#9 lore raw

Re: [Qemu-devel] [PATCH RFT 1/2] coreaudio: Fix OSStatus format specifier

In reply to malc

Am 23.06.2011 um 14:54 schrieb malc:

Quoted 11 lines · Andreas F?rber
Quoted 3 lines

OSStatus type is defined as SInt32.
Use %d format instead of %ld to avoid a warning on ppc64.

Which itself is defined as

typedef signed long SInt32;

(here on ppc32 inside:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/libkern/OSTypes.h)

Thanks for the pointer! Here it's:

#if __LP64__
typedef signed int SInt32;
#else
typedef signed long SInt32;
#endif

Quoted 2 lines

So i'd suggest to just cast the thing to appropriate long type and be done with it.

I posted a different solution to avoid unnecessary 64-bit width on ppc64/x86_64.

Andreas

#6 lore raw

Re: [Qemu-devel] [PATCH 2/2] coreaudio: Avoid formatting UInt32 type

In reply to Andreas Färber

$subject missing v2

Am 23.06.2011 um 16:24 schrieb Andreas Färber:

Quoted 36 lines

coreaudioVoiceOut's audioDevicePropertyBufferFrameSize is defined as UInt32 and is being used by reference for AudioDevice{Get,Set}Property(). UInt32 is unsigned int on __LP64__ but unsigned long otherwise.

Cast to POSIX type and use PRIu32 format specifier to hide the details. This avoids a warning on ppc64.

---
audio/coreaudio.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
audio/coreaudio.c +2 -2
index 508bcbe..5964c62 100644
@@ -360,8 +360,8 @@ static int coreaudio_init_out (HWVoiceOut *hw,  
 struct audsettings *as)
        &core->audioDevicePropertyBufferFrameSize);
    if (status != kAudioHardwareNoError) {
        coreaudio_logerr2 (status, typ,
-                           "Could not set device buffer frame size  
 %ld\n",
-                           core->audioDevicePropertyBufferFrameSize);
+                           "Could not set device buffer frame size  
 %" PRIu32 "\n",
+                           (uint32_t)core- 
Quoted 1 line

audioDevicePropertyBufferFrameSize);

        return -1;
    }
Signature · 1 line
1.7.5.3
#7 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] coreaudio: Fix OSStatus format specifier

In reply to Andreas Färber
Quoted 5 lines · Andreas F?rber

OSStatus type is defined as SInt32. That's signed int on __LP64__ and signed long otherwise.
Since it is an explicit 32-bit-width type, cast to corresponsing POSIX type and use PRId32 format specifier. This avoids a warning on ppc64.

[..snip..]

Applied thanks (ditto UInt32 patch).

Signature · 1 line
mailto:[email protected]
#8 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] coreaudio: Fix OSStatus format specifier

Sorry for the delay.

Commit 744d3644181ddb16ef5944a0f9217e46961c8c84 works fine on OSX 10.6.

Alexandre

Quoted 15 lines · malc
Quoted 5 lines · Andreas F?rber

OSStatus type is defined as SInt32. That's signed int on __LP64__ and signed long otherwise.
Since it is an explicit 32-bit-width type, cast to corresponsing POSIX type and use PRId32 format specifier. This avoids a warning on ppc64.

[..snip..]

Applied thanks (ditto UInt32 patch).

--
mailto:[email protected]