[PATCH xf86-video-amdgpu] Replace 'foo == NULL' with '!foo'
Alex Deucher
alexdeucher at gmail.com
Wed May 16 15:41:06 UTC 2018
On Wed, May 16, 2018 at 10:51 AM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> Shorter and sweeter. :)
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
> ---
> 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(-)
>
> diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c
> index 34880ff12..98eb04a64 100644
> --- a/src/amdgpu_bo_helper.c
> +++ b/src/amdgpu_bo_helper.c
> @@ -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)) {
> diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
> index 4a0f8bf24..a9e2819ae 100644
> --- a/src/amdgpu_dri2.c
> +++ b/src/amdgpu_dri2.c
> @@ -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);
> diff --git a/src/amdgpu_glamor.c b/src/amdgpu_glamor.c
> index 6efc372df..44cdbcff7 100644
> --- a/src/amdgpu_glamor.c
> +++ b/src/amdgpu_glamor.c
> @@ -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,
> diff --git a/src/amdgpu_glamor_wrappers.c b/src/amdgpu_glamor_wrappers.c
> index fab8e5ab9..d44eec9a8 100644
> --- a/src/amdgpu_glamor_wrappers.c
> +++ b/src/amdgpu_glamor_wrappers.c
> @@ -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);
> diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
> index 5ea90f90c..bedd02037 100644
> --- a/src/amdgpu_kms.c
> +++ b/src/amdgpu_kms.c
> @@ -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;
>
> diff --git a/src/amdgpu_pixmap.c b/src/amdgpu_pixmap.c
> index f2008b5a4..c5e80ad51 100644
> --- a/src/amdgpu_pixmap.c
> +++ b/src/amdgpu_pixmap.c
> @@ -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);
> diff --git a/src/amdgpu_pixmap.h b/src/amdgpu_pixmap.h
> index d744ca573..0cff1952f 100644
> --- a/src/amdgpu_pixmap.h
> +++ b/src/amdgpu_pixmap.h
> @@ -62,7 +62,7 @@ static inline Bool amdgpu_set_pixmap_bo(PixmapPtr pPix, struct amdgpu_buffer *bo
> struct amdgpu_pixmap *priv;
>
> priv = amdgpu_get_pixmap_private(pPix);
> - if (priv == NULL && bo == NULL)
> + if (!priv && !bo)
> return TRUE;
>
> if (priv) {
> diff --git a/src/amdgpu_video.c b/src/amdgpu_video.c
> index 8f9a2b977..94ae17096 100644
> --- a/src/amdgpu_video.c
> +++ b/src/amdgpu_video.c
> @@ -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,
> diff --git a/src/drmmode_display.c b/src/drmmode_display.c
> index 49284c697..0ee89961a 100644
> --- a/src/drmmode_display.c
> +++ b/src/drmmode_display.c
> @@ -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_res
> AMDGPUInfoPtr 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
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
More information about the amd-gfx
mailing list