forked from kiss-community/repo
287 lines
9.3 KiB
Diff
287 lines
9.3 KiB
Diff
|
From a92ccaf05efe8f11b3c5cd217d48ad3cf4caa090 Mon Sep 17 00:00:00 2001
|
||
|
From: Ethan Sommer <e5ten.arch@gmail.com>
|
||
|
Date: Mon, 16 Dec 2019 15:23:10 -0500
|
||
|
Subject: [PATCH] fix uninitialized variables causing segfaults when built with
|
||
|
clang
|
||
|
|
||
|
fixes #171
|
||
|
---
|
||
|
src/sna/kgem.c | 22 +++++++++++-----------
|
||
|
src/sna/kgem_debug.c | 4 ++--
|
||
|
src/sna/sna_damage.c | 4 ++--
|
||
|
src/sna/sna_display.c | 18 +++++++++---------
|
||
|
src/sna/sna_dri3.c | 2 +-
|
||
|
src/sna/sna_present.c | 4 ++--
|
||
|
6 files changed, 27 insertions(+), 27 deletions(-)
|
||
|
|
||
|
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
|
||
|
index 6a35067c..488cfa47 100644
|
||
|
--- a/src/sna/kgem.c
|
||
|
+++ b/src/sna/kgem.c
|
||
|
@@ -2846,7 +2846,7 @@ static bool kgem_bo_move_to_cache(struct kgem *kgem, struct kgem_bo *bo)
|
||
|
static struct kgem_bo *
|
||
|
search_snoop_cache(struct kgem *kgem, unsigned int num_pages, unsigned flags)
|
||
|
{
|
||
|
- struct kgem_bo *bo, *first = NULL;
|
||
|
+ struct kgem_bo *bo = NULL, *first = NULL;
|
||
|
|
||
|
DBG(("%s: num_pages=%d, flags=%x\n", __FUNCTION__, num_pages, flags));
|
||
|
|
||
|
@@ -3112,7 +3112,7 @@ void kgem_retire__buffers(struct kgem *kgem)
|
||
|
|
||
|
static bool kgem_retire__flushing(struct kgem *kgem)
|
||
|
{
|
||
|
- struct kgem_bo *bo, *next;
|
||
|
+ struct kgem_bo *bo = NULL, *next;
|
||
|
bool retired = false;
|
||
|
|
||
|
list_for_each_entry_safe(bo, next, &kgem->flushing, request) {
|
||
|
@@ -3410,7 +3410,7 @@ static void kgem_commit__check_reloc(struct kgem *kgem)
|
||
|
#ifndef NDEBUG
|
||
|
static void kgem_commit__check_buffers(struct kgem *kgem)
|
||
|
{
|
||
|
- struct kgem_buffer *bo;
|
||
|
+ struct kgem_buffer *bo = NULL;
|
||
|
|
||
|
list_for_each_entry(bo, &kgem->active_buffers, base.list)
|
||
|
assert(bo->base.exec == NULL);
|
||
|
@@ -3422,7 +3422,7 @@ static void kgem_commit__check_buffers(struct kgem *kgem)
|
||
|
static void kgem_commit(struct kgem *kgem)
|
||
|
{
|
||
|
struct kgem_request *rq = kgem->next_request;
|
||
|
- struct kgem_bo *bo, *next;
|
||
|
+ struct kgem_bo *bo = NULL, *next;
|
||
|
|
||
|
kgem_commit__check_reloc(kgem);
|
||
|
|
||
|
@@ -3536,7 +3536,7 @@ static void kgem_close_inactive(struct kgem *kgem)
|
||
|
|
||
|
static void kgem_finish_buffers(struct kgem *kgem)
|
||
|
{
|
||
|
- struct kgem_buffer *bo, *next;
|
||
|
+ struct kgem_buffer *bo = NULL, *next;
|
||
|
|
||
|
list_for_each_entry_safe(bo, next, &kgem->batch_buffers, base.list) {
|
||
|
DBG(("%s: buffer handle=%d, used=%d, exec?=%d, write=%d, mmapped=%s, refcnt=%d\n",
|
||
|
@@ -3925,7 +3925,7 @@ static int compact_batch_surface(struct kgem *kgem, int *shrink)
|
||
|
|
||
|
static struct kgem_bo *first_available(struct kgem *kgem, struct list *list)
|
||
|
{
|
||
|
- struct kgem_bo *bo;
|
||
|
+ struct kgem_bo *bo = NULL;
|
||
|
|
||
|
list_for_each_entry(bo, list, list) {
|
||
|
assert(bo->refcnt > 0);
|
||
|
@@ -4209,7 +4209,7 @@ void _kgem_submit(struct kgem *kgem)
|
||
|
kgem->nreloc, kgem->nexec, kgem->nfence, kgem->aperture, kgem->aperture_fenced, kgem->aperture_high, kgem->aperture_total, -ret);
|
||
|
|
||
|
for (i = 0; i < kgem->nexec; i++) {
|
||
|
- struct kgem_bo *bo, *found = NULL;
|
||
|
+ struct kgem_bo *bo = NULL, *found = NULL;
|
||
|
|
||
|
list_for_each_entry(bo, &kgem->next_request->buffers, request) {
|
||
|
if (bo->handle == kgem->exec[i].handle) {
|
||
|
@@ -4573,7 +4573,7 @@ bool kgem_cleanup_cache(struct kgem *kgem)
|
||
|
static struct kgem_bo *
|
||
|
search_linear_cache(struct kgem *kgem, unsigned int num_pages, unsigned flags)
|
||
|
{
|
||
|
- struct kgem_bo *bo, *first = NULL;
|
||
|
+ struct kgem_bo *bo = NULL, *first = NULL;
|
||
|
bool use_active = (flags & CREATE_INACTIVE) == 0;
|
||
|
struct list *cache;
|
||
|
|
||
|
@@ -5377,7 +5377,7 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem,
|
||
|
uint32_t flags)
|
||
|
{
|
||
|
struct list *cache;
|
||
|
- struct kgem_bo *bo;
|
||
|
+ struct kgem_bo *bo = NULL;
|
||
|
uint32_t pitch, tiled_height, size;
|
||
|
uint32_t handle;
|
||
|
int i, bucket, retry;
|
||
|
@@ -7220,7 +7220,7 @@ void kgem_bo_sync__gtt(struct kgem *kgem, struct kgem_bo *bo)
|
||
|
void kgem_clear_dirty(struct kgem *kgem)
|
||
|
{
|
||
|
struct list * const buffers = &kgem->next_request->buffers;
|
||
|
- struct kgem_bo *bo;
|
||
|
+ struct kgem_bo *bo = NULL;
|
||
|
|
||
|
list_for_each_entry(bo, buffers, request) {
|
||
|
if (!bo->gpu_dirty)
|
||
|
@@ -7500,7 +7500,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
|
||
|
uint32_t size, uint32_t flags,
|
||
|
void **ret)
|
||
|
{
|
||
|
- struct kgem_buffer *bo;
|
||
|
+ struct kgem_buffer *bo = NULL;
|
||
|
unsigned offset, alloc;
|
||
|
struct kgem_bo *old;
|
||
|
|
||
|
diff --git a/src/sna/kgem_debug.c b/src/sna/kgem_debug.c
|
||
|
index d90e5439..e417a99a 100644
|
||
|
--- a/src/sna/kgem_debug.c
|
||
|
+++ b/src/sna/kgem_debug.c
|
||
|
@@ -56,7 +56,7 @@ struct kgem_bo *
|
||
|
kgem_debug_get_bo_for_reloc_entry(struct kgem *kgem,
|
||
|
struct drm_i915_gem_relocation_entry *reloc)
|
||
|
{
|
||
|
- struct kgem_bo *bo;
|
||
|
+ struct kgem_bo *bo = NULL;
|
||
|
|
||
|
if (reloc == NULL)
|
||
|
return NULL;
|
||
|
@@ -86,7 +86,7 @@ static int kgem_debug_handle_is_fenced(struct kgem *kgem, uint32_t handle)
|
||
|
|
||
|
static int kgem_debug_handle_tiling(struct kgem *kgem, uint32_t handle)
|
||
|
{
|
||
|
- struct kgem_bo *bo;
|
||
|
+ struct kgem_bo *bo = NULL;
|
||
|
|
||
|
list_for_each_entry(bo, &kgem->next_request->buffers, request)
|
||
|
if (bo->target_handle == handle)
|
||
|
diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c
|
||
|
index 8824a10b..a51935a3 100644
|
||
|
--- a/src/sna/sna_damage.c
|
||
|
+++ b/src/sna/sna_damage.c
|
||
|
@@ -215,7 +215,7 @@ static void __sna_damage_reduce(struct sna_damage *damage)
|
||
|
int n, nboxes;
|
||
|
BoxPtr boxes, free_boxes = NULL;
|
||
|
pixman_region16_t *region = &damage->region;
|
||
|
- struct sna_damage_box *iter;
|
||
|
+ struct sna_damage_box *iter = NULL;
|
||
|
|
||
|
assert(damage->mode != DAMAGE_ALL);
|
||
|
assert(damage->dirty);
|
||
|
@@ -1808,7 +1808,7 @@ void _sna_damage_debug_get_region(struct sna_damage *damage, RegionRec *r)
|
||
|
{
|
||
|
int n, nboxes;
|
||
|
BoxPtr boxes;
|
||
|
- struct sna_damage_box *iter;
|
||
|
+ struct sna_damage_box *iter = NULL;
|
||
|
|
||
|
RegionCopy(r, &damage->region);
|
||
|
if (!damage->dirty)
|
||
|
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
|
||
|
index 874292bc..ee38e1a6 100644
|
||
|
--- a/src/sna/sna_display.c
|
||
|
+++ b/src/sna/sna_display.c
|
||
|
@@ -467,7 +467,7 @@ static inline uint32_t fb_id(struct kgem_bo *bo)
|
||
|
|
||
|
unsigned sna_crtc_count_sprites(xf86CrtcPtr crtc)
|
||
|
{
|
||
|
- struct plane *sprite;
|
||
|
+ struct plane *sprite = NULL;
|
||
|
unsigned count;
|
||
|
|
||
|
count = 0;
|
||
|
@@ -479,7 +479,7 @@ unsigned sna_crtc_count_sprites(xf86CrtcPtr crtc)
|
||
|
|
||
|
static struct plane *lookup_sprite(struct sna_crtc *crtc, unsigned idx)
|
||
|
{
|
||
|
- struct plane *sprite;
|
||
|
+ struct plane *sprite = NULL;
|
||
|
|
||
|
list_for_each_entry(sprite, &crtc->sprites, link)
|
||
|
if (idx-- == 0)
|
||
|
@@ -1727,7 +1727,7 @@ static bool wait_for_shadow(struct sna *sna,
|
||
|
|
||
|
if ((flags & MOVE_WRITE) == 0) {
|
||
|
if ((flags & __MOVE_SCANOUT) == 0) {
|
||
|
- struct sna_crtc *crtc;
|
||
|
+ struct sna_crtc *crtc = NULL;
|
||
|
|
||
|
list_for_each_entry(crtc, &sna->mode.shadow_crtc, shadow_link) {
|
||
|
if (overlap(&sna->mode.shadow_region.extents,
|
||
|
@@ -1768,7 +1768,7 @@ static bool wait_for_shadow(struct sna *sna,
|
||
|
|
||
|
flip_active = sna->mode.flip_active;
|
||
|
if (flip_active) {
|
||
|
- struct sna_crtc *crtc;
|
||
|
+ struct sna_crtc *crtc = NULL;
|
||
|
list_for_each_entry(crtc, &sna->mode.shadow_crtc, shadow_link)
|
||
|
flip_active -= crtc->flip_pending;
|
||
|
DBG(("%s: %d flips still pending, shadow flip_active=%d\n",
|
||
|
@@ -3263,7 +3263,7 @@ static void
|
||
|
sna_crtc_destroy(xf86CrtcPtr crtc)
|
||
|
{
|
||
|
struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
|
||
|
- struct plane *sprite, *sn;
|
||
|
+ struct plane *sprite = NULL, *sn;
|
||
|
|
||
|
if (sna_crtc == NULL)
|
||
|
return;
|
||
|
@@ -3652,7 +3652,7 @@ bool sna_has_sprite_format(struct sna *sna, uint32_t format)
|
||
|
|
||
|
for (i = 0; i < sna->mode.num_real_crtc; i++) {
|
||
|
struct sna_crtc *sna_crtc = to_sna_crtc(config->crtc[i]);
|
||
|
- struct plane *plane;
|
||
|
+ struct plane *plane = NULL;
|
||
|
|
||
|
list_for_each_entry(plane, &sna_crtc->sprites, link) {
|
||
|
struct local_mode_get_plane p;
|
||
|
@@ -8639,7 +8639,7 @@ sna_mode_disable_secondary_planes(struct sna *sna)
|
||
|
for (c = 0; c < sna->mode.num_real_crtc; c++) {
|
||
|
xf86CrtcPtr crtc = config->crtc[c];
|
||
|
struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
|
||
|
- struct plane *plane;
|
||
|
+ struct plane *plane = NULL;
|
||
|
|
||
|
list_for_each_entry(plane, &sna_crtc->sprites, link) {
|
||
|
struct local_mode_get_plane p;
|
||
|
@@ -8737,7 +8737,7 @@ static bool
|
||
|
sna_crtc_hide_planes(struct sna *sna, struct sna_crtc *crtc)
|
||
|
{
|
||
|
struct local_mode_set_plane s;
|
||
|
- struct plane *plane;
|
||
|
+ struct plane *plane = NULL;
|
||
|
|
||
|
if (crtc->primary.id == 0)
|
||
|
return false;
|
||
|
@@ -8774,7 +8774,7 @@ void sna_mode_reset(struct sna *sna)
|
||
|
|
||
|
for (i = 0; i < sna->mode.num_real_crtc; i++) {
|
||
|
struct sna_crtc *sna_crtc = to_sna_crtc(config->crtc[i]);
|
||
|
- struct plane *plane;
|
||
|
+ struct plane *plane = NULL;
|
||
|
|
||
|
assert(sna_crtc != NULL);
|
||
|
|
||
|
diff --git a/src/sna/sna_dri3.c b/src/sna/sna_dri3.c
|
||
|
index ce4970ae..c5a7c820 100644
|
||
|
--- a/src/sna/sna_dri3.c
|
||
|
+++ b/src/sna/sna_dri3.c
|
||
|
@@ -175,7 +175,7 @@ static PixmapPtr sna_dri3_pixmap_from_fd(ScreenPtr screen,
|
||
|
{
|
||
|
struct sna *sna = to_sna_from_screen(screen);
|
||
|
PixmapPtr pixmap;
|
||
|
- struct sna_pixmap *priv;
|
||
|
+ struct sna_pixmap *priv = NULL;
|
||
|
struct kgem_bo *bo;
|
||
|
|
||
|
DBG(("%s(fd=%d, width=%d, height=%d, stride=%d, depth=%d, bpp=%d)\n",
|
||
|
diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
|
||
|
index 6bb7b927..7309871b 100644
|
||
|
--- a/src/sna/sna_present.c
|
||
|
+++ b/src/sna/sna_present.c
|
||
|
@@ -376,7 +376,7 @@ sna_present_get_crtc(WindowPtr window)
|
||
|
static void add_keepalive(struct sna *sna, xf86CrtcPtr crtc, uint64_t msc)
|
||
|
{
|
||
|
struct list *q = sna_crtc_vblank_queue(crtc);
|
||
|
- struct sna_present_event *info, *tmp;
|
||
|
+ struct sna_present_event *info, *tmp = NULL;
|
||
|
union drm_wait_vblank vbl;
|
||
|
|
||
|
list_for_each_entry(tmp, q, link) {
|
||
|
@@ -480,7 +480,7 @@ static int
|
||
|
sna_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
|
||
|
{
|
||
|
struct sna *sna = to_sna_from_screen(crtc->pScreen);
|
||
|
- struct sna_present_event *info, *tmp;
|
||
|
+ struct sna_present_event *info, *tmp = NULL;
|
||
|
const struct ust_msc *swap;
|
||
|
struct list *q;
|
||
|
|
||
|
--
|
||
|
GitLab
|
||
|
|