Skip to content

Commit dc59ab4

Browse files
Merge pull request #92 from yutaro-sakamoto/fix/warnings
2 parents 67c3aa4 + a109b6a commit dc59ab4

File tree

7 files changed

+19
-151
lines changed

7 files changed

+19
-151
lines changed

bin/cobjrun.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <stdio.h>
2626
#include <string.h>
27+
#include <stdlib.h>
2728

2829
#include "tarstamp.h"
2930

cobj/cobj.c

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int cb_saveargc;
163163
char **cb_saveargv;
164164

165165
const char *cob_config_dir;
166-
extern char *cb_java_package_name = NULL;
166+
char *cb_java_package_name = NULL;
167167

168168
char edit_code_command[512];
169169
char edit_code_command_is_set = 0;
@@ -235,15 +235,6 @@ static const char *cob_tmpdir; /* /tmp */
235235

236236
static struct filename *file_list;
237237

238-
/* NOTE fcopts MUST have at least one leading space */
239-
#if defined(__GNUC__) && (__GNUC__ >= 3)
240-
static const char fcopts[] = " -finline-functions -fno-gcse -freorder-blocks ";
241-
#elif defined(__xlc__)
242-
static const char fcopts[] = " -Q -qro -qroconst ";
243-
#else
244-
static const char fcopts[] = " ";
245-
#endif
246-
247238
#if defined(__GNUC__) && (__GNUC__ >= 3)
248239
static const char gccpipe[] = "-pipe";
249240
#else
@@ -1526,25 +1517,12 @@ static int preprocess(struct filename *fn) {
15261517
return 0;
15271518
}
15281519

1529-
static struct cb_program *program_list_reverse(struct cb_program *p) {
1530-
struct cb_program *next;
1531-
struct cb_program *last = NULL;
1532-
1533-
for (; p; p = next) {
1534-
next = p->next_program;
1535-
p->next_program = last;
1536-
last = p;
1537-
}
1538-
return last;
1539-
}
1540-
15411520
static int process_translate(struct filename *fn) {
15421521
struct cb_program *p;
15431522
struct cb_program *q;
15441523
struct cb_program *r;
15451524
struct handler_struct *hstr1;
15461525
struct handler_struct *hstr2;
1547-
struct local_filename *lf;
15481526
int ret;
15491527
int i;
15501528

@@ -1643,30 +1621,6 @@ static int process_compile(struct filename *fn) {
16431621
return ret;
16441622
}
16451623

1646-
/* Create single-element assembled object */
1647-
1648-
static int process_assemble(struct filename *fn) {
1649-
char buff[COB_MEDIUM_BUFF];
1650-
1651-
#ifdef _MSC_VER
1652-
sprintf(buff,
1653-
gflag_set ? "%s /c %s %s /Od /MDd /Zi /FR /Fo\"%s\" \"%s\""
1654-
: "%s /c %s %s /MD /Fo\"%s\" \"%s\"",
1655-
cob_cc, cob_java_flags, cob_define_flags, fn->object, fn->translate);
1656-
#else
1657-
if (cb_compile_level == CB_LEVEL_MODULE ||
1658-
cb_compile_level == CB_LEVEL_LIBRARY) {
1659-
sprintf(buff, "%s %s -c %s %s %s -o \"%s\" \"%s\"", cob_cc, gccpipe,
1660-
cob_java_flags, cob_define_flags, COB_PIC_FLAGS, fn->object,
1661-
fn->translate);
1662-
} else {
1663-
sprintf(buff, "%s %s -c %s %s -o \"%s\" \"%s\"", cob_cc, gccpipe,
1664-
cob_java_flags, cob_define_flags, fn->object, fn->translate);
1665-
}
1666-
#endif
1667-
return process(buff);
1668-
}
1669-
16701624
static int process_build_module(struct filename *fn) {
16711625
int ret;
16721626
char buff[COB_MEDIUM_BUFF];
@@ -1710,66 +1664,6 @@ static int process_build_module(struct filename *fn) {
17101664
return ret;
17111665
}
17121666

1713-
/* Create single-element loadable object */
1714-
1715-
static int process_module(struct filename *fn) {
1716-
int ret;
1717-
char buff[COB_MEDIUM_BUFF];
1718-
char name[COB_MEDIUM_BUFF];
1719-
1720-
if (output_name) {
1721-
strcpy(name, output_name);
1722-
#if defined(_MSC_VER)
1723-
file_stripext(name);
1724-
#else
1725-
if (strchr(output_name, '.') == NULL) {
1726-
strcat(name, ".");
1727-
strcat(name, COB_MODULE_EXT);
1728-
}
1729-
#endif
1730-
} else {
1731-
file_basename(fn->source, name);
1732-
#if !defined(_MSC_VER)
1733-
strcat(name, ".");
1734-
strcat(name, COB_MODULE_EXT);
1735-
#endif
1736-
}
1737-
#ifdef _MSC_VER
1738-
sprintf(buff,
1739-
gflag_set ? "%s /Od /MDd /LDd /Zi /FR /Fe\"%s\" %s \"%s\" %s"
1740-
: "%s /MD /LD /Fe\"%s\" %s \"%s\" %s",
1741-
cob_cc, name, cob_ldflags, fn->object, cob_libs);
1742-
ret = process(buff);
1743-
#if _MSC_VER >= 1400
1744-
/* Embedding manifest */
1745-
if (ret == 0) {
1746-
sprintf(buff,
1747-
"%s /manifest \"%s.dll.manifest\" /outputresource:\"%s.dll\";#2",
1748-
manicmd, name, name);
1749-
ret = process(buff);
1750-
sprintf(buff, "%s.dll.manifest", name);
1751-
cobc_check_action(buff);
1752-
}
1753-
#endif
1754-
sprintf(buff, "%s.exp", name);
1755-
cobc_check_action(buff);
1756-
sprintf(buff, "%s.lib", name);
1757-
cobc_check_action(buff);
1758-
#else /* _MSC_VER */
1759-
sprintf(buff, "%s %s %s %s %s %s -o %s %s %s", cob_cc, gccpipe,
1760-
COB_SHARED_OPT, cob_ldflags, COB_PIC_FLAGS, COB_EXPORT_DYN, name,
1761-
fn->object, cob_libs);
1762-
ret = process(buff);
1763-
#ifdef COB_STRIP_CMD
1764-
if (strip_output && ret == 0) {
1765-
sprintf(buff, "%s %s", COB_STRIP_CMD, name);
1766-
ret = process(buff);
1767-
}
1768-
#endif
1769-
#endif /* _MSC_VER */
1770-
return ret;
1771-
}
1772-
17731667
static int process_library(struct filename *l) {
17741668
char *buffptr;
17751669
char *objsptr;

cobj/codegen.c

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ int param_wrap_string_flag = 0;
163163
static char *get_java_identifier_field(struct cb_field *f);
164164
static char *get_java_identifier_base(struct cb_field *f);
165165
static void get_java_identifier_helper(struct cb_field *f, char *buf);
166-
static void strcpy_identifier_cobol_to_java(char *buf, char *identifier);
166+
static void strcpy_identifier_cobol_to_java(char *buf, const char *identifier);
167167
void joutput_execution_list(struct cb_program *prog);
168-
void joutput_execution_entry_func();
168+
void joutput_execution_entry_func(void);
169169
void joutput_init_method(struct cb_program *prog);
170170
void joutput_declare_member_variables(struct cb_program *prog,
171171
cb_tree parameter_list);
@@ -174,8 +174,8 @@ char *convert_byte_value_format(char value);
174174
void append_label_id_map(struct cb_label *label);
175175
void create_label_id_map(struct cb_program *prog);
176176
int find_label_id(struct cb_label *label);
177-
void destroy_label_id_map();
178-
void joutput_edit_code_command(const char *option);
177+
void destroy_label_id_map(void);
178+
void joutput_edit_code_command(const char *target);
179179

180180
const int EXECUTION_NORMAL = 0;
181181
const int EXECUTION_LAST = 1;
@@ -220,7 +220,7 @@ static void get_java_identifier_helper(struct cb_field *f, char *buf) {
220220
}
221221
}
222222

223-
static void strcpy_identifier_cobol_to_java(char *buf, char *identifier) {
223+
static void strcpy_identifier_cobol_to_java(char *buf, const char *identifier) {
224224
for (; *identifier != '\0'; ++identifier, ++buf) {
225225
if (*identifier == '-') {
226226
*buf = '_';
@@ -296,18 +296,6 @@ static struct literal_list *literal_list_reverse(struct literal_list *p) {
296296
return last;
297297
}
298298

299-
static struct local_list *local_list_reverse(struct local_list *p) {
300-
struct local_list *next;
301-
struct local_list *last = NULL;
302-
303-
for (; p; p = next) {
304-
next = p->next;
305-
p->next = last;
306-
last = p;
307-
}
308-
return last;
309-
}
310-
311299
/*
312300
* Output routines
313301
*/
@@ -501,8 +489,6 @@ void joutput_edit_code_command(const char *target) {
501489
}
502490

503491
pclose(fp);
504-
505-
return 0;
506492
}
507493

508494
/*
@@ -516,7 +502,7 @@ static void joutput_base(struct cb_field *f) {
516502
struct base_list *bl;
517503
char *nmp;
518504
char name[COB_SMALL_BUFF];
519-
char *base_name;
505+
char *base_name = NULL;
520506

521507
f01 = cb_field_founder(f);
522508

@@ -571,7 +557,9 @@ static void joutput_base(struct cb_field *f) {
571557
joutput("%s%s", CB_PREFIX_BASE, name);
572558
} else {
573559
joutput(name);
574-
free(base_name);
560+
if (base_name != NULL) {
561+
free(base_name);
562+
}
575563
}
576564

577565
if (cb_field_variable_address(f)) {
@@ -1328,7 +1316,6 @@ static void joutput_param(cb_tree x, int id) {
13281316
}
13291317
if (!r->subs && !r->offset && f->count > 0 && !cb_field_variable_size(f) &&
13301318
!cb_field_variable_address(f)) {
1331-
int joutput_flag = 0;
13321319
if (!f->flag_field) {
13331320
savetarget = joutput_target;
13341321
joutput_target = NULL;
@@ -2454,7 +2441,7 @@ static void joutput_call(struct cb_call *p) {
24542441
char *system_call = NULL;
24552442
struct system_table *psyst;
24562443
size_t n;
2457-
size_t parmnum;
2444+
size_t parmnum = 0;
24582445
size_t retptr;
24592446
int dynamic_link = 1;
24602447
int sizes;
@@ -4027,17 +4014,14 @@ struct call_parameter_list *call_parameter_cache = NULL;
40274014
static void joutput_java_entrypoint(struct cb_program *prog,
40284015
cb_tree parameter_list) {
40294016
cb_tree l;
4030-
struct cb_field *f;
40314017
char arg_field_name[COB_SMALL_BUFF];
40324018

40334019
joutput_prefix();
40344020
joutput("public CobolResultSet execute (");
40354021

4036-
int k;
40374022
for (l = parameter_list; l; l = CB_CHAIN(l)) {
40384023
struct cb_field *arg_field = cb_field(CB_VALUE(l));
40394024
int type = cb_tree_type(CB_TREE(arg_field));
4040-
char *field_name = get_java_identifier_field(arg_field);
40414025
get_java_identifier_helper(arg_field, arg_field_name);
40424026
if (type & COB_TYPE_NUMERIC) {
40434027
if (arg_field->pic->scale > 0) {
@@ -5381,16 +5365,6 @@ void joutput_declare_member_variables(struct cb_program *prog,
53815365
joutput("\n");
53825366
}
53835367

5384-
static void joutput_main_function(struct cb_program *prog) {
5385-
joutput_line("/* Main function */");
5386-
joutput_line("int");
5387-
joutput_line("main (int argc, char **argv)");
5388-
joutput_indent("{");
5389-
joutput_line("cob_init (argc, argv);");
5390-
joutput_line("cob_stop_run (%s ());", prog->program_id);
5391-
joutput_indent("}\n");
5392-
}
5393-
53945368
/*
53955369
* Class definition
53965370
*/
@@ -5672,7 +5646,7 @@ void codegen(struct cb_program *prog, const int nested,
56725646
joutput_target = yyout;
56735647
char java_file_name[64];
56745648
sprintf(java_file_name, "%s.java", prog->program_id);
5675-
*program_id_list = prog->program_id;
5649+
*program_id_list = (char *)prog->program_id;
56765650
joutput_target = fopen(java_file_name, "w");
56775651

56785652
if (!nested) {

cobj/tree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,8 +1472,8 @@ extern void cb_emit_divide(cb_tree dividend, cb_tree divisor, cb_tree quotient,
14721472
extern void cb_emit_evaluate(cb_tree subject_list, cb_tree case_list);
14731473

14741474
extern void cb_emit_goto(cb_tree target, cb_tree depending);
1475-
extern void cb_emit_java_continue();
1476-
extern void cb_emit_java_break();
1475+
extern void cb_emit_java_continue(void);
1476+
extern void cb_emit_java_break(void);
14771477
extern void cb_emit_exit(size_t goback);
14781478

14791479
extern void cb_emit_if(cb_tree cond, cb_tree stmt1, cb_tree stmt2);

cobj/typeck.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,12 +3743,12 @@ void cb_emit_goto(cb_tree target, cb_tree depending) {
37433743
}
37443744
}
37453745

3746-
void cb_emit_java_continue() {
3746+
void cb_emit_java_continue(void) {
37473747
cb_emit(make_tree(CB_TAG_JAVA_CONTINUE, CB_CATEGORY_UNKNOWN,
37483748
sizeof(struct cb_tree_common)));
37493749
}
37503750

3751-
void cb_emit_java_break() {
3751+
void cb_emit_java_break(void) {
37523752

37533753
cb_emit(make_tree(CB_TAG_JAVA_BREAK, CB_CATEGORY_UNKNOWN,
37543754
sizeof(struct cb_tree_common)));

configure

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21821,7 +21821,6 @@ printf "%s\n" "#define ICONV_CONST $am_cv_proto_iconv_arg1" >>confdefs.h
2182121821

2182221822

2182321823

21824-
# AM_LANGINFO_CODESET
2182521824

2182621825
# Checks for getopt_long.
2182721826
# Cygwin has getopt_long_only prototype in kpathsea/getopt.h
@@ -24777,7 +24776,7 @@ esac
2477724776

2477824777
if test "`basename $CC`" = "gcc"
2477924778
then
24780-
CFLAGS="$CFLAGS -fsigned-char -Wall -Wwrite-strings -Wmissing-prototypes -Wno-format-y2k"
24779+
CFLAGS="$CFLAGS -fsigned-char -Wall -Wwrite-strings -Wmissing-prototypes -Wno-format-y2k -Wno-format-security -Wno-incompatible-pointer-types"
2478124780
fi
2478224781

2478324782
if test "x$lt_cv_dlopen_self" != "xyes"

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ esac
617617

618618
if test "`basename $CC`" = "gcc"
619619
then
620-
CFLAGS="$CFLAGS -fsigned-char -Wall -Wwrite-strings -Wmissing-prototypes -Wno-format-y2k"
620+
CFLAGS="$CFLAGS -fsigned-char -Wall -Wwrite-strings -Wmissing-prototypes -Wno-format-y2k -Wno-format-security -Wno-incompatible-pointer-types"
621621
fi
622622

623623
if test "x$lt_cv_dlopen_self" != "xyes"

0 commit comments

Comments
 (0)