links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 156e54ea6e3f7ac56e7aacf0df93e983b129e0e3
Parent: bd246f1665862bdececb920997da27127fac6845
Author: opask
Date:   Fri, 20 Jul 2018 19:30:28 -0600

cleanup empty functions, update TODO

Diffstat:
MTODO | 2++
Mbfu.c | 14+++++---------
Mcache.c | 3+--
Mcharsets.c | 2+-
Mconnect.c | 2--
Mdip.c | 42++++++++----------------------------------
Mdither.c | 15+++++++--------
Merror.c | 3---
Mfbcommon.inc | 6++----
Mhtml_r.c | 17++++++-----------
Mhttps.c | 11-----------
Mimg.c | 13+++----------
Mjpeg.c | 2+-
Mlinks.h | 20--------------------
Mmain.c | 1-
Mmemory.c | 2--
Mmenu.c | 9+++------
Mos_dep.c | 3+--
Mos_depx.h | 20--------------------
19 files changed, 40 insertions(+), 147 deletions(-)

diff --git a/TODO b/TODO @@ -39,3 +39,5 @@ - other error mechanisms should be replaced with die() - fix command-line flag handling + +- remove if (x) free(x), it only guards against free(NULL) which is a no-op diff --git a/bfu.c b/bfu.c @@ -626,9 +626,7 @@ void do_mainmenu(struct terminal *term, struct menu_item *items, void *data, int menu->hotkeys[i] = select_hotkey(term, NULL, items[i].hotkey, menu->hotkeys, i); add_window(term, mainmenu_func, menu); if (sel != -1) { - /* icc_volatile is workaround for some weird bug in icc or linker, - it results in unaligned sse load */ - icc_volatile struct links_event ev = {EV_KBD, KBD_ENTER, 0, 0}; + struct links_event ev = {EV_KBD, KBD_ENTER, 0, 0}; struct window *win = list_struct(term->windows.next, struct window); win->handler(win, (struct links_event *)&ev, 0); } @@ -1247,8 +1245,7 @@ void dialog_func(struct window *win, struct links_event *ev, int fwd) switch ((int)ev->ev) { case EV_INIT: for (i = 0; i < dlg->n; i++) { - /* highc_volatile because of a compiler bug */ - struct dialog_item_data * highc_volatile di = &dlg->items[i]; + struct dialog_item_data *di = &dlg->items[i]; memset(di, 0, sizeof(struct dialog_item_data)); di->item = &dlg->dlg->items[i]; di->cdata = xmalloc(di->item->dlen); @@ -1649,10 +1646,9 @@ void get_dialog_data(struct dialog_data *dlg) { int i; for (i = 0; i < dlg->n; i++) { - /* highc_volatile because of a compiler bug */ - void * highc_volatile p1 = dlg->dlg->items[i].data; - void * highc_volatile p2 = dlg->items[i].cdata; - highc_volatile int l = dlg->dlg->items[i].dlen; + void *p1 = dlg->dlg->items[i].data; + void *p2 = dlg->items[i].cdata; + int l = dlg->dlg->items[i].dlen; if (l) memcpy(p1, p2, l); } diff --git a/cache.c b/cache.c @@ -211,7 +211,6 @@ static void mem_free_fragment(struct fragment *f) size_t s = (size_t)f->length; mem_free(f); s += sizeof(struct fragment); - mem_freed_large(s); } #define sf(x) e->data_size += (x), cache_size += (my_uintptr_t)(x) @@ -226,7 +225,7 @@ int add_fragment(struct cache_entry *e, off_t offset, const unsigned char *data, struct list_head *lf; struct fragment *nf; int trunc = 0; - icc_volatile off_t ca; + off_t ca; if (!length) return 0; free_decompressed_data(e); e->incomplete = 1; diff --git a/charsets.c b/charsets.c @@ -456,7 +456,7 @@ need_table: int get_cp_index(unsigned char *n) { - decc_volatile int i, a, p, q, sl, ii = -1, ll = 0; + int i, a, p, q, sl, ii = -1, ll = 0; for (i = 0; codepages[i].name; i++) { for (a = 0; codepages[i].aliases[a]; a++) { for (p = 0; n[p]; p++) { diff --git a/connect.c b/connect.c @@ -727,7 +727,6 @@ static void connected(void *c_) mem_free(h); goto ssl_error; } -#ifdef SSL_SESSION_RESUME if (!proxies.only_proxies && !c->no_ssl_session) { unsigned char *h = get_host_name(orig_url); int p = get_port(orig_url); @@ -738,7 +737,6 @@ static void connected(void *c_) } mem_free(h); } -#endif #if !defined(OPENSSL_NO_STDIO) if (!proxies.only_proxies) { if (ssl_options.client_cert_key[0]) { diff --git a/dip.c b/dip.c @@ -247,7 +247,7 @@ static void emit_and_bias_col_color(scale_t *restrict col_buf, static void emit_and_bias_row_color(scale_t *restrict row_buf, unsigned short *restrict out, int n, unsigned weight) { - scale_t half=(scale_t)weight / 2; + scale_t half = (scale_t)weight / 2; scale_t inv_weight = (scale_t)1 / weight; for (;n;n--){ out[0]=(unsigned short)op(row_buf[0]); @@ -916,11 +916,8 @@ void scale_color(unsigned short *in, int ix, int iy, unsigned short **out, scale_color_horizontal(in,ix,iy,&intermediate_buffer,ox); scale_color_vertical(intermediate_buffer,ox,iy,out,oy); } - if (do_optimize) decimate_3(out, ox0, oy); - mem_freed_large( - 3 * sizeof(short) * ix * iy > 3 * sizeof(short) * ox * oy ? - 3 * sizeof(short) * ix * iy : 3 * sizeof(short) * ox * oy - ); + if (do_optimize) + decimate_3(out, ox0, oy); } /* Fills a block with given color. length is number of pixels. pixel is a @@ -1054,10 +1051,7 @@ void agx_and_uc_32_to_48(unsigned short *restrict dest, ri=(unsigned)((r*65535)+(float_double)0.5); gi=(unsigned)((g*65535)+(float_double)0.5); bi=(unsigned)((b*65535)+(float_double)0.5); - cmd_limit_16(ri); - cmd_limit_16(gi); - cmd_limit_16(bi); - if (((alpha+1)&255)>=2){ + if (((alpha + 1) & 255) >= 2) { calpha=255-alpha; dest[0]=(unsigned short)((ri*alpha+calpha*rb+127U)/255U); dest[1]=(unsigned short)((gi*alpha+calpha*gb+127U)/255U); @@ -1108,10 +1102,7 @@ void agx_and_uc_64_to_48(unsigned short *restrict dest, ri=(unsigned short)(r*65535+(float_double)0.5); gi=(unsigned short)(g*65535+(float_double)0.5); bi=(unsigned short)(b*65535+(float_double)0.5); - cmd_limit_16(ri); - cmd_limit_16(gi); - cmd_limit_16(bi); - if (((alpha+1)&65535)>=2){ + if (((alpha + 1) & 65535) >= 2) { calpha=65535-alpha; dest[0]=(unsigned short)((ri*alpha+calpha*rb+32767U)/65535U); dest[1]=(unsigned short)((gi*alpha+calpha*gb+32767U)/65535U); @@ -1187,17 +1178,14 @@ void agx_48_to_48(unsigned short *restrict dest, a*=inv_65535; a=fd_pow(a,red_gamma); dest[0]=(unsigned short)((a*65535)+(float_double)0.5); - cmd_limit_16(dest[0]); a=src[1]; a*=inv_65535; a=fd_pow(a,green_gamma); dest[1]=(unsigned short)((a*65535)+(float_double)0.5); - cmd_limit_16(dest[1]); a=src[2]; a*=inv_65535; a=fd_pow(a,blue_gamma); dest[2]=(unsigned short)((a*65535)+(float_double)0.5); - cmd_limit_16(dest[2]); } } @@ -1233,17 +1221,14 @@ void agx_24_to_48(unsigned short *restrict dest, const unsigned char *restrict s a*=inv_255; a=fd_pow(a,red_gamma); dest[0]=(unsigned short)((a*65535)+(float_double)0.5); - cmd_limit_16(dest[0]); a=src[1]; a*=inv_255; a=fd_pow(a,green_gamma); dest[1]=(unsigned short)((a*65535)+(float_double)0.5); - cmd_limit_16(dest[1]); a=src[2]; a*=inv_255; a=fd_pow(a,blue_gamma); dest[2]=(unsigned short)((a*65535)+(float_double)0.5); - cmd_limit_16(dest[2]); } } @@ -1267,17 +1252,14 @@ void make_gamma_table(struct cached_image *cimg) cimg->gamma_table=ptr_16; for (a=0;a<256;a++,ptr_16++){ last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_255,rg)+(float_double)0.5); - cmd_limit_16(last_val); *ptr_16 = last_val; } for (a=0;a<256;a++,ptr_16++){ last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_255,gg)+(float_double)0.5); - cmd_limit_16(last_val); *ptr_16 = last_val; } for (a=0;a<256;a++,ptr_16++){ last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_255,bg)+(float_double)0.5); - cmd_limit_16(last_val); *ptr_16 = last_val; } }else{ @@ -1291,24 +1273,18 @@ void make_gamma_table(struct cached_image *cimg) ptr_16 = xmalloc(196608 * sizeof(*(cimg->gamma_table))); cimg->gamma_table=ptr_16; for (a=0;a<0x10000;a++,ptr_16++){ - if (!x_slow_fpu || !(a & 0xff)) { + if (!x_slow_fpu || !(a & 0xff)) last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_65535,rg)+(float_double)0.5); - cmd_limit_16(last_val); - } *ptr_16 = last_val; } for (a=0;a<0x10000;a++,ptr_16++){ - if (!x_slow_fpu || !(a & 0xff)) { + if (!x_slow_fpu || !(a & 0xff)) last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_65535,gg)+(float_double)0.5); - cmd_limit_16(last_val); - } *ptr_16 = last_val; } for (a=0;a<0x10000;a++,ptr_16++){ - if (!x_slow_fpu || !(a & 0xff)) { + if (!x_slow_fpu || !(a & 0xff)) last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_65535,bg)+(float_double)0.5); - cmd_limit_16(last_val); - } *ptr_16 = last_val; } } @@ -1347,7 +1323,6 @@ unsigned short ags_8_to_16(unsigned char input, float gamma) a=fd_pow(a,gamma); a*=65535; retval = (unsigned short)(a+(float_double)0.5); - cmd_limit_16(retval); return retval; } @@ -1366,7 +1341,6 @@ unsigned short ags_16_to_16(unsigned short input, float gamma) const float_double inv_65535=(float_double)(1/65535.); retval = (unsigned short)(65535*fd_pow((float_double)input*inv_65535,gamma)+(float_double)0.5); - cmd_limit_16(retval); return retval; } diff --git a/dither.c b/dither.c @@ -267,9 +267,9 @@ int slow_fpu = -1; if (table_16) {\ for (y=out->y;y;y--){\ for (x=out->x;x;x--){\ - rt=red_table[limit_16(in[0])];\ - gt=green_table[limit_16(in[1])];\ - bt=blue_table[limit_16(in[2])];\ + rt = red_table[in[0]];\ + gt = green_table[in[1]];\ + bt = blue_table[in[2]];\ in+=3;\ SAVE_CODE\ }\ @@ -278,9 +278,9 @@ int slow_fpu = -1; } else {\ for (y=out->y;y;y--){\ for (x=out->x;x;x--){\ - rt=red_table[limit_16(in[0]) >> 8];\ - gt=green_table[limit_16(in[1]) >> 8];\ - bt=blue_table[limit_16(in[2]) >> 8];\ + rt = red_table[in[0] >> 8];\ + gt = green_table[in[1] >> 8];\ + bt = blue_table[in[2] >> 8];\ in+=3;\ SAVE_CODE\ }\ @@ -807,8 +807,7 @@ void dither_restart(unsigned short *in, struct bitmap *out, int *dregs) static void make_round_tables(void) { int a; - /* ICC bug */ - icc_volatile unsigned short v; + unsigned short v; for (a=0;a<256;a++){ /* a is sRGB coordinate */ diff --git a/error.c b/error.c @@ -110,7 +110,6 @@ void debug_msg(char *m, ...) void *mem_calloc_(size_t size, int mayfail) { void *p; - dos_poll_break(); debug_test_free(NULL, 0); if (!size) return DUMMY; retry: @@ -123,7 +122,6 @@ void *mem_calloc_(size_t size, int mayfail) void mem_free(void *p) { - dos_poll_break(); if (p == DUMMY) return; if (!p) { internal("mem_free(NULL)"); @@ -136,7 +134,6 @@ void *mem_realloc_(void *p, size_t size, int mayfail) { void *np; if (p == DUMMY) return xmalloc(size); - dos_poll_break(); debug_test_free(NULL, 0); if (!p) { internal("mem_realloc(NULL, %lu)", (unsigned long)size); diff --git a/fbcommon.inc b/fbcommon.inc @@ -22,8 +22,7 @@ static inline void pixel_set(unsigned char *dest, int n,void * pattern) case 2: { unsigned short v=*(unsigned short *)do_not_optimize_here(pattern); - /* ICC has an optimization bug here */ - icc_volatile int a; + int a; if ((v & 255) == ((v >> 8) & 255)) { memset(dest, v, n); @@ -70,8 +69,7 @@ static inline void pixel_set(unsigned char *dest, int n,void * pattern) memset(dest, ((unsigned char *)pattern)[1], n); } else { unsigned v=*(unsigned *)do_not_optimize_here(pattern); - /* ICC has an optimization bug here */ - icc_volatile int a; + int a; { unsigned long vv = ((unsigned long)v << 32) | v; diff --git a/html_r.c b/html_r.c @@ -95,18 +95,13 @@ static void clear_formatted(struct f_data *scr) int y; struct form_control *fc; struct list_head *lfc; - if (!scr) return; + if (!scr) + return; - if (scr->search_chr) { - mem_free(scr->search_chr); - mem_freed_large(scr->nsearch_chr * sizeof(char_t)); - } - if (scr->search_pos) { - mem_free(scr->search_pos); - mem_freed_large(scr->nsearch_pos * sizeof(struct search)); - } - if (scr->slines1) mem_free(scr->slines1); - if (scr->slines2) mem_free(scr->slines2); + free(scr->search_chr); + free(scr->search_pos); + free(scr->slines1); + free(scr->slines2); #ifdef G if (scr->root) scr->root->destruct(scr->root); diff --git a/https.c b/https.c @@ -163,7 +163,6 @@ void freeSSL(links_ssl *ssl) { if (!ssl || ssl == DUMMY) return; -#ifdef SSL_SESSION_RESUME { int r; SSL_set_quiet_shutdown(ssl->ssl, 1); @@ -171,7 +170,6 @@ void freeSSL(links_ssl *ssl) if (r < 0) clear_ssl_errors(__LINE__); } -#endif SSL_free(ssl->ssl); mem_free(ssl); } @@ -294,16 +292,9 @@ unsigned char *get_cipher_string(links_ssl *ssl) add_chr_to_str(&s, &l, ' '); add_to_str(&s, &l, cipher); } -#if defined(SSL_SESSION_RESUME) && 0 - if (SSL_session_reused(ssl->ssl)) { - add_to_str(&s, &l, cast_uchar " (reused session)"); - } -#endif return s; } -#ifdef SSL_SESSION_RESUME - struct session_cache_entry { list_entry_1st uttime absolute_time; @@ -427,5 +418,3 @@ void init_session_cache(void) { register_cache_upcall(shrink_session_cache, 0, cast_uchar "session"); } - -#endif diff --git a/img.c b/img.c @@ -53,7 +53,6 @@ static void destroy_decoder (struct cached_image *cimg) static void mem_free_buffer(struct cached_image *cimg) { mem_free(cimg->buffer); - mem_freed_large(cimg->width * cimg->height * cimg->buffer_bytes_per_pixel); } static void img_destruct_image(struct g_object *object) @@ -551,7 +550,6 @@ not_enough: goto not_enough; end: mem_free(tmp); - mem_freed_large(cimg->width*(height<max_height?height:max_height)*3*sizeof(*tmp)); if (!use_strip) drv->register_bitmap(&(cimg->bmp)); } @@ -619,12 +617,8 @@ buffer_to_bitmap"); cimg->bmp.x=ox; cimg->bmp.y=oy; if (drv->get_empty_bitmap(&(cimg->bmp))) { - if (!gonna_be_smart) { - if (tmp) { - mem_free(tmp); - mem_freed_large(ix*iy*3*sizeof(*tmp)); - } - } + if (!gonna_be_smart) + free(tmp); goto bitmap_failed; } if (gonna_be_smart){ @@ -643,8 +637,7 @@ buffer_to_bitmap"); dither(tmp,&(cimg->bmp)); else (*round_fn)(tmp,&(cimg->bmp)); - mem_free(tmp); - mem_freed_large(ix*iy*3*sizeof(*tmp)); + free(tmp); } else { int i; unsigned char *ptr = cimg->bmp.data; diff --git a/jpeg.c b/jpeg.c @@ -157,7 +157,7 @@ static void gray_to_rgb(unsigned char *data, int pixels) static inline void fix_data( struct jpg_decoder *deco, int lines_read) { /* ICC bug */ - icc_volatile int a; + int a; switch (global_cinfo->output_components){ case 1: diff --git a/links.h b/links.h @@ -55,8 +55,6 @@ #include <openssl/err.h> #include <openssl/crypto.h> -#define SSL_SESSION_RESUME - #if defined(G) #if defined(HAVE_PNG_H) #define PNG_THREAD_UNSAFE_OK @@ -422,8 +420,6 @@ static inline int cmpbeg(const unsigned char *str, const unsigned char *b) typedef unsigned long long uttime; typedef unsigned long long tcount; -#define mem_freed_large(x) do { } while (0) - struct terminal; struct open_in_new { @@ -1034,15 +1030,10 @@ int verify_ssl_cipher(links_ssl *ssl); int ssl_not_reusable(links_ssl *ssl); unsigned char *get_cipher_string(links_ssl *ssl); -#if defined(SSL_SESSION_RESUME) SSL_SESSION *get_session_cache_entry(SSL_CTX *ctx, unsigned char *host, int port); void retrieve_ssl_session(struct connection *c); unsigned long session_info(int type); void init_session_cache(void); -#else -#define init_session_cache() do { } while (0) -#define retrieve_ssl_session(c) do { } while (0) -#endif /* data.c */ @@ -1367,9 +1358,6 @@ void generic_set_clip_area(struct graphics_device *dev, struct rect *r); * on a monochromatic backround and font operations. */ -#define limit_16(x) (x) -#define cmd_limit_16(x) do { } while (0) - #define sRGB_gamma 0.45455 /* For HTML, which runs * according to sRGB standard. Number * in HTML tag is linear to photons raised @@ -1780,10 +1768,6 @@ void set_language(void); #define TEXT_(x) (dummyarray + x) /* TEXT causes name clash on windows */ -/* dos.c */ -/* Used in error.c */ -#define dos_poll_break() do { } while (0) - /* main.c */ extern int terminal_pipe[2]; @@ -3146,10 +3130,6 @@ void add_png_version(unsigned char **s, int *l); #endif /* #ifdef G */ -/* svg.c */ - -#define spawn_font_thread() do { } while (0) - /* img.c */ #ifdef G diff --git a/main.c b/main.c @@ -405,7 +405,6 @@ static void init(void) } mem_free(n); } - spawn_font_thread(); init_dither(drv->depth); } #else diff --git a/memory.c b/memory.c @@ -127,9 +127,7 @@ retry: #endif fprintf(stderr, "Formatted document cache: %lu documents, %lu locked\n", formatted_info(CI_FILES), formatted_info(CI_LOCKED)); fprintf(stderr, "DNS cache: %lu servers", dns_info(CI_FILES)); -#ifdef SSL_SESSION_RESUME fprintf(stderr, ", TLS session cache: %lu servers", session_info(CI_FILES)); -#endif fprintf(stderr, "\n"); if (file) fatal_exit("ERROR: out of memory (%s(%lu) at %s:%d returned NULL)", msg, (unsigned long)size, file, line); diff --git a/menu.c b/menu.c @@ -44,7 +44,7 @@ static void menu_version(void *term_) int maxlen = 0; unsigned char *s; int l; - unsigned char * const * decc_volatile text_ptr; + unsigned char * const *text_ptr; for (i = 0; version_texts[i]; i++) { unsigned char *t = get_text_translation(version_texts[i], term); int tl = cp_len(term_charset(term), t); @@ -412,14 +412,12 @@ static int resource_info(struct terminal *term, struct refresh *r2) add_unsigned_long_num_to_str(&a, &l, dns_info(CI_FILES)); add_to_str(&a, &l, cast_uchar " "); add_to_str(&a, &l, get_text_translation(TEXT_(T_SERVERS), term)); -#ifdef SSL_SESSION_RESUME add_to_str(&a, &l, cast_uchar ", "); add_to_str(&a, &l, get_text_translation(TEXT_(T_TLS_SESSION_CACHE), term)); add_to_str(&a, &l, cast_uchar ": "); add_unsigned_long_num_to_str(&a, &l, session_info(CI_FILES)); add_to_str(&a, &l, cast_uchar " "); add_to_str(&a, &l, get_text_translation(TEXT_(T_SERVERS), term)); -#endif add_to_str(&a, &l, cast_uchar "."); if (r2 && !strcmp(cast_const_char a, cast_const_char *(unsigned char **)((struct dialog_data *)r2->win->data)->dlg->udata)) { @@ -3231,10 +3229,9 @@ static_const struct menu_item main_menu[] = { void activate_bfu_technology(struct session *ses, int item) { struct terminal *term = ses->term; - /* decc_volatile to avoid compiler bug */ - struct menu_item * decc_volatile m = (struct menu_item *)main_menu; + struct menu_item *m = (struct menu_item *)main_menu; #ifdef G - struct menu_item * decc_volatile mg = m; + struct menu_item *mg = m; #endif do_mainmenu(term, gf_val(m, mg), ses, item); } diff --git a/os_dep.c b/os_dep.c @@ -182,8 +182,7 @@ int get_terminal_size(int fd, int *x, int *y) { int rs = -1; #ifdef TIOCGWINSZ - /* Sun Studio misoptimizes it */ - sun_volatile struct winsize ws; + struct winsize ws; EINTRLOOP(rs, ioctl(1, TIOCGWINSZ, &ws)); #endif if ((rs == -1 diff --git a/os_depx.h b/os_depx.h @@ -203,27 +203,7 @@ #define fd_pow powf #endif -#if defined(__DECC_VER) -#define static_const static -#define decc_volatile volatile -#else #define static_const static const -#define decc_volatile -#endif - -#ifdef __HIGHC__ -#define highc_volatile volatile -#else -#define highc_volatile -#endif - -#define icc_volatile - -#ifdef __SUNPRO_C -#define sun_volatile volatile -#else -#define sun_volatile -#endif typedef const char *const_char_ptr;