nsxive0e9697
Removed overcautious parameter checks
+11 −147
6 files changed
- M Makefile +1 −1
- M image.c +3 −52
- M main.c +3 −8
- M thumbs.c +1 −37
- M util.c +3 −12
- M window.c +0 −37
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION := git-20150819 | |
| 1 | + | VERSION := git-20151028 | |
| 2 | 2 | ||
| 3 | 3 | PREFIX := /usr/local | |
| 4 | 4 | MANPREFIX := $(PREFIX)/share/man | |
| @@ -51,9 +51,6 @@ void img_init(img_t *img, win_t *win) | |||
| 51 | 51 | zoom_min = zoom_levels[0] / 100.0; | |
| 52 | 52 | zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0; | |
| 53 | 53 | ||
| 54 | − | if (img == NULL || win == NULL) | |
| 55 | − | return; | |
| 56 | − | ||
| 57 | 54 | imlib_context_set_display(win->env.dpy); | |
| 58 | 55 | imlib_context_set_visual(win->env.vis); | |
| 59 | 56 | imlib_context_set_colormap(win->env.cmap); | |
| @@ -300,9 +297,6 @@ bool img_load(img_t *img, const fileinfo_t *file) | |||
| 300 | 297 | { | |
| 301 | 298 | const char *fmt; | |
| 302 | 299 | ||
| 303 | − | if (img == NULL || file == NULL || file->name == NULL || file->path == NULL) | |
| 304 | − | return false; | |
| 305 | − | ||
| 306 | 300 | if (access(file->path, R_OK) < 0 || | |
| 307 | 301 | (img->im = imlib_load_image(file->path)) == NULL) | |
| 308 | 302 | { | |
| @@ -336,9 +330,6 @@ void img_close(img_t *img, bool decache) | |||
| 336 | 330 | { | |
| 337 | 331 | int i; | |
| 338 | 332 | ||
| 339 | − | if (img == NULL) | |
| 340 | − | return; | |
| 341 | − | ||
| 342 | 333 | if (img->multi.cnt > 0) { | |
| 343 | 334 | for (i = 0; i < img->multi.cnt; i++) { | |
| 344 | 335 | imlib_context_set_image(img->multi.frames[i].im); | |
| @@ -362,9 +353,6 @@ void img_check_pan(img_t *img, bool moved) | |||
| 362 | 353 | int ox, oy; | |
| 363 | 354 | float w, h; | |
| 364 | 355 | ||
| 365 | − | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 366 | − | return; | |
| 367 | − | ||
| 368 | 356 | win = img->win; | |
| 369 | 357 | w = img->w * img->zoom; | |
| 370 | 358 | h = img->h * img->zoom; | |
| @@ -392,8 +380,6 @@ bool img_fit(img_t *img) | |||
| 392 | 380 | { | |
| 393 | 381 | float z, zmax, zw, zh; | |
| 394 | 382 | ||
| 395 | − | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 396 | − | return false; | |
| 397 | 383 | if (img->scalemode == SCALE_ZOOM) | |
| 398 | 384 | return false; | |
| 399 | 385 | ||
| @@ -433,9 +419,6 @@ void img_render(img_t *img) | |||
| 433 | 419 | Imlib_Image bg; | |
| 434 | 420 | unsigned long c; | |
| 435 | 421 | ||
| 436 | − | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 437 | − | return; | |
| 438 | − | ||
| 439 | 422 | win = img->win; | |
| 440 | 423 | img_fit(img); | |
| 441 | 424 | ||
| @@ -521,9 +504,6 @@ bool img_fit_win(img_t *img, scalemode_t sm) | |||
| 521 | 504 | { | |
| 522 | 505 | float oz; | |
| 523 | 506 | ||
| 524 | − | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 525 | − | return false; | |
| 526 | − | ||
| 527 | 507 | oz = img->zoom; | |
| 528 | 508 | img->scalemode = sm; | |
| 529 | 509 | ||
| @@ -539,9 +519,6 @@ bool img_fit_win(img_t *img, scalemode_t sm) | |||
| 539 | 519 | ||
| 540 | 520 | bool img_zoom(img_t *img, float z) | |
| 541 | 521 | { | |
| 542 | − | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 543 | − | return false; | |
| 544 | − | ||
| 545 | 522 | z = MAX(z, zoom_min); | |
| 546 | 523 | z = MIN(z, zoom_max); | |
| 547 | 524 | ||
| @@ -564,9 +541,6 @@ bool img_zoom_in(img_t *img) | |||
| 564 | 541 | int i; | |
| 565 | 542 | float z; | |
| 566 | 543 | ||
| 567 | − | if (img == NULL || img->im == NULL) | |
| 568 | − | return false; | |
| 569 | − | ||
| 570 | 544 | for (i = 1; i < ARRLEN(zoom_levels); i++) { | |
| 571 | 545 | z = zoom_levels[i] / 100.0; | |
| 572 | 546 | if (zoomdiff(z, img->zoom) > 0) | |
| @@ -580,9 +554,6 @@ bool img_zoom_out(img_t *img) | |||
| 580 | 554 | int i; | |
| 581 | 555 | float z; | |
| 582 | 556 | ||
| 583 | − | if (img == NULL || img->im == NULL) | |
| 584 | − | return false; | |
| 585 | − | ||
| 586 | 557 | for (i = ARRLEN(zoom_levels) - 2; i >= 0; i--) { | |
| 587 | 558 | z = zoom_levels[i] / 100.0; | |
| 588 | 559 | if (zoomdiff(z, img->zoom) < 0) | |
| @@ -595,9 +566,6 @@ bool img_move(img_t *img, float dx, float dy) | |||
| 595 | 566 | { | |
| 596 | 567 | float ox, oy; | |
| 597 | 568 | ||
| 598 | − | if (img == NULL || img->im == NULL) | |
| 599 | − | return false; | |
| 600 | − | ||
| 601 | 569 | ox = img->x; | |
| 602 | 570 | oy = img->y; | |
| 603 | 571 | ||
| @@ -622,9 +590,6 @@ bool img_pan(img_t *img, direction_t dir, int d) | |||
| 622 | 590 | */ | |
| 623 | 591 | float x, y; | |
| 624 | 592 | ||
| 625 | − | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 626 | − | return false; | |
| 627 | − | ||
| 628 | 593 | if (d > 0) { | |
| 629 | 594 | x = y = MAX(1, (float) d * img->zoom); | |
| 630 | 595 | } else { | |
| @@ -649,9 +614,6 @@ bool img_pan_edge(img_t *img, direction_t dir) | |||
| 649 | 614 | { | |
| 650 | 615 | int ox, oy; | |
| 651 | 616 | ||
| 652 | − | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 653 | − | return false; | |
| 654 | − | ||
| 655 | 617 | ox = img->x; | |
| 656 | 618 | oy = img->y; | |
| 657 | 619 | ||
| @@ -678,9 +640,6 @@ void img_rotate(img_t *img, degree_t d) | |||
| 678 | 640 | { | |
| 679 | 641 | int i, ox, oy, tmp; | |
| 680 | 642 | ||
| 681 | − | if (img == NULL || img->im == NULL || img->win == NULL) | |
| 682 | − | return; | |
| 683 | − | ||
| 684 | 643 | imlib_context_set_image(img->im); | |
| 685 | 644 | imlib_image_orientate(d); | |
| 686 | 645 | ||
| @@ -716,7 +675,7 @@ void img_flip(img_t *img, flipdir_t d) | |||
| 716 | 675 | ||
| 717 | 676 | d = (d & (FLIP_HORIZONTAL | FLIP_VERTICAL)) - 1; | |
| 718 | 677 | ||
| 719 | − | if (img == NULL || img->im == NULL || d < 0 || d >= ARRLEN(imlib_flip_op)) | |
| 678 | + | if (d < 0 || d >= ARRLEN(imlib_flip_op)) | |
| 720 | 679 | return; | |
| 721 | 680 | ||
| 722 | 681 | imlib_context_set_image(img->im); | |
| @@ -733,9 +692,6 @@ void img_flip(img_t *img, flipdir_t d) | |||
| 733 | 692 | ||
| 734 | 693 | void img_toggle_antialias(img_t *img) | |
| 735 | 694 | { | |
| 736 | − | if (img == NULL || img->im == NULL) | |
| 737 | − | return; | |
| 738 | − | ||
| 739 | 695 | img->aa = !img->aa; | |
| 740 | 696 | imlib_context_set_image(img->im); | |
| 741 | 697 | imlib_context_set_anti_alias(img->aa); | |
| @@ -751,9 +707,6 @@ bool img_change_gamma(img_t *img, int d) | |||
| 751 | 707 | int gamma; | |
| 752 | 708 | double range; | |
| 753 | 709 | ||
| 754 | − | if (img == NULL) | |
| 755 | − | return false; | |
| 756 | − | ||
| 757 | 710 | if (d == 0) | |
| 758 | 711 | gamma = 0; | |
| 759 | 712 | else | |
| @@ -775,8 +728,6 @@ bool img_change_gamma(img_t *img, int d) | |||
| 775 | 728 | ||
| 776 | 729 | bool img_frame_goto(img_t *img, int n) | |
| 777 | 730 | { | |
| 778 | − | if (img == NULL || img->im == NULL) | |
| 779 | − | return false; | |
| 780 | 731 | if (n < 0 || n >= img->multi.cnt || n == img->multi.sel) | |
| 781 | 732 | return false; | |
| 782 | 733 | ||
| @@ -794,7 +745,7 @@ bool img_frame_goto(img_t *img, int n) | |||
| 794 | 745 | ||
| 795 | 746 | bool img_frame_navigate(img_t *img, int d) | |
| 796 | 747 | { | |
| 797 | − | if (img == NULL|| img->im == NULL || img->multi.cnt == 0 || d == 0) | |
| 748 | + | if (img->multi.cnt == 0 || d == 0) | |
| 798 | 749 | return false; | |
| 799 | 750 | ||
| 800 | 751 | d += img->multi.sel; | |
| @@ -808,7 +759,7 @@ bool img_frame_navigate(img_t *img, int d) | |||
| 808 | 759 | ||
| 809 | 760 | bool img_frame_animate(img_t *img) | |
| 810 | 761 | { | |
| 811 | − | if (img == NULL || img->im == NULL || img->multi.cnt == 0) | |
| 762 | + | if (img->multi.cnt == 0) | |
| 812 | 763 | return false; | |
| 813 | 764 | ||
| 814 | 765 | if (img->multi.sel + 1 >= img->multi.cnt) | |
| @@ -117,7 +117,7 @@ void check_add_file(char *filename, bool given) | |||
| 117 | 117 | { | |
| 118 | 118 | const char *bn; | |
| 119 | 119 | ||
| 120 | − | if (filename == NULL || *filename == '\0') | |
| 120 | + | if (*filename == '\0') | |
| 121 | 121 | return; | |
| 122 | 122 | ||
| 123 | 123 | if (access(filename, R_OK) < 0) { | |
| @@ -323,7 +323,8 @@ void load_image(int new) | |||
| 323 | 323 | if (new < 0 || new >= filecnt) | |
| 324 | 324 | return; | |
| 325 | 325 | ||
| 326 | − | win_set_cursor(&win, CURSOR_WATCH); | |
| 326 | + | if (win.xwin != None) | |
| 327 | + | win_set_cursor(&win, CURSOR_WATCH); | |
| 327 | 328 | reset_timeout(slideshow); | |
| 328 | 329 | ||
| 329 | 330 | if (new != current) | |
| @@ -590,9 +591,6 @@ void on_keypress(XKeyEvent *kev) | |||
| 590 | 591 | char key; | |
| 591 | 592 | bool dirty = false; | |
| 592 | 593 | ||
| 593 | − | if (kev == NULL) | |
| 594 | − | return; | |
| 595 | − | ||
| 596 | 594 | if (kev->state & ShiftMask) { | |
| 597 | 595 | kev->state &= ~ShiftMask; | |
| 598 | 596 | XLookupString(kev, &key, 1, &shksym, NULL); | |
| @@ -633,9 +631,6 @@ void on_buttonpress(XButtonEvent *bev) | |||
| 633 | 631 | bool dirty = false; | |
| 634 | 632 | static Time firstclick; | |
| 635 | 633 | ||
| 636 | − | if (bev == NULL) | |
| 637 | − | return; | |
| 638 | − | ||
| 639 | 634 | if (mode == MODE_IMAGE) { | |
| 640 | 635 | win_set_cursor(&win, CURSOR_ARROW); | |
| 641 | 636 | set_timeout(reset_cursor, TO_CURSOR_HIDE, true); | |
| @@ -43,7 +43,7 @@ char* tns_cache_filepath(const char *filepath) | |||
| 43 | 43 | size_t len; | |
| 44 | 44 | char *cfile = NULL; | |
| 45 | 45 | ||
| 46 | − | if (cache_dir == NULL || filepath == NULL || *filepath != '/') | |
| 46 | + | if (*filepath != '/') | |
| 47 | 47 | return NULL; | |
| 48 | 48 | ||
| 49 | 49 | if (strncmp(filepath, cache_dir, strlen(cache_dir)) != 0) { | |
| @@ -61,8 +61,6 @@ Imlib_Image tns_cache_load(const char *filepath, bool *outdated) | |||
| 61 | 61 | struct stat cstats, fstats; | |
| 62 | 62 | Imlib_Image im = NULL; | |
| 63 | 63 | ||
| 64 | − | if (filepath == NULL) | |
| 65 | − | return NULL; | |
| 66 | 64 | if (stat(filepath, &fstats) < 0) | |
| 67 | 65 | return NULL; | |
| 68 | 66 | ||
| @@ -85,8 +83,6 @@ void tns_cache_write(Imlib_Image im, const char *filepath, bool force) | |||
| 85 | 83 | struct utimbuf times; | |
| 86 | 84 | Imlib_Load_Error err = 0; | |
| 87 | 85 | ||
| 88 | − | if (im == NULL || filepath == NULL) | |
| 89 | − | return; | |
| 90 | 86 | if (stat(filepath, &fstats) < 0) | |
| 91 | 87 | return; | |
| 92 | 88 | ||
| @@ -126,9 +122,6 @@ void tns_clean_cache(tns_t *tns) | |||
| 126 | 122 | char *cfile, *filename, *tpos; | |
| 127 | 123 | r_dir_t dir; | |
| 128 | 124 | ||
| 129 | − | if (cache_dir == NULL) | |
| 130 | − | return; | |
| 131 | − | ||
| 132 | 125 | if (r_opendir(&dir, cache_dir) < 0) { | |
| 133 | 126 | warn("could not open thumbnail cache directory: %s", cache_dir); | |
| 134 | 127 | return; | |
| @@ -162,9 +155,6 @@ void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel, | |||
| 162 | 155 | int len; | |
| 163 | 156 | const char *homedir, *dsuffix = ""; | |
| 164 | 157 | ||
| 165 | − | if (tns == NULL) | |
| 166 | − | return; | |
| 167 | − | ||
| 168 | 158 | if (cnt != NULL && *cnt > 0) { | |
| 169 | 159 | tns->thumbs = (thumb_t*) s_malloc(*cnt * sizeof(thumb_t)); | |
| 170 | 160 | memset(tns->thumbs, 0, *cnt * sizeof(thumb_t)); | |
| @@ -200,9 +190,6 @@ void tns_free(tns_t *tns) | |||
| 200 | 190 | { | |
| 201 | 191 | int i; | |
| 202 | 192 | ||
| 203 | − | if (tns == NULL) | |
| 204 | − | return; | |
| 205 | − | ||
| 206 | 193 | if (tns->thumbs != NULL) { | |
| 207 | 194 | for (i = 0; i < *tns->cnt; i++) { | |
| 208 | 195 | if (tns->thumbs[i].im != NULL) { | |
| @@ -253,8 +240,6 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only) | |||
| 253 | 240 | fileinfo_t *file; | |
| 254 | 241 | Imlib_Image im = NULL; | |
| 255 | 242 | ||
| 256 | − | if (tns == NULL || tns->thumbs == NULL) | |
| 257 | − | return false; | |
| 258 | 243 | if (n < 0 || n >= *tns->cnt) | |
| 259 | 244 | return false; | |
| 260 | 245 | file = &tns->files[n]; | |
| @@ -386,8 +371,6 @@ void tns_unload(tns_t *tns, int n) | |||
| 386 | 371 | { | |
| 387 | 372 | thumb_t *t; | |
| 388 | 373 | ||
| 389 | − | if (tns == NULL || tns->thumbs == NULL) | |
| 390 | − | return; | |
| 391 | 374 | if (n < 0 || n >= *tns->cnt) | |
| 392 | 375 | return; | |
| 393 | 376 | ||
| @@ -434,8 +417,6 @@ void tns_render(tns_t *tns) | |||
| 434 | 417 | win_t *win; | |
| 435 | 418 | int i, cnt, r, x, y; | |
| 436 | 419 | ||
| 437 | − | if (tns == NULL || tns->thumbs == NULL || tns->win == NULL) | |
| 438 | − | return; | |
| 439 | 420 | if (!tns->dirty) | |
| 440 | 421 | return; | |
| 441 | 422 | ||
| @@ -495,9 +476,6 @@ void tns_render(tns_t *tns) | |||
| 495 | 476 | ||
| 496 | 477 | void tns_mark(tns_t *tns, int n, bool mark) | |
| 497 | 478 | { | |
| 498 | − | if (tns == NULL || tns->thumbs == NULL || tns->win == NULL) | |
| 499 | − | return; | |
| 500 | − | ||
| 501 | 479 | if (n >= 0 && n < *tns->cnt && tns->thumbs[n].im != NULL) { | |
| 502 | 480 | win_t *win = tns->win; | |
| 503 | 481 | thumb_t *t = &tns->thumbs[n]; | |
| @@ -519,9 +497,6 @@ void tns_mark(tns_t *tns, int n, bool mark) | |||
| 519 | 497 | ||
| 520 | 498 | void tns_highlight(tns_t *tns, int n, bool hl) | |
| 521 | 499 | { | |
| 522 | − | if (tns == NULL || tns->thumbs == NULL || tns->win == NULL) | |
| 523 | − | return; | |
| 524 | − | ||
| 525 | 500 | if (n >= 0 && n < *tns->cnt && tns->thumbs[n].im != NULL) { | |
| 526 | 501 | win_t *win = tns->win; | |
| 527 | 502 | thumb_t *t = &tns->thumbs[n]; | |
| @@ -545,9 +520,6 @@ bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) | |||
| 545 | 520 | { | |
| 546 | 521 | int old, max; | |
| 547 | 522 | ||
| 548 | − | if (tns == NULL || tns->thumbs == NULL) | |
| 549 | − | return false; | |
| 550 | − | ||
| 551 | 523 | old = *tns->sel; | |
| 552 | 524 | cnt = cnt > 1 ? cnt : 1; | |
| 553 | 525 | ||
| @@ -581,9 +553,6 @@ bool tns_scroll(tns_t *tns, direction_t dir, bool screen) | |||
| 581 | 553 | { | |
| 582 | 554 | int d, max, old; | |
| 583 | 555 | ||
| 584 | − | if (tns == NULL) | |
| 585 | − | return false; | |
| 586 | − | ||
| 587 | 556 | old = tns->first; | |
| 588 | 557 | d = tns->cols * (screen ? tns->rows : 1); | |
| 589 | 558 | ||
| @@ -607,9 +576,6 @@ bool tns_zoom(tns_t *tns, int d) | |||
| 607 | 576 | { | |
| 608 | 577 | int i, oldzl; | |
| 609 | 578 | ||
| 610 | − | if (tns == NULL || tns->thumbs == NULL) | |
| 611 | − | return false; | |
| 612 | − | ||
| 613 | 579 | oldzl = tns->zl; | |
| 614 | 580 | tns->zl += -(d < 0) + (d > 0); | |
| 615 | 581 | tns->zl = MAX(tns->zl, 0); | |
| @@ -631,8 +597,6 @@ int tns_translate(tns_t *tns, int x, int y) | |||
| 631 | 597 | { | |
| 632 | 598 | int n; | |
| 633 | 599 | ||
| 634 | − | if (tns == NULL || tns->thumbs == NULL) | |
| 635 | − | return -1; | |
| 636 | 600 | if (x < tns->x || y < tns->y) | |
| 637 | 601 | return -1; | |
| 638 | 602 | ||
| @@ -103,9 +103,6 @@ ssize_t get_line(char **buf, size_t *n, FILE *stream) | |||
| 103 | 103 | size_t len; | |
| 104 | 104 | char *s; | |
| 105 | 105 | ||
| 106 | − | if (stream == NULL || feof(stream) || ferror(stream)) | |
| 107 | − | return -1; | |
| 108 | − | ||
| 109 | 106 | if (*buf == NULL || *n == 0) { | |
| 110 | 107 | *n = BUF_SIZE; | |
| 111 | 108 | *buf = (char*) s_malloc(*n); | |
| @@ -148,7 +145,7 @@ char* absolute_path(const char *filename) | |||
| 148 | 145 | char *dir, *dirname = NULL, *path = NULL, *s; | |
| 149 | 146 | char *cwd = NULL, *twd = NULL; | |
| 150 | 147 | ||
| 151 | − | if (filename == NULL || *filename == '\0' || *filename == '/') | |
| 148 | + | if (*filename == '\0' || *filename == '/') | |
| 152 | 149 | return NULL; | |
| 153 | 150 | ||
| 154 | 151 | len = FNAME_LEN; | |
| @@ -211,7 +208,7 @@ end: | |||
| 211 | 208 | ||
| 212 | 209 | int r_opendir(r_dir_t *rdir, const char *dirname) | |
| 213 | 210 | { | |
| 214 | − | if (rdir == NULL || dirname == NULL || *dirname == '\0') | |
| 211 | + | if (*dirname == '\0') | |
| 215 | 212 | return -1; | |
| 216 | 213 | ||
| 217 | 214 | if ((rdir->dir = opendir(dirname)) == NULL) { | |
| @@ -234,9 +231,6 @@ int r_closedir(r_dir_t *rdir) | |||
| 234 | 231 | { | |
| 235 | 232 | int ret = 0; | |
| 236 | 233 | ||
| 237 | − | if (rdir == NULL) | |
| 238 | − | return -1; | |
| 239 | − | ||
| 240 | 234 | if (rdir->stack != NULL) { | |
| 241 | 235 | while (rdir->stlen > 0) | |
| 242 | 236 | free(rdir->stack[--rdir->stlen]); | |
| @@ -264,9 +258,6 @@ char* r_readdir(r_dir_t *rdir) | |||
| 264 | 258 | struct dirent *dentry; | |
| 265 | 259 | struct stat fstats; | |
| 266 | 260 | ||
| 267 | − | if (rdir == NULL || rdir->dir == NULL || rdir->name == NULL) | |
| 268 | − | return NULL; | |
| 269 | − | ||
| 270 | 261 | while (true) { | |
| 271 | 262 | if (rdir->dir != NULL && (dentry = readdir(rdir->dir)) != NULL) { | |
| 272 | 263 | if (dentry->d_name[0] == '.') | |
| @@ -316,7 +307,7 @@ int r_mkdir(const char *path) | |||
| 316 | 307 | struct stat stats; | |
| 317 | 308 | int err = 0; | |
| 318 | 309 | ||
| 319 | − | if (path == NULL || *path == '\0') | |
| 310 | + | if (*path == '\0') | |
| 320 | 311 | return -1; | |
| 321 | 312 | ||
| 322 | 313 | if (stat(path, &stats) == 0) | |
| @@ -94,8 +94,6 @@ unsigned long win_alloc_color(win_t *win, const char *name) | |||
| 94 | 94 | { | |
| 95 | 95 | XColor col; | |
| 96 | 96 | ||
| 97 | − | if (win == NULL) | |
| 98 | − | return 0UL; | |
| 99 | 97 | if (XAllocNamedColor(win->env.dpy, | |
| 100 | 98 | DefaultColormap(win->env.dpy, win->env.scr), | |
| 101 | 99 | name, &col, &col) == 0) | |
| @@ -142,9 +140,6 @@ void win_init(win_t *win) | |||
| 142 | 140 | { | |
| 143 | 141 | win_env_t *e; | |
| 144 | 142 | ||
| 145 | − | if (win == NULL) | |
| 146 | − | return; | |
| 147 | − | ||
| 148 | 143 | memset(win, 0, sizeof(win_t)); | |
| 149 | 144 | ||
| 150 | 145 | e = &win->env; | |
| @@ -199,9 +194,6 @@ void win_open(win_t *win) | |||
| 199 | 194 | XSizeHints sizehints; | |
| 200 | 195 | Bool fullscreen = options->fullscreen && fs_support; | |
| 201 | 196 | ||
| 202 | − | if (win == NULL) | |
| 203 | − | return; | |
| 204 | − | ||
| 205 | 197 | e = &win->env; | |
| 206 | 198 | ||
| 207 | 199 | sizehints.flags = PWinGravity; | |
| @@ -317,9 +309,6 @@ void win_open(win_t *win) | |||
| 317 | 309 | ||
| 318 | 310 | void win_close(win_t *win) | |
| 319 | 311 | { | |
| 320 | − | if (win == NULL || win->xwin == None) | |
| 321 | − | return; | |
| 322 | − | ||
| 323 | 312 | XFreeCursor(win->env.dpy, carrow); | |
| 324 | 313 | XFreeCursor(win->env.dpy, cnone); | |
| 325 | 314 | XFreeCursor(win->env.dpy, chand); | |
| @@ -335,9 +324,6 @@ bool win_configure(win_t *win, XConfigureEvent *c) | |||
| 335 | 324 | { | |
| 336 | 325 | bool changed; | |
| 337 | 326 | ||
| 338 | − | if (win == NULL || c == NULL) | |
| 339 | − | return false; | |
| 340 | − | ||
| 341 | 327 | changed = win->w != c->width || win->h + win->bar.h != c->height; | |
| 342 | 328 | ||
| 343 | 329 | win->x = c->x; | |
| @@ -354,9 +340,6 @@ void win_toggle_fullscreen(win_t *win) | |||
| 354 | 340 | XEvent ev; | |
| 355 | 341 | XClientMessageEvent *cm; | |
| 356 | 342 | ||
| 357 | − | if (win == NULL || win->xwin == None) | |
| 358 | − | return; | |
| 359 | − | ||
| 360 | 343 | if (!fs_support) { | |
| 361 | 344 | if (!fs_warned) { | |
| 362 | 345 | warn("window manager does not support fullscreen"); | |
| @@ -383,9 +366,6 @@ void win_toggle_fullscreen(win_t *win) | |||
| 383 | 366 | ||
| 384 | 367 | void win_toggle_bar(win_t *win) | |
| 385 | 368 | { | |
| 386 | − | if (win == NULL || win->xwin == None) | |
| 387 | − | return; | |
| 388 | − | ||
| 389 | 369 | if (win->bar.h != 0) { | |
| 390 | 370 | win->h += win->bar.h; | |
| 391 | 371 | win->bar.h = 0; | |
| @@ -399,9 +379,6 @@ void win_clear(win_t *win) | |||
| 399 | 379 | { | |
| 400 | 380 | win_env_t *e; | |
| 401 | 381 | ||
| 402 | − | if (win == NULL || win->xwin == None) | |
| 403 | − | return; | |
| 404 | − | ||
| 405 | 382 | e = &win->env; | |
| 406 | 383 | ||
| 407 | 384 | if (win->w > win->buf.w || win->h + win->bar.h > win->buf.h) { | |
| @@ -423,8 +400,6 @@ void win_draw_bar(win_t *win) | |||
| 423 | 400 | win_env_t *e; | |
| 424 | 401 | win_bar_t *l, *r; | |
| 425 | 402 | ||
| 426 | − | if (win == NULL || win->xwin == None) | |
| 427 | − | return; | |
| 428 | 403 | if ((l = &win->bar.l)->buf == NULL || (r = &win->bar.r)->buf == NULL) | |
| 429 | 404 | return; | |
| 430 | 405 | ||
| @@ -473,9 +448,6 @@ void win_draw_bar(win_t *win) | |||
| 473 | 448 | ||
| 474 | 449 | void win_draw(win_t *win) | |
| 475 | 450 | { | |
| 476 | − | if (win == NULL || win->xwin == None) | |
| 477 | − | return; | |
| 478 | − | ||
| 479 | 451 | if (win->bar.h > 0) | |
| 480 | 452 | win_draw_bar(win); | |
| 481 | 453 | ||
| @@ -489,9 +461,6 @@ void win_draw_rect(win_t *win, int x, int y, int w, int h, bool fill, int lw, | |||
| 489 | 461 | { | |
| 490 | 462 | XGCValues gcval; | |
| 491 | 463 | ||
| 492 | − | if (win == NULL || win->buf.pm == None) | |
| 493 | − | return; | |
| 494 | − | ||
| 495 | 464 | gcval.line_width = lw; | |
| 496 | 465 | gcval.foreground = col; | |
| 497 | 466 | XChangeGC(win->env.dpy, gc, GCForeground | GCLineWidth, &gcval); | |
| @@ -517,9 +486,6 @@ int win_textwidth(const char *text, unsigned int len, bool with_padding) | |||
| 517 | 486 | ||
| 518 | 487 | void win_set_title(win_t *win, const char *title) | |
| 519 | 488 | { | |
| 520 | − | if (win == NULL || win->xwin == None) | |
| 521 | − | return; | |
| 522 | − | ||
| 523 | 489 | if (title == NULL) | |
| 524 | 490 | title = "sxiv"; | |
| 525 | 491 | ||
| @@ -536,9 +502,6 @@ void win_set_title(win_t *win, const char *title) | |||
| 536 | 502 | ||
| 537 | 503 | void win_set_cursor(win_t *win, cursor_t cursor) | |
| 538 | 504 | { | |
| 539 | − | if (win == NULL || win->xwin == None) | |
| 540 | − | return; | |
| 541 | − | ||
| 542 | 505 | switch (cursor) { | |
| 543 | 506 | case CURSOR_NONE: | |
| 544 | 507 | XDefineCursor(win->env.dpy, win->xwin, cnone); | |