Fix some style problems in audio
cover Fix some style problems in audio
Some style problems in audio directory are found by checkpatch.pl. Fix these style problems.
Zhang Han (6):
audio: Add braces for statements/fix braces' position
audio: Add spaces around operator/delete redundant spaces
audio: foo* bar" should be "foo *bar".
audio: Fix lines over 90 characters
audio: Don't use '#' flag of printf format ('%#') in format strings
audio: Suspect code indent for conditional statements
audio/alsaaudio.c | 15 +++++-------- audio/audio.c | 26 ++++++++++------------ audio/audio_template.h | 14 +++++------- audio/coreaudio.c | 17 +++++++------- audio/dsoundaudio.c | 50 +++++++++++++++++++++++++++--------------- audio/jackaudio.c | 2 +- audio/ossaudio.c | 12 ++++------ audio/paaudio.c | 2 +- 8 files changed, 68 insertions(+), 70 deletions(-)
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH 1/6 audio: Add braces for statements/fix braces' position
Fix problems about braces:
-braces are necessary for all arms of if/for/while statements -else should follow close brace '}'
--- audio/alsaaudio.c | 15 +++++---------- audio/audio.c | 26 ++++++++++++-------------- audio/audio_template.h | 12 ++++-------- audio/coreaudio.c | 3 +-- audio/dsoundaudio.c | 9 +++------ audio/ossaudio.c | 12 ++++-------- 6 files changed, 29 insertions(+), 48 deletions(-)
audio/alsaaudio.c +5 -10
@@ -278,32 +278,28 @@ static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt, int endianness)case AUDIO_FORMAT_S16 :if (endianness) {return SND_PCM_FORMAT_S16_BE ; - } -else { + }else {return SND_PCM_FORMAT_S16_LE ; }case AUDIO_FORMAT_U16 :if (endianness) {return SND_PCM_FORMAT_U16_BE ; - } -else { + }else {return SND_PCM_FORMAT_U16_LE ; }case AUDIO_FORMAT_S32 :if (endianness) {return SND_PCM_FORMAT_S32_BE ; - } -else { + }else {return SND_PCM_FORMAT_S32_LE ; }case AUDIO_FORMAT_U32 :if (endianness) {return SND_PCM_FORMAT_U32_BE ; - } -else { + }else {return SND_PCM_FORMAT_U32_LE ; }
@@ -722,8 +718,7 @@ static int alsa_voice_ctl (snd_pcm_t *handle, const char *typ, int ctl)alsa_logerr (err,"Could not stop %s\n" , typ);return -1 ; } - } -else { + }else { err =snd_pcm_prepare (handle);if (err <0 ) {alsa_logerr (err,"Could not prepare handle for %s\n" , typ);
audio/audio.c +12 -14
@@ -344,8 +344,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len)if (info->is_signed || info->is_float) {memset (buf,0x00 , len * info->bytes_per_frame); - } -else { + }else {switch (info->bits) {case 8 :memset (buf,0x80 , len * info->bytes_per_frame);
@@ -584,8 +583,7 @@ static size_t audio_pcm_sw_get_rpos_in(SWVoiceIn *sw) rpos = hw->conv_buf->pos - live;if (rpos >=0 ) {return rpos; - } -else { + }else {return hw->conv_buf->size + rpos; } }
@@ -788,10 +786,14 @@ static int audio_is_timer_needed(AudioState *s)HWVoiceOut *hwo =NULL ;while ((hwo =audio_pcm_hw_find_any_enabled_out (s, hwo))) { -if (!hwo->poll_mode)return 1 ; +if (!hwo->poll_mode) { +return 1 ; + } }while ((hwi =audio_pcm_hw_find_any_enabled_in (s, hwi))) { -if (!hwi->poll_mode)return 1 ; +if (!hwi->poll_mode) { +return 1 ; + } }return 0 ; }
@@ -908,8 +910,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on)audio_reset_timer (s); } } - } -else { + }else {if (hw->enabled) {int nb_active =0 ;
@@ -956,8 +957,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) } } sw->total_hw_samples_acquired = hw->total_samples_captured; - } -else { + }else {if (hw->enabled) {int nb_active =0 ;
@@ -1540,8 +1540,7 @@ static int audio_driver_init(AudioState *s, struct audio_driver *drv,audio_init_nb_voices_in (s, drv); s->drv = drv;return 0 ; - } -else { + }else {if (msg) {dolog ("Could not init `%s' audio driver\n" , drv->name); }
@@ -1856,8 +1855,7 @@ CaptureVoiceOut *AUD_add_capture(if (cap) {QLIST_INSERT_HEAD (&cap->cb_head, cb, entries);return cap; - } -else { + }else {HWVoiceOut *hw;CaptureVoiceOut *cap;
audio/audio_template.h +4 -8
@@ -47,8 +47,7 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioState *s,#ifdef DAC dolog ("Driver `%s' does not support " NAME "\n" , drv->name);#endif - } -else { + }else { dolog ("Driver `%s' does not support %d " NAME " voices, max %d\n", drv->name, glue (s->nb_hw_voices_, TYPE),
@@ -387,8 +386,7 @@ static SW *glue(audio_pcm_create_voice_pair_, TYPE)(if (pdo->fixed_settings) { hw_as =audiodev_to_audsettings (pdo); - } -else { + }else { hw_as = *as; }
@@ -498,8 +496,7 @@ SW *glue (AUD_open_, TYPE) (if (glue (audio_pcm_sw_init_,TYPE ) (sw, hw, name, as)) { goto fail; } - } -else { + }else { sw =glue (audio_pcm_create_voice_pair_,TYPE )(s, name, as);if (!sw) {dolog ("Failed to create voice `%s'\n" , name);
@@ -553,8 +550,7 @@ uint64_t glue (AUD_get_elapsed_usec_, TYPE) (SW *sw, QEMUAudioTimeStamp *ts)if (cur_ts >= old_ts) { delta = cur_ts - old_ts; - } -else { + }else { delta =UINT64_MAX - old_ts + cur_ts; }
audio/coreaudio.c +1 -2
@@ -524,8 +524,7 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as, }else if (frameRange.mMaximum < frames) { core->audioDevicePropertyBufferFrameSize = (UInt32 ) frameRange.mMaximum;dolog ("warning: Downsizing Buffer Frames to %f\n" , frameRange.mMaximum); - } -else { + }else { core->audioDevicePropertyBufferFrameSize = frames; }
audio/dsoundaudio.c +3 -6
@@ -404,8 +404,7 @@ static void dsound_enable_out(HWVoiceOut *hw, bool enable)dsound_logerr (hr,"Could not stop playing buffer\n" );return ; } - } -else { + }else {dolog ("warning: Voice is not playing\n" ); } }
@@ -509,8 +508,7 @@ static void dsound_enable_in(HWVoiceIn *hw, bool enable)dsound_logerr (hr,"Could not stop capturing\n" );return ; } - } -else { + }else {dolog ("warning: Voice is not capturing\n" ); } }
@@ -659,8 +657,7 @@ static void *dsound_audio_init(Audiodev *dev) );if (FAILED (hr)) {dsound_logerr (hr,"Could not create DirectSoundCapture instance\n" ); - } -else { + }else { hr =IDirectSoundCapture_Initialize (s->dsound_capture,NULL );if (FAILED (hr)) {dsound_logerr (hr,"Could not initialize DirectSoundCapture\n" );
audio/ossaudio.c +4 -8
@@ -142,16 +142,14 @@ static int aud_to_ossfmt (AudioFormat fmt, int endianness)case AUDIO_FORMAT_S16 :if (endianness) {return AFMT_S16_BE ; - } -else { + }else {return AFMT_S16_LE ; }case AUDIO_FORMAT_U16 :if (endianness) {return AFMT_U16_BE ; - } -else { + }else {return AFMT_U16_LE ; }
@@ -542,16 +540,14 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,int trig =0 ;if (ioctl (fd,SNDCTL_DSP_SETTRIGGER , &trig) <0 ) {oss_logerr (errno,"SNDCTL_DSP_SETTRIGGER 0 failed\n" ); - } -else { + }else { trig =PCM_ENABLE_OUTPUT ;if (ioctl (fd,SNDCTL_DSP_SETTRIGGER , &trig) <0 ) {oss_logerr ( errno,"SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n" ); - } -else { + }else { oss->mmapped =1 ; } }
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH 2/6 audio: Add spaces around operator/delete redundant spaces
In reply to Zhang HanFix problems about spaces:
-operator needs spaces around it, add them.
-somespaces are redundant, remove them.
--- audio/audio_template.h | 2 +- audio/coreaudio.c | 2 +- audio/dsoundaudio.c | 2 +- audio/jackaudio.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
audio/audio_template.h +1 -1
@@ -208,7 +208,7 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)QLIST_REMOVE (hw, entries);glue (hw->pcm_ops->fini_,TYPE ) (hw);glue (s->nb_hw_voices_,TYPE ) +=1 ; -glue (audio_pcm_hw_free_resources_ ,TYPE ) (hw); +glue (audio_pcm_hw_free_resources_ ,TYPE ) (hw);g_free (hw); *hwp =NULL ; }
audio/coreaudio.c +1 -1
@@ -270,7 +270,7 @@ static void coreaudio_logstatus (OSStatus status) {const char *str ="BUG" ; -switch (status) { +switch (status) {case kAudioHardwareNoError: str ="kAudioHardwareNoError" ;break ;
audio/dsoundaudio.c +1 -1
@@ -133,7 +133,7 @@ static void dsound_log_hresult (HRESULT hr)break ;#endif #ifdef DSERR_GENERIC -case DSERR_GENERIC : +case DSERR_GENERIC : str ="An undetermined error occurred inside the DirectSound subsystem" ;break ;#endif
audio/jackaudio.c +1 -1
@@ -277,7 +277,7 @@ static int qjack_process(jack_nframes_t nframes, void *arg)if (likely (c->enabled)) {qjack_buffer_read_l (&c->fifo, buffers, nframes); }else { -for (int i =0 ; i < c->nchannels; ++i) { +for (int i =0 ; i < c->nchannels; ++i) {memset (buffers[i],0 , nframes *sizeof (float )); } }
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH 3/6 audio: foo* bar" should be "foo *bar".
In reply to Zhang HanTransfer "foo* " to "foo *"
--- audio/coreaudio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
audio/coreaudio.c +6 -6
@@ -421,12 +421,12 @@ COREAUDIO_WRAPPER_FUNC(write, size_t, (HWVoiceOut *hw, void *buf, size_t size),/* callback to feed audiooutput buffer */ static OSStatus audioDeviceIOProc (AudioDeviceID inDevice, -const AudioTimeStamp * inNow, -const AudioBufferList * inInputData, -const AudioTimeStamp * inInputTime, -AudioBufferList * outOutputData, -const AudioTimeStamp * inOutputTime, -void * hwptr) +const AudioTimeStamp *inNow, +const AudioBufferList *inInputData, +const AudioTimeStamp *inInputTime, +AudioBufferList *outOutputData, +const AudioTimeStamp *inOutputTime, +void *hwptr) {UInt32 frameCount, pending_frames;void *out = outOutputData->mBuffers[0 ].mData;
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH 4/6 audio: Fix lines over 90 characters
In reply to Zhang HanFix the line width of code.
--- audio/dsoundaudio.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
audio/dsoundaudio.c +27 -10
@@ -89,7 +89,9 @@ static void dsound_log_hresult (HRESULT hr)#endif #ifdef DSERR_ALLOCATED case DSERR_ALLOCATED : - str ="The request failed because resources, such as a priority level, were already in use by another caller" ; + str ="The request failed because resources, " +"such as a priority level, were already in use " +"by another caller" ;break ;#endif #ifdef DSERR_ALREADYINITIALIZED
@@ -104,7 +106,8 @@ static void dsound_log_hresult (HRESULT hr)#endif #ifdef DSERR_BADSENDBUFFERGUID case DSERR_BADSENDBUFFERGUID : - str ="The GUID specified in an audiopath file does not match a valid mix-in buffer" ; + str ="The GUID specified in an audiopath file " +"does not match a valid mix-in buffer" ;break ;#endif #ifdef DSERR_BUFFERLOST
@@ -114,22 +117,31 @@ static void dsound_log_hresult (HRESULT hr)#endif #ifdef DSERR_BUFFERTOOSMALL case DSERR_BUFFERTOOSMALL : - str ="The buffer size is not great enough to enable effects processing" ; + str ="The buffer size is not great enough to " +"enable effects processing" ;break ;#endif #ifdef DSERR_CONTROLUNAVAIL case DSERR_CONTROLUNAVAIL : - str ="The buffer control (volume, pan, and so on) requested by the caller is not available. Controls must be specified when the buffer is created, using the dwFlags member of DSBUFFERDESC" ; + str ="The buffer control (volume, pan, and so on) " +"requested by the caller is not available. " +"Controls must be specified when the buffer is created, " +"using the dwFlags member of DSBUFFERDESC" ;break ;#endif #ifdef DSERR_DS8_REQUIRED case DSERR_DS8_REQUIRED : - str ="A DirectSound object of class CLSID_DirectSound8 or later is required for the requested functionality. For more information, see IDirectSound8 Interface" ; + str ="A DirectSound object of class CLSID_DirectSound8 or later " +"is required for the requested functionality. " +"For more information, see IDirectSound8 Interface" ;break ;#endif #ifdef DSERR_FXUNAVAILABLE case DSERR_FXUNAVAILABLE : - str ="The effects requested could not be found on the system, or they are in the wrong order or in the wrong location; for example, an effect expected in hardware was found in software" ; + str ="The effects requested could not be found on the system, " +"or they are in the wrong order or in the wrong location; " +"for example, an effect expected in hardware " +"was found in software" ;break ;#endif #ifdef DSERR_GENERIC
@@ -154,7 +166,8 @@ static void dsound_log_hresult (HRESULT hr)#endif #ifdef DSERR_NODRIVER case DSERR_NODRIVER : - str ="No sound driver is available for use, or the given GUID is not a valid DirectSound device ID" ; + str ="No sound driver is available for use, " +"or the given GUID is not a valid DirectSound device ID" ;break ;#endif #ifdef DSERR_NOINTERFACE
@@ -169,12 +182,14 @@ static void dsound_log_hresult (HRESULT hr)#endif #ifdef DSERR_OTHERAPPHASPRIO case DSERR_OTHERAPPHASPRIO : - str ="Another application has a higher priority level, preventing this call from succeeding" ; + str ="Another application has a higher priority level, " +"preventing this call from succeeding" ;break ;#endif #ifdef DSERR_OUTOFMEMORY case DSERR_OUTOFMEMORY : - str ="The DirectSound subsystem could not allocate sufficient memory to complete the caller's request" ; + str ="The DirectSound subsystem could not allocate " +"sufficient memory to complete the caller's request" ;break ;#endif #ifdef DSERR_PRIOLEVELNEEDED
@@ -189,7 +204,9 @@ static void dsound_log_hresult (HRESULT hr)#endif #ifdef DSERR_UNINITIALIZED case DSERR_UNINITIALIZED : - str ="The Initialize method has not been called or has not been called successfully before other methods were called" ; + str ="The Initialize method has not been called " +"or has not been called successfully " +"before other methods were called" ;break ;#endif #ifdef DSERR_UNSUPPORTED
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH 5/6 audio: Don't use '#' flag of printf format ('%#') in
In reply to Zhang HanUse '0x' prefix instead of '%#'
--- audio/dsoundaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
audio/dsoundaudio.c +1 -1
@@ -215,7 +215,7 @@ static void dsound_log_hresult (HRESULT hr)break ;#endif default : -AUD_log (AUDIO_CAP ,"Reason: Unknown (HRESULT %#lx)\n" , hr); +AUD_log (AUDIO_CAP ,"Reason: Unknown (HRESULT 0x%lx)\n" , hr);return ; }
Signature · 1 line
2.29.1.59.gf9b6481aed
PATCH 6/6 audio: Suspect code indent for conditional statements
In reply to Zhang HanFix code indent.
--- audio/paaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
audio/paaudio.c +1 -1
@@ -437,7 +437,7 @@ static pa_stream *qpa_simple_new ( }if (r <0 ) { - goto fail; + goto fail; }pa_threaded_mainloop_unlock (c->mainloop);
Signature · 1 line
2.29.1.59.gf9b6481aed
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PATCH 0/6] Fix some style problems in audio
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
8f35a92 audio: Suspect code indent for conditional statements 8ed0853 audio: Don't use '#' flag of printf format ('%#') in 51cd1e7 audio: Fix lines over 90 characters
5d8549c audio: foo* bar" should be "foo *bar".
d1ff82c audio: Add spaces around operator/delete redundant spaces fd15fe2 audio: Add braces for statements/fix braces' position
=== OUTPUT BEGIN ===
1/6 Checking commit fd15fe2d8c7c (audio: Add braces for statements/fix braces' position) 2/6 Checking commit d1ff82c2665a (audio: Add spaces around operator/delete redundant spaces)
ERROR: space prohibited between function name and open parenthesis '('
#23: FILE: audio/audio_template.h:211:
+ glue (audio_pcm_hw_free_resources_ , TYPE) (hw);
total: 1 errors, 0 warnings, 32 lines checked
Patch 2/6 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/6 Checking commit 5d8549cdb6b4 (audio: foo* bar" should be "foo *bar".) 4/6 Checking commit 51cd1e738a1c (audio: Fix lines over 90 characters)
5/6 Checking commit 8ed08536993d (audio: Don't use '#' flag of printf format ('%#') in) 6/6 Checking commit 8f35a92e6aa6 (audio: Suspect code indent for conditional statements) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]