Text  |   XML   |   Visible Warnings:

Irssi : Irssi analysis 1 : Ignored Return Value  at lastlog.c:205

Categories: LANG.FUNCS.IRV CWE:252 CWE:253 POW10:7
Warning ID: 2400.2414
Similar Warnings: 2400.2415
Procedure: show_lastlog
Trace: View
Modified: Wed Sep 2 12:25:23 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
LineSource
  /u1/paul/SATE/2010/c/irssi/irssi-0.8.14/src/fe-text/lastlog.c
  Enter show_lastlog
77 static void show_lastlog(const char *searchtext, GHashTable *optlist,
78                          int start, int count, FILE *fhandle) 
79 {
80         WINDOW_REC *window;
81         LINE_REC *startline;
82         GList *list, *tmp;
83         GString *line;
84         char *str;
85         int level, before, after, len;
86  
87         level = cmd_options_get_level("lastlog", optlist);
88         if (level == -1) return; /* error in options */ 
89         if (level == 0) level = MSGLEVEL_ALL;
90  
91         if (g_hash_table_lookup(optlist, "clear") != NULL) {
92                 textbuffer_view_remove_lines_by_level(WINDOW_GUI(active_win)->view, MSGLEVEL_LASTLOG);
93                 if (*searchtext == '\0')
94                         return;
95         }
96  
97         /* which window's lastlog to look at? */ 
98         window = active_win;
99         str = g_hash_table_lookup(optlist, "window");
100         if (str != NULL) {
101                 window = is_numeric(str, '\0') ? 
102                         window_find_refnum(atoi(str)) : 
103                         window_find_item(NULL, str);
104                 if (window == NULL) {
105                         printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
106                                     TXT_REFNUM_NOT_FOUND, str);
107                         return;
108                 }
109         }
110  
111         if (g_hash_table_lookup(optlist, "new") != NULL)
112                 startline = textbuffer_view_get_bookmark(WINDOW_GUI(window)->view, "lastlog_last_check");
113         else if (g_hash_table_lookup(optlist, "away") != NULL)
114                 startline = textbuffer_view_get_bookmark(WINDOW_GUI(window)->view, "lastlog_last_away");
115         else 
116                 startline = NULL;
117  
118         if (startline == NULL)
119                 startline = textbuffer_view_get_lines(WINDOW_GUI(window)->view);
120  
121         str = g_hash_table_lookup(optlist, "#");
122         if (str != NULL) {
123                 before = after = atoi(str);
124         } else {
125                 str = g_hash_table_lookup(optlist, "before");
126                 before = str == NULL ? 0 : *str != '\0' ? 
127                         atoi(str) : DEFAULT_LASTLOG_BEFORE;
128  
129                 str = g_hash_table_lookup(optlist, "after");
130                 if (str == NULL) str = g_hash_table_lookup(optlist, "a");
131                 after = str == NULL ? 0 : *str != '\0' ? 
132                         atoi(str) : DEFAULT_LASTLOG_AFTER;
133         }
134  
135         list = textbuffer_find_text(WINDOW_GUI(window)->view->buffer, startline,
136                                     level, MSGLEVEL_LASTLOG,
137                                     searchtext, before, after,
138                                     g_hash_table_lookup(optlist, "regexp") != NULL,
139                                     g_hash_table_lookup(optlist, "word") != NULL,
140                                     g_hash_table_lookup(optlist, "case") != NULL);
141  
142         len = g_list_length(list);
143         if (count <= 0)
144                 tmp = list;
145         else {
146                 int pos = len-count-start;
147                 if (pos < 0) pos = 0;
148  
149                 tmp = pos > len ? NULL : g_list_nth(list, pos);
150                 len = g_list_length(tmp);
151         }
152  
153         if (g_hash_table_lookup(optlist, "count") != NULL) {
154                 printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
155                                    TXT_LASTLOG_COUNT, len);
156                 g_list_free(list);
157                 return;
158         }
159  
160         if (len > MAX_LINES_WITHOUT_FORCE && fhandle == NULL &&
161             g_hash_table_lookup(optlist, "force") == NULL) {
162                 printformat_window(active_win,
163                                    MSGLEVEL_CLIENTNOTICE|MSGLEVEL_LASTLOG,
164                                    TXT_LASTLOG_TOO_LONG, len);
165                 g_list_free(list);
166                 return;
167         }
168  
169         if (fhandle == NULL && g_hash_table_lookup(optlist, "-") == NULL)
170                 printformat(NULL, NULL, MSGLEVEL_LASTLOG, TXT_LASTLOG_START);
171  
172         line = g_string_new(NULL);
173         while (tmp != NULL && (count < 0 || count > 0)) {
174                 LINE_REC *rec = tmp->data;
175  
176                 if (rec == NULL) {
177                         if (tmp->next == NULL)
178                                 break;
179                         if (fhandle != NULL) {
180                                 fwrite("--\n", 3, 1, fhandle);
181                         } else {
182                                 printformat_window(active_win,
183                                                    MSGLEVEL_LASTLOG,
184                                                    TXT_LASTLOG_SEPARATOR);
185                         }
186                         tmp = tmp->next;
187                         continue;
188                 }
189  
190                 /* get the line text */ 
191                 textbuffer_line2text(rec, fhandle == NULL, line);
192                 if (!settings_get_bool("timestamps")) {
193                         struct tm *tm = localtime(&rec->info.time);
194                         char timestamp[10];
195  
196                         g_snprintf(timestamp, sizeof(timestamp),
197                                    "%02d:%02d ",
198                                    tm->tm_hour, tm->tm_min);
199                         g_string_prepend(line, timestamp);
200                 }
201  
202                 /* write to file/window */ 
203                 if (fhandle != NULL) {
204                         fwrite(line->str, line->len, 1, fhandle);   /* Ignored Return Value (ID: 2400.2415) */
205                         fputc('\n', fhandle);     /* Ignored Return Value */
206                 } else {
207                         printtext_window(active_win, MSGLEVEL_LASTLOG,
208                                          "%s", line->str);
209                 }
210  
211                 count--;
212                 tmp = tmp->next;
213         }
214         g_string_free(line, TRUE);
215  
216         if (fhandle == NULL && g_hash_table_lookup(optlist, "-") == NULL)
217                 printformat(NULL, NULL, MSGLEVEL_LASTLOG, TXT_LASTLOG_END);
218  
219         textbuffer_view_set_bookmark_bottom(WINDOW_GUI(window)->view,
220                                             "lastlog_last_check");
221  
222         g_list_free(list);
223 } 




Change Warning 2400.2414 : Ignored Return Value

Because they are very similar, this warning shares annotations with warning 2400.2415.

Priority:
State:
Finding:
Owner:
Note: