File: | perl/perl-sources.c |
Location: | line 80, column 2 |
Description: | Value stored to 'retcount' is never read |
1 | /* |
2 | perl-sources.c : irssi |
3 | |
4 | Copyright (C) 1999-2001 Timo Sirainen |
5 | |
6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. |
10 | |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License along |
17 | with this program; if not, write to the Free Software Foundation, Inc., |
18 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ |
20 | |
21 | #define NEED_PERL_H |
22 | #include "module.h" |
23 | #include "signals.h" |
24 | |
25 | #include "perl-core.h" |
26 | #include "perl-common.h" |
27 | #include "perl-sources.h" |
28 | |
29 | typedef struct { |
30 | PERL_SCRIPT_REC *script; |
31 | int tag; |
32 | int refcount; |
33 | int once; /* run only once */ |
34 | |
35 | SV *func; |
36 | SV *data; |
37 | } PERL_SOURCE_REC; |
38 | |
39 | static GSList *perl_sources; |
40 | |
41 | static void perl_source_ref(PERL_SOURCE_REC *rec) |
42 | { |
43 | rec->refcount++; |
44 | } |
45 | |
46 | static int perl_source_unref(PERL_SOURCE_REC *rec) |
47 | { |
48 | if (--rec->refcount != 0) |
49 | return TRUE(1); |
50 | |
51 | SvREFCNT_dec(rec->data)Perl_sv_free((SV*)(rec->data)); |
52 | SvREFCNT_dec(rec->func)Perl_sv_free((SV*)(rec->func)); |
53 | g_free(rec); |
54 | return FALSE(0); |
55 | } |
56 | |
57 | static void perl_source_destroy(PERL_SOURCE_REC *rec) |
58 | { |
59 | perl_sources = g_slist_remove(perl_sources, rec); |
60 | |
61 | g_source_remove(rec->tag); |
62 | rec->tag = -1; |
63 | |
64 | perl_source_unref(rec); |
65 | } |
66 | |
67 | static int perl_source_event(PERL_SOURCE_REC *rec) |
68 | { |
69 | dSPSV **sp = PL_stack_sp; |
70 | int retcount; |
71 | |
72 | ENTERPerl_push_scope(); |
73 | SAVETMPSPerl_save_int((int*)&PL_tmps_floor), PL_tmps_floor = PL_tmps_ix; |
74 | |
75 | PUSHMARK(SP)(void)( { if (++PL_markstack_ptr == PL_markstack_max) Perl_markstack_grow (); *PL_markstack_ptr = (I32)((sp) - PL_stack_base); } ); |
76 | XPUSHs(sv_mortalcopy(rec->data))(void)( { (void)( { if (PL_stack_max - sp < (int)(1)) { sp = Perl_stack_grow(sp,sp, (int) (1)); } } ); (*++sp = (Perl_sv_mortalcopy (rec->data))); } ); |
77 | PUTBACKPL_stack_sp = sp; |
78 | |
79 | perl_source_ref(rec); |
80 | retcount = perl_call_sv(rec->func, G_EVAL|G_SCALAR)Perl_call_sv(rec->func,4|0); |
Value stored to 'retcount' is never read | |
81 | SPAGAINsp = PL_stack_sp; |
82 | |
83 | if (SvTRUE(ERRSV)( !((((XPVGV*)(PL_errgv)->sv_any)->xgv_gp)->gp_sv) ? 0 : ((((((XPVGV*)(PL_errgv)->sv_any)->xgv_gp)->gp_sv ))->sv_flags & 0x00040000) ? (({XPV *nxpv = (XPV*)(((( (XPVGV*)(PL_errgv)->sv_any)->xgv_gp)->gp_sv))->sv_any ; nxpv && (nxpv->xpv_cur > 1 || (nxpv->xpv_cur && *nxpv->xpv_pv != '0')); }) ? 1 : 0) : ((((((XPVGV *)(PL_errgv)->sv_any)->xgv_gp)->gp_sv))->sv_flags & 0x00010000) ? ((XPVIV*) (((((XPVGV*)(PL_errgv)->sv_any )->xgv_gp)->gp_sv))->sv_any)->xiv_iv != 0 : ((((( (XPVGV*)(PL_errgv)->sv_any)->xgv_gp)->gp_sv))->sv_flags & 0x00020000) ? ((XPVNV*)(((((XPVGV*)(PL_errgv)->sv_any )->xgv_gp)->gp_sv))->sv_any)->xnv_nv != 0.0 : Perl_sv_2bool (((((XPVGV*)(PL_errgv)->sv_any)->xgv_gp)->gp_sv)) )) { |
84 | char *error = g_strdup(SvPV(ERRSV, PL_na)(((((((XPVGV*)(PL_errgv)->sv_any)->xgv_gp)->gp_sv))-> sv_flags & (0x00040000)) == 0x00040000 ? ((PL_na = ((XPV* ) (((((XPVGV*)(PL_errgv)->sv_any)->xgv_gp)->gp_sv))-> sv_any)->xpv_cur), ((XPV*) (((((XPVGV*)(PL_errgv)->sv_any )->xgv_gp)->gp_sv))->sv_any)->xpv_pv) : Perl_sv_2pv_flags (((((XPVGV*)(PL_errgv)->sv_any)->xgv_gp)->gp_sv), & PL_na, 2))); |
85 | signal_emit("script error", 2, rec->script, error); |
86 | g_free(error); |
87 | } |
88 | |
89 | if (perl_source_unref(rec) && rec->once) |
90 | perl_source_destroy(rec); |
91 | |
92 | PUTBACKPL_stack_sp = sp; |
93 | FREETMPSif (PL_tmps_ix > PL_tmps_floor) Perl_free_tmps(); |
94 | LEAVEPerl_pop_scope(); |
95 | |
96 | return 1; |
97 | } |
98 | |
99 | int perl_timeout_add(int msecs, SV *func, SV *data, int once) |
100 | { |
101 | PERL_SCRIPT_REC *script; |
102 | PERL_SOURCE_REC *rec; |
103 | const char *pkg; |
104 | |
105 | pkg = perl_get_package(); |
106 | script = perl_script_find_package(pkg); |
107 | g_return_val_if_fail(script != NULL, -1)do{ if (script != ((void *)0)) { } else { g_return_if_fail_warning (((gchar*) 0), __PRETTY_FUNCTION__, "script != NULL"); return (-1); }; }while (0); |
108 | |
109 | rec = g_new0(PERL_SOURCE_REC, 1)((PERL_SOURCE_REC *) g_malloc0 (((gsize) sizeof (PERL_SOURCE_REC )) * ((gsize) (1)))); |
110 | perl_source_ref(rec); |
111 | |
112 | rec->once = once; |
113 | rec->script = script; |
114 | rec->func = perl_func_sv_inc(func, pkg); |
115 | rec->data = SvREFCNT_inc(data)({ SV * const _sv = (SV*)(data); if (_sv) (++(_sv)->sv_refcnt ); _sv; }); |
116 | rec->tag = g_timeout_add(msecs, (GSourceFunc) perl_source_event, rec); |
117 | |
118 | perl_sources = g_slist_append(perl_sources, rec); |
119 | return rec->tag; |
120 | } |
121 | |
122 | int perl_input_add(int source, int condition, SV *func, SV *data, int once) |
123 | { |
124 | PERL_SCRIPT_REC *script; |
125 | PERL_SOURCE_REC *rec; |
126 | const char *pkg; |
127 | |
128 | pkg = perl_get_package(); |
129 | script = perl_script_find_package(pkg); |
130 | g_return_val_if_fail(script != NULL, -1)do{ if (script != ((void *)0)) { } else { g_return_if_fail_warning (((gchar*) 0), __PRETTY_FUNCTION__, "script != NULL"); return (-1); }; }while (0); |
131 | |
132 | rec = g_new0(PERL_SOURCE_REC, 1)((PERL_SOURCE_REC *) g_malloc0 (((gsize) sizeof (PERL_SOURCE_REC )) * ((gsize) (1)))); |
133 | perl_source_ref(rec); |
134 | |
135 | rec->once = once; |
136 | rec->script =script; |
137 | rec->func = perl_func_sv_inc(func, pkg); |
138 | rec->data = SvREFCNT_inc(data)({ SV * const _sv = (SV*)(data); if (_sv) (++(_sv)->sv_refcnt ); _sv; }); |
139 | |
140 | rec->tag = g_input_add_poll(source, G_PRIORITY_DEFAULT0, condition, |
141 | (GInputFunction) perl_source_event, rec); |
142 | |
143 | perl_sources = g_slist_append(perl_sources, rec); |
144 | return rec->tag; |
145 | } |
146 | |
147 | void perl_source_remove(int tag) |
148 | { |
149 | GSList *tmp; |
150 | |
151 | for (tmp = perl_sources; tmp != NULL((void *)0); tmp = tmp->next) { |
152 | PERL_SOURCE_REC *rec = tmp->data; |
153 | |
154 | if (rec->tag == tag) { |
155 | perl_source_destroy(rec); |
156 | break; |
157 | } |
158 | } |
159 | } |
160 | |
161 | void perl_source_remove_script(PERL_SCRIPT_REC *script) |
162 | { |
163 | GSList *tmp, *next; |
164 | |
165 | for (tmp = perl_sources; tmp != NULL((void *)0); tmp = next) { |
166 | PERL_SOURCE_REC *rec = tmp->data; |
167 | |
168 | next = tmp->next; |
169 | if (rec->script == script) |
170 | perl_source_destroy(rec); |
171 | } |
172 | } |
173 | |
174 | void perl_sources_start(void) |
175 | { |
176 | perl_sources = NULL((void *)0); |
177 | } |
178 | |
179 | void perl_sources_stop(void) |
180 | { |
181 | /* timeouts and input waits */ |
182 | while (perl_sources != NULL((void *)0)) |
183 | perl_source_destroy(perl_sources->data); |
184 | } |