Replace 'foo == NULL' with '!foo'
PATCH 1/1 Replace 'foo == NULL' with '!foo'
From: Michel Dänzer <[email protected]>
Shorter and sweeter. :)
Signed-off-by Michel Dänzer <[email protected]>
--- src/amdgpu_bo_helper.c | 10 ++++------ src/amdgpu_dri2.c | 10 +++++----- src/amdgpu_glamor.c | 2 +- src/amdgpu_glamor_wrappers.c | 2 +- src/amdgpu_kms.c | 8 ++++---- src/amdgpu_pixmap.c | 2 +- src/amdgpu_pixmap.h | 2 +- src/amdgpu_video.c | 2 +- src/drmmode_display.c | 8 ++++---- 9 files changed, 22 insertions(+), 24 deletions(-)
src/amdgpu_bo_helper.c +4 -6
@@ -252,7 +252,7 @@ int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo)PROT_READ |PROT_WRITE ,MAP_SHARED , fd, args.out.addr_ptr); -if (ptr ==NULL ) { +if (!ptr) {ErrorF ("Failed to mmap the bo\n" );return -1 ; }
@@ -266,7 +266,7 @@ int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo)void amdgpu_bo_unmap (struct amdgpu_buffer *bo) { -if (bo->cpu_ptr ==NULL ) +if (!bo->cpu_ptr)return ;if (bo->flags &AMDGPU_BO_FLAGS_GBM ) {
@@ -289,9 +289,8 @@ struct amdgpu_buffer *amdgpu_bo_open(amdgpu_device_handle pDev,memset (&alloc_request,0 ,sizeof (struct amdgpu_bo_alloc_request )); bo = (struct amdgpu_buffer *)calloc (1 ,sizeof (struct amdgpu_buffer )); -if (bo ==NULL ) { +if (!bo)return NULL ; - } alloc_request.alloc_size = alloc_size; alloc_request.phys_alignment = phys_alignment;
@@ -376,9 +375,8 @@ struct amdgpu_buffer *amdgpu_gem_bo_open_prime(amdgpu_device_handle pDev,struct amdgpu_bo_import_result buffer = {0 }; bo = (struct amdgpu_buffer *)calloc (1 ,sizeof (struct amdgpu_buffer )); -if (bo ==NULL ) { +if (!bo)return NULL ; - }if (amdgpu_bo_import (pDev, amdgpu_bo_handle_type_dma_buf_fd, (uint32_t )fd_handle, &buffer)) {
src/amdgpu_dri2.c +5 -5
@@ -162,7 +162,7 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen, } buffers =calloc (1 ,sizeof *buffers); -if (buffers ==NULL ) +if (!buffers) goto error;if (pixmap) {
@@ -176,7 +176,7 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen, } privates =calloc (1 ,sizeof (struct dri2_buffer_priv )); -if (privates ==NULL ) +if (!privates) goto error; buffers->attachment = attachment;
@@ -830,7 +830,7 @@ static int amdgpu_dri2_get_msc(DrawablePtr draw, CARD64 * ust, CARD64 * msc)xf86CrtcPtr crtc =amdgpu_dri2_drawable_crtc (draw, TRUE);/* Drawable not displayed, make up a value */ -if (crtc ==NULL ) { +if (!crtc) { *ust =0 ; *msc =0 ;return TRUE;
@@ -941,7 +941,7 @@ static int amdgpu_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, remainder &=0xffffffff ;/* Drawable not visible, return immediately */ -if (crtc ==NULL ) +if (!crtc) goto out_complete; msc_delta =amdgpu_get_msc_delta (draw, crtc);
@@ -1101,7 +1101,7 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,amdgpu_dri2_ref_buffer (back);/* either off-screen or CRTC not usable... just complete the swap */ -if (crtc ==NULL ) +if (!crtc) goto blit_fallback; msc_delta =amdgpu_get_msc_delta (draw, crtc);
src/amdgpu_glamor.c +1 -1
@@ -216,7 +216,7 @@ amdgpu_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,int stride; priv =calloc (1 ,sizeof (struct amdgpu_pixmap )); -if (priv ==NULL ) +if (!priv) goto fallback_pixmap; priv->bo = amdgpu_alloc_pixmap_bo(scrn, w, h, depth, usage,
src/amdgpu_glamor_wrappers.c +1 -1
@@ -209,7 +209,7 @@ amdgpu_glamor_picture_prepare_access_cpu_ro(ScrnInfoPtr scrn,PixmapPtr pixmap;struct amdgpu_pixmap *priv; -if (picture->pDrawable ==NULL ) +if (!picture->pDrawable)return TRUE; pixmap =get_drawable_pixmap (picture->pDrawable);
src/amdgpu_kms.c +4 -4
@@ -1511,7 +1511,7 @@ Bool AMDGPUPreInit_KMS(ScrnInfoPtr pScrn, int flags)return FALSE; } - if (pScrn->modes == NULL + if (!pScrn->modes #ifdef XSERVER_PLATFORM_BUS && !pScrn->is_gpu #endif
@@ -1781,7 +1781,7 @@ Bool AMDGPUScreenInit_KMS(ScreenPtr pScreen, int argc, char **argv) info->fb_shadow =calloc (1 , pScrn->displayWidth * pScrn->virtualY * ((pScrn->bitsPerPixel +7 ) >>3 )); -if (info->fb_shadow ==NULL ) { +if (!info->fb_shadow) {xf86DrvMsg (pScrn->scrnIndex,X_ERROR ,"Failed to allocate shadow framebuffer\n" );return FALSE;
@@ -2160,7 +2160,7 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen) cursor_size =AMDGPU_ALIGN (cursor_size,AMDGPU_GPU_PAGE_SIZE );for (c =0 ; c < xf86_config->num_crtc; c++) {/* cursor objects */ -if (info->cursor_buffer[c] ==NULL ) { +if (!info->cursor_buffer[c]) {if (info->gbm) { info->cursor_buffer[c] = (struct amdgpu_buffer *)calloc (1 ,sizeof (struct amdgpu_buffer ));if (!info->cursor_buffer[c]) {
@@ -2202,7 +2202,7 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen) } } -if (info->front_buffer ==NULL ) { +if (!info->front_buffer) {int pitch;int hint =0 ;
src/amdgpu_pixmap.c +1 -1
@@ -56,7 +56,7 @@ amdgpu_pixmap_create(ScreenPtr screen, int w, int h, int depth, unsigned usage)int stride; priv =calloc (1 ,sizeof (struct amdgpu_pixmap )); -if (priv ==NULL ) +if (!priv) goto fallback_pixmap; scrn =xf86ScreenToScrn (screen);
src/amdgpu_pixmap.h +1 -1
@@ -62,7 +62,7 @@ static inline Bool amdgpu_set_pixmap_bo(PixmapPtr pPix, struct amdgpu_buffer *bostruct amdgpu_pixmap *priv; priv =amdgpu_get_pixmap_private (pPix); -if (priv ==NULL && bo ==NULL ) +if (!priv && !bo)return TRUE;if (priv) {
src/amdgpu_video.c +1 -1
@@ -135,7 +135,7 @@ void AMDGPUInitVideo(ScreenPtr pScreen) num_adaptors =xf86XVListGenericAdaptors (pScrn, &adaptors); newAdaptors =malloc ((num_adaptors +2 ) *sizeof (*newAdaptors)); -if (newAdaptors ==NULL ) +if (!newAdaptors)return ; memcpy(newAdaptors, adaptors,
src/drmmode_display.c +4 -4
@@ -368,7 +368,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode,return pixmap; fbcon =drmModeGetFB (pAMDGPUEnt->fd, fbcon_id); -if (fbcon ==NULL ) +if (!fbcon)return NULL ; if (fbcon->depth != pScrn->depth ||
@@ -384,7 +384,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode, } bo =calloc (1 ,sizeof (struct amdgpu_buffer )); -if (bo ==NULL ) { +if (!bo) {xf86DrvMsg (pScrn->scrnIndex,X_ERROR ,"Couldn't allocate bo for fbcon handle\n" ); goto out_free_fb;
@@ -1342,7 +1342,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_resAMDGPUInfoPtr info =AMDGPUPTR (pScrn); crtc =xf86CrtcCreate (pScrn, &info->drmmode_crtc_funcs); -if (crtc ==NULL ) +if (!crtc)return 0 ; drmmode_crtc =xnfcalloc (sizeof (drmmode_crtc_private_rec),1 );
@@ -2233,7 +2233,7 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) width, height, -1, -1, pitch, info->front_buffer->cpu_ptr); }else { fb_shadow =calloc (1 , pitch * scrn->virtualY); -if (fb_shadow ==NULL ) +if (!fb_shadow) goto fail;free (info->fb_shadow); info->fb_shadow = fb_shadow;
Signature · 6 lines
2.17.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180516145141.21674-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Alex Deucher
Reviewed-byQuoted 5 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
Shorter and sweeter. :)
Signed-off-by Michel Dänzer <[email protected]>
Reviewed-by Alex Deucher <[email protected]>
Quoted 253 lines
--- src/amdgpu_bo_helper.c | 10 ++++------ src/amdgpu_dri2.c | 10 +++++----- src/amdgpu_glamor.c | 2 +- src/amdgpu_glamor_wrappers.c | 2 +- src/amdgpu_kms.c | 8 ++++---- src/amdgpu_pixmap.c | 2 +- src/amdgpu_pixmap.h | 2 +- src/amdgpu_video.c | 2 +- src/drmmode_display.c | 8 ++++---- 9 files changed, 22 insertions(+), 24 deletions(-)src/amdgpu_bo_helper.c +4
-6@@ -252,7 +252,7 @@ int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo)PROT_READ |PROT_WRITE ,MAP_SHARED , fd, args.out.addr_ptr); -if (ptr ==NULL ) { +if (!ptr) {ErrorF ("Failed to mmap the bo\n" );return -1 ; }@@ -266,7 +266,7 @@ int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo)void amdgpu_bo_unmap (struct amdgpu_buffer *bo) { -if (bo->cpu_ptr ==NULL ) +if (!bo->cpu_ptr)return ;if (bo->flags &AMDGPU_BO_FLAGS_GBM ) {@@ -289,9 +289,8 @@ struct amdgpu_buffer *amdgpu_bo_open(amdgpu_device_handle pDev,memset (&alloc_request,0 ,sizeof (struct amdgpu_bo_alloc_request )); bo = (struct amdgpu_buffer *)calloc (1 ,sizeof (struct amdgpu_buffer )); -if (bo ==NULL ) { +if (!bo)return NULL ; - } alloc_request.alloc_size = alloc_size; alloc_request.phys_alignment = phys_alignment;@@ -376,9 +375,8 @@ struct amdgpu_buffer *amdgpu_gem_bo_open_prime(amdgpu_device_handle pDev,struct amdgpu_bo_import_result buffer = {0 }; bo = (struct amdgpu_buffer *)calloc (1 ,sizeof (struct amdgpu_buffer )); -if (bo ==NULL ) { +if (!bo)return NULL ; - }if (amdgpu_bo_import (pDev, amdgpu_bo_handle_type_dma_buf_fd, (uint32_t )fd_handle, &buffer)) {src/amdgpu_dri2.c +5
-5@@ -162,7 +162,7 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen, } buffers =calloc (1 ,sizeof *buffers); -if (buffers ==NULL ) +if (!buffers) goto error;if (pixmap) {@@ -176,7 +176,7 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen, } privates =calloc (1 ,sizeof (struct dri2_buffer_priv )); -if (privates ==NULL ) +if (!privates) goto error; buffers->attachment = attachment;@@ -830,7 +830,7 @@ static int amdgpu_dri2_get_msc(DrawablePtr draw, CARD64 * ust, CARD64 * msc)xf86CrtcPtr crtc =amdgpu_dri2_drawable_crtc (draw, TRUE);/* Drawable not displayed, make up a value */ -if (crtc ==NULL ) { +if (!crtc) { *ust =0 ; *msc =0 ;return TRUE;@@ -941,7 +941,7 @@ static int amdgpu_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, remainder &=0xffffffff ;/* Drawable not visible, return immediately */ -if (crtc ==NULL ) +if (!crtc) goto out_complete; msc_delta =amdgpu_get_msc_delta (draw, crtc);@@ -1101,7 +1101,7 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,amdgpu_dri2_ref_buffer (back);/* either off-screen or CRTC not usable... just complete the swap */ -if (crtc ==NULL ) +if (!crtc) goto blit_fallback; msc_delta =amdgpu_get_msc_delta (draw, crtc);src/amdgpu_glamor.c +1
-1@@ -216,7 +216,7 @@ amdgpu_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,int stride; priv =calloc (1 ,sizeof (struct amdgpu_pixmap )); -if (priv ==NULL ) +if (!priv) goto fallback_pixmap; priv->bo = amdgpu_alloc_pixmap_bo(scrn, w, h, depth, usage,src/amdgpu_glamor_wrappers.c +1
-1@@ -209,7 +209,7 @@ amdgpu_glamor_picture_prepare_access_cpu_ro(ScrnInfoPtr scrn,PixmapPtr pixmap;struct amdgpu_pixmap *priv; -if (picture->pDrawable ==NULL ) +if (!picture->pDrawable)return TRUE; pixmap =get_drawable_pixmap (picture->pDrawable);src/amdgpu_kms.c +4
-4@@ -1511,7 +1511,7 @@ Bool AMDGPUPreInit_KMS(ScrnInfoPtr pScrn, int flags)return FALSE; } - if (pScrn->modes == NULL + if (!pScrn->modes #ifdef XSERVER_PLATFORM_BUS && !pScrn->is_gpu #endif@@ -1781,7 +1781,7 @@ Bool AMDGPUScreenInit_KMS(ScreenPtr pScreen, int argc, char **argv) info->fb_shadow =calloc (1 , pScrn->displayWidth * pScrn->virtualY * ((pScrn->bitsPerPixel +7 ) >>3 )); -if (info->fb_shadow ==NULL ) { +if (!info->fb_shadow) {xf86DrvMsg (pScrn->scrnIndex,X_ERROR ,"Failed to allocate shadow framebuffer\n" );return FALSE;@@ -2160,7 +2160,7 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen) cursor_size =AMDGPU_ALIGN (cursor_size,AMDGPU_GPU_PAGE_SIZE );for (c =0 ; c < xf86_config->num_crtc; c++) {/* cursor objects */ -if (info->cursor_buffer[c] ==NULL ) { +if (!info->cursor_buffer[c]) {if (info->gbm) { info->cursor_buffer[c] = (struct amdgpu_buffer *)calloc (1 ,sizeof (struct amdgpu_buffer ));if (!info->cursor_buffer[c]) {@@ -2202,7 +2202,7 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen) } } -if (info->front_buffer ==NULL ) { +if (!info->front_buffer) {int pitch;int hint =0 ;src/amdgpu_pixmap.c +1
-1@@ -56,7 +56,7 @@ amdgpu_pixmap_create(ScreenPtr screen, int w, int h, int depth, unsigned usage)int stride; priv =calloc (1 ,sizeof (struct amdgpu_pixmap )); -if (priv ==NULL ) +if (!priv) goto fallback_pixmap; scrn =xf86ScreenToScrn (screen);src/amdgpu_pixmap.h +1
-1@@ -62,7 +62,7 @@ static inline Bool amdgpu_set_pixmap_bo(PixmapPtr pPix, struct amdgpu_buffer *bostruct amdgpu_pixmap *priv; priv =amdgpu_get_pixmap_private (pPix); -if (priv ==NULL && bo ==NULL ) +if (!priv && !bo)return TRUE;if (priv) {src/amdgpu_video.c +1
-1@@ -135,7 +135,7 @@ void AMDGPUInitVideo(ScreenPtr pScreen) num_adaptors =xf86XVListGenericAdaptors (pScrn, &adaptors); newAdaptors =malloc ((num_adaptors +2 ) *sizeof (*newAdaptors)); -if (newAdaptors ==NULL ) +if (!newAdaptors)return ; memcpy(newAdaptors, adaptors,src/drmmode_display.c +4
-5@@ -368,7 +368,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode,return pixmap; fbcon =drmModeGetFB (pAMDGPUEnt->fd, fbcon_id); -if (fbcon ==NULL ) +if (!fbcon)return NULL ; if (fbcon->depth != pScrn->depth ||@@ -384,7 +384,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode, } bo =calloc (1 ,sizeof (struct amdgpu_buffer )); -if (bo ==NULL ) { +if (!bo) {xf86DrvMsg (pScrn->scrnIndex,X_ERROR ,"Couldn't allocate bo for fbcon handle\n" ); goto out_free_fb;@@ -1342,7 +1342,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_resAMDGPUInfoPtr info =AMDGPUPTR (pScrn); crtc =xf86CrtcCreate (pScrn, &info->drmmode_crtc_funcs); -if (crtc ==NULL ) +if (!crtc)return 0 ; drmmode_crtc =xnfcalloc (sizeof (drmmode_crtc_private_rec),1 );@@ -2233,7 +2233,7 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) width, height, -1, -1, pitch, info->front_buffer->cpu_ptr); }else { fb_shadow =calloc (1 , pitch * scrn->virtualY); -if (fb_shadow ==NULL ) +if (!fb_shadow) goto fail;free (info->fb_shadow); info->fb_shadow = fb_shadow; --2.17.0
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx