comparison src/channel.c @ 17974:9fb236d0f386 v8.1.1983

patch 8.1.1983: compiler nags for uninitialized variable and unused function Commit: https://github.com/vim/vim/commit/ea781459b9617aa47335061fcc78403495260315 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 4 18:53:12 2019 +0200 patch 8.1.1983: compiler nags for uninitialized variable and unused function Problem: Compiler nags for uninitialized variable and unused function. Solution: Add unnecessary initialization. Move function inside #ifdef.
author Bram Moolenaar <Bram@vim.org>
date Wed, 04 Sep 2019 19:00:03 +0200
parents 0f7ae8010787
children cf8e0c7e0cb9
comparison
equal deleted inserted replaced
17973:c76b0cb3fa3a 17974:9fb236d0f386
53 # define fd_write(sd, buf, len) write(sd, buf, len) 53 # define fd_write(sd, buf, len) write(sd, buf, len)
54 # define fd_close(sd) close(sd) 54 # define fd_close(sd) close(sd)
55 #endif 55 #endif
56 56
57 static void channel_read(channel_T *channel, ch_part_T part, char *func); 57 static void channel_read(channel_T *channel, ch_part_T part, char *func);
58 # if defined(MSWIN) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
59 static channel_T *channel_fd2channel(sock_T fd, ch_part_T *partp);
60 # endif
61 static ch_mode_T channel_get_mode(channel_T *channel, ch_part_T part); 58 static ch_mode_T channel_get_mode(channel_T *channel, ch_part_T part);
62 static int channel_get_timeout(channel_T *channel, ch_part_T part); 59 static int channel_get_timeout(channel_T *channel, ch_part_T part);
63 static ch_part_T channel_part_send(channel_T *channel); 60 static ch_part_T channel_part_send(channel_T *channel);
64 static ch_part_T channel_part_read(channel_T *channel); 61 static ch_part_T channel_part_read(channel_T *channel);
65 static void free_job_options(jobopt_T *opt); 62 static void free_job_options(jobopt_T *opt);
503 } 500 }
504 } 501 }
505 502
506 #if defined(FEAT_GUI) || defined(PROTO) 503 #if defined(FEAT_GUI) || defined(PROTO)
507 504
508 #if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) 505 # if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
506 /*
507 * Lookup the channel from the socket. Set "partp" to the fd index.
508 * Returns NULL when the socket isn't found.
509 */
510 static channel_T *
511 channel_fd2channel(sock_T fd, ch_part_T *partp)
512 {
513 channel_T *channel;
514 ch_part_T part;
515
516 if (fd != INVALID_FD)
517 for (channel = first_channel; channel != NULL;
518 channel = channel->ch_next)
519 {
520 for (part = PART_SOCK; part < PART_IN; ++part)
521 if (channel->ch_part[part].ch_fd == fd)
522 {
523 *partp = part;
524 return channel;
525 }
526 }
527 return NULL;
528 }
529
509 static void 530 static void
510 channel_read_fd(int fd) 531 channel_read_fd(int fd)
511 { 532 {
512 channel_T *channel; 533 channel_T *channel;
513 ch_part_T part; 534 ch_part_T part;
516 if (channel == NULL) 537 if (channel == NULL)
517 ch_error(NULL, "Channel for fd %d not found", fd); 538 ch_error(NULL, "Channel for fd %d not found", fd);
518 else 539 else
519 channel_read(channel, part, "channel_read_fd"); 540 channel_read(channel, part, "channel_read_fd");
520 } 541 }
521 #endif 542 # endif
522 543
523 /* 544 /*
524 * Read a command from netbeans. 545 * Read a command from netbeans.
525 */ 546 */
526 #ifdef FEAT_GUI_X11 547 # ifdef FEAT_GUI_X11
527 static void 548 static void
528 messageFromServerX11(XtPointer clientData, 549 messageFromServerX11(XtPointer clientData,
529 int *unused1 UNUSED, 550 int *unused1 UNUSED,
530 XtInputId *unused2 UNUSED) 551 XtInputId *unused2 UNUSED)
531 { 552 {
532 channel_read_fd((int)(long)clientData); 553 channel_read_fd((int)(long)clientData);
533 } 554 }
534 #endif 555 # endif
535 556
536 #ifdef FEAT_GUI_GTK 557 # ifdef FEAT_GUI_GTK
537 # if GTK_CHECK_VERSION(3,0,0) 558 # if GTK_CHECK_VERSION(3,0,0)
538 static gboolean 559 static gboolean
539 messageFromServerGtk3(GIOChannel *unused1 UNUSED, 560 messageFromServerGtk3(GIOChannel *unused1 UNUSED,
540 GIOCondition unused2 UNUSED, 561 GIOCondition unused2 UNUSED,
541 gpointer clientData) 562 gpointer clientData)
542 { 563 {
543 channel_read_fd(GPOINTER_TO_INT(clientData)); 564 channel_read_fd(GPOINTER_TO_INT(clientData));
544 return TRUE; /* Return FALSE instead in case the event source is to 565 return TRUE; /* Return FALSE instead in case the event source is to
545 * be removed after this function returns. */ 566 * be removed after this function returns. */
546 } 567 }
547 # else 568 # else
548 static void 569 static void
549 messageFromServerGtk2(gpointer clientData, 570 messageFromServerGtk2(gpointer clientData,
550 gint unused1 UNUSED, 571 gint unused1 UNUSED,
551 GdkInputCondition unused2 UNUSED) 572 GdkInputCondition unused2 UNUSED)
552 { 573 {
553 channel_read_fd((int)(long)clientData); 574 channel_read_fd((int)(long)clientData);
554 } 575 }
576 # endif
555 # endif 577 # endif
556 #endif
557 578
558 static void 579 static void
559 channel_gui_register_one(channel_T *channel, ch_part_T part) 580 channel_gui_register_one(channel_T *channel, ch_part_T part)
560 { 581 {
561 if (!CH_HAS_GUI) 582 if (!CH_HAS_GUI)
672 693
673 for (part = PART_SOCK; part < PART_IN; ++part) 694 for (part = PART_SOCK; part < PART_IN; ++part)
674 channel_gui_unregister_one(channel, part); 695 channel_gui_unregister_one(channel, part);
675 } 696 }
676 697
677 #endif 698 #endif // FEAT_GUI
678 699
679 static char *e_cannot_connect = N_("E902: Cannot connect to port"); 700 static char *e_cannot_connect = N_("E902: Cannot connect to port");
680 701
681 /* 702 /*
682 * Open a socket channel to "hostname":"port". 703 * Open a socket channel to "hostname":"port".
3761 } 3782 }
3762 3783
3763 theend: 3784 theend:
3764 free_job_options(&opt); 3785 free_job_options(&opt);
3765 } 3786 }
3766
3767 # if defined(MSWIN) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \
3768 || defined(PROTO)
3769 /*
3770 * Lookup the channel from the socket. Set "partp" to the fd index.
3771 * Returns NULL when the socket isn't found.
3772 */
3773 static channel_T *
3774 channel_fd2channel(sock_T fd, ch_part_T *partp)
3775 {
3776 channel_T *channel;
3777 ch_part_T part;
3778
3779 if (fd != INVALID_FD)
3780 for (channel = first_channel; channel != NULL;
3781 channel = channel->ch_next)
3782 {
3783 for (part = PART_SOCK; part < PART_IN; ++part)
3784 if (channel->ch_part[part].ch_fd == fd)
3785 {
3786 *partp = part;
3787 return channel;
3788 }
3789 }
3790 return NULL;
3791 }
3792 # endif
3793 3787
3794 # if defined(MSWIN) || defined(FEAT_GUI) || defined(PROTO) 3788 # if defined(MSWIN) || defined(FEAT_GUI) || defined(PROTO)
3795 /* 3789 /*
3796 * Check the channels for anything that is ready to be read. 3790 * Check the channels for anything that is ready to be read.
3797 * The data is put in the read queue. 3791 * The data is put in the read queue.