Patch to allow FreeRADIUS server 2.1.8 to compile on non-GCC systems
Change Description: * Allow code to compile on non-GCC systems, by providing const casting when necessary (command.c, for example) * Allow code to compile on non-GCC systems, by fixing variable declarations that are not at the beginning of a block (ltdl.c, for example) diff -urN freeradius-server-2.1.8/libltdl/ltdl.c freeradiusd-gnucleanup/libltdl/ltdl.c --- freeradius-server-2.1.8/libltdl/ltdl.c 2009-12-30 07:44:35.000000000 -0800 +++ freeradiusd-gnucleanup/libltdl/ltdl.c 2010-04-20 07:25:27.000000000 -0700 @@ -2442,12 +2442,14 @@ while (loader) { + lt_user_data data; /* san */ if (useloader && strcmp(loader->loader_name, useloader)) { loader = loader->next; continue; } - lt_user_data data = loader->dlloader_data; +/* lt_user_data data = loader->dlloader_data; */ /* SAN */ + data = loader->dlloader_data; /* SAN */ cur->module = loader->module_open (data, filename); diff -urN freeradius-server-2.1.8/src/main/auth.c freeradiusd-gnucleanup/src/main/auth.c --- freeradius-server-2.1.8/src/main/auth.c 2009-12-30 07:44:35.000000000 -0800 +++ freeradiusd-gnucleanup/src/main/auth.c 2010-04-20 09:28:18.000000000 -0700 @@ -175,9 +175,13 @@ */ cur_config_item = request->config_items; while(((auth_type_pair = pairfind(cur_config_item, PW_AUTH_TYPE))) != NULL) { + DICT_VALUE *dv = NULL; /* SAN */ auth_type = auth_type_pair->vp_integer; auth_type_count++; - DICT_VALUE *dv = dict_valbyattr(auth_type_pair->attribute, +/* SAN DICT_VALUE *dv = dict_valbyattr(auth_type_pair->attribute, + auth_type_pair->vp_integer); +*/ + dv = dict_valbyattr(auth_type_pair->attribute, auth_type_pair->vp_integer); RDEBUG2("Found Auth-Type = %s", diff -urN freeradius-server-2.1.8/src/main/command.c freeradiusd-gnucleanup/src/main/command.c --- freeradius-server-2.1.8/src/main/command.c 2009-12-30 07:44:35.000000000 -0800 +++ freeradiusd-gnucleanup/src/main/command.c 2010-04-20 09:33:16.000000000 -0700 @@ -842,7 +842,7 @@ return 0; } - cf_section2file(fp, client->cs); + cf_section2file(fp, /* SAN */(CONF_SECTION*)client->cs); fclose(fp); return 1; diff -urN freeradius-server-2.1.8/src/main/listen.c freeradiusd-gnucleanup/src/main/listen.c --- freeradius-server-2.1.8/src/main/listen.c 2009-12-30 07:44:35.000000000 -0800 +++ freeradiusd-gnucleanup/src/main/listen.c 2010-04-20 09:33:05.000000000 -0700 @@ -126,7 +126,7 @@ last_printed = now; } - listener->print(listener, name, sizeof(name)); + listener->print(/* SAN */(rad_listen_t*)listener, name, sizeof(name)); radlog(L_ERR, "Ignoring request to %s from unknown client %s port %d", name, inet_ntop(ipaddr->af, &ipaddr->ipaddr, @@ -206,7 +206,7 @@ request = request_alloc(); if (!request) goto unknown; - request->listener = listener; + request->listener = /* SAN */(rad_listen_t*)listener; request->client = client; request->packet = rad_recv(listener->fd, 0x02); /* MSG_PEEK */ if (!request->packet) { /* badly formed, etc */ diff -urN freeradius-server-2.1.8/src/main/log.c freeradiusd-gnucleanup/src/main/log.c --- freeradius-server-2.1.8/src/main/log.c 2009-12-30 07:44:35.000000000 -0800 +++ freeradiusd-gnucleanup/src/main/log.c 2010-04-20 09:35:58.000000000 -0700 @@ -384,7 +384,7 @@ s[1] = '\0'; } - s = fr_int2str(levels, (lvl & ~L_CONS), ": "); + s = /* SAN */ (char *) fr_int2str(levels, (lvl & ~L_CONS), ": "); strcat(buffer, s); len = strlen(buffer); diff -urN freeradius-server-2.1.8/src/main/xlat.c freeradiusd-gnucleanup/src/main/xlat.c --- freeradius-server-2.1.8/src/main/xlat.c 2009-12-30 07:44:35.000000000 -0800 +++ freeradiusd-gnucleanup/src/main/xlat.c 2010-04-20 09:49:52.000000000 -0700 @@ -572,7 +572,7 @@ * Register the internal packet xlat's. */ for (i = 0; internal_xlat[i] != NULL; i++) { - xlat_register(internal_xlat[i], xlat_packet, &xlat_inst[i]); + xlat_register(internal_xlat[i], xlat_packet, /* SAN */(void*)&xlat_inst[i]); c = xlat_find(internal_xlat[i]); rad_assert(c != NULL); c->internal = TRUE; @@ -581,7 +581,7 @@ /* * New name: "control" */ - xlat_register("control", xlat_packet, &xlat_inst[0]); + xlat_register("control", xlat_packet, /* SAN */(void*)&xlat_inst[0]); c = xlat_find("control"); rad_assert(c != NULL); c->internal = TRUE; @@ -593,7 +593,7 @@ buffer[1] = '\0'; for (i = 0; i <= REQUEST_MAX_REGEX; i++) { buffer[0] = '0' + i; - xlat_register(buffer, xlat_regex, &xlat_inst[i]); + xlat_register(buffer, xlat_regex, /* SAN */(void*)&xlat_inst[i]); c = xlat_find(buffer); rad_assert(c != NULL); c->internal = TRUE; @@ -601,12 +601,12 @@ #endif /* HAVE_REGEX_H */ - xlat_register("debug", xlat_debug, &xlat_inst[0]); + xlat_register("debug", xlat_debug, /* SAN */(void*)&xlat_inst[0]); c = xlat_find("debug"); rad_assert(c != NULL); c->internal = TRUE; - xlat_register("md5", xlat_md5, &xlat_inst[0]); + xlat_register("md5", xlat_md5, /* SAN */(void*)&xlat_inst[0]); c = xlat_find("md5"); rad_assert(c != NULL); c->internal = TRUE; diff -urN freeradius-server-2.1.8/src/modules/rlm_dbm/rlm_dbm.c freeradiusd-gnucleanup/src/modules/rlm_dbm/rlm_dbm.c --- freeradius-server-2.1.8/src/modules/rlm_dbm/rlm_dbm.c 2009-12-30 07:44:35.000000000 -0800 +++ freeradiusd-gnucleanup/src/modules/rlm_dbm/rlm_dbm.c 2010-04-20 07:43:17.000000000 -0700 @@ -206,7 +206,7 @@ if ( parse_state == SMP_PATTERN ) { /* pattern line found */ DEBUG2("process pattern"); /* check pattern against request */ - if ( paircompare(req, request, vp, reply ) == 0 ) { + if ( paircompare(req, /* SAN */ (VALUE_PAIR*)request, vp, reply ) == 0 ) { DEBUG2("rlm_dbm: Pattern matched, look for request"); pairmove(&tmp_config, &vp); pairfree(&vp); diff -urN freeradius-server-2.1.8/src/modules/rlm_policy/parse.c freeradiusd-gnucleanup/src/modules/rlm_policy/parse.c --- freeradius-server-2.1.8/src/modules/rlm_policy/parse.c 2009-12-30 07:44:35.000000000 -0800 +++ freeradiusd-gnucleanup/src/modules/rlm_policy/parse.c 2010-04-20 09:24:14.000000000 -0700 @@ -1532,7 +1532,7 @@ } if ((lexer->debug & POLICY_DEBUG_PRINT_POLICY) != 0) { - rlm_policy_print(this); + rlm_policy_print(/* SAN */(policy_item_t*)this); } return 1;
Scott Neugroschl wrote:
Change Description: * Allow code to compile on non-GCC systems, by providing const casting when necessary (command.c, for example) * Allow code to compile on non-GCC systems, by fixing variable declarations that are not at the beginning of a block (ltdl.c, for example)
Get rid of the /* SAN */ text everywhere. It's useless and annoying. If you want to track local changes, use 'git'. I used to work with a guy who put /* BOB */ on every line of code he changed. He lasted about 2 months.
+ DICT_VALUE *dv = NULL; /* SAN */ auth_type = auth_type_pair->vp_integer; auth_type_count++; - DICT_VALUE *dv = dict_valbyattr(auth_type_pair->attribute, +/* SAN DICT_VALUE *dv = dict_valbyattr(auth_type_pair->attribute, + auth_type_pair->vp_integer); +*/ + dv = dict_valbyattr(auth_type_pair->attribute, auth_type_pair->vp_integer);
If your C compiler can't handle variable declarations, it's *very* old and out of date.
- cf_section2file(fp, client->cs); + cf_section2file(fp, /* SAN */(CONF_SECTION*)client->cs); fclose(fp);
This cast will satisfy old compilers. Modern compilers won't be confused by it. And even for an older compiler, it does nothing more than get rid of a warning. Based on this feedback, none of these patches can make it into the server. Alan DeKok.
--On Wednesday, April 21, 2010 08:48:25 AM +0200 Alan DeKok <aland@deployingradius.com> wrote:
Scott Neugroschl wrote:
Change Description: * Allow code to compile on non-GCC systems, by providing const casting when necessary (command.c, for example) * Allow code to compile on non-GCC systems, by fixing variable declarations that are not at the beginning of a block (ltdl.c, for example)
Get rid of the /* SAN */ text everywhere. It's useless and annoying. If you want to track local changes, use 'git'.
Also get rid of the practice of included a commented-out copy of what every line you changed looked like before the change. That's also unnecessary and makes the patch much harder to read.
+ DICT_VALUE *dv = NULL; /* SAN */ auth_type = auth_type_pair->vp_integer; auth_type_count++; - DICT_VALUE *dv = dict_valbyattr(auth_type_pair->attribute, +/* SAN DICT_VALUE *dv = dict_valbyattr(auth_type_pair->attribute, + auth_type_pair->vp_integer); +*/ + dv = dict_valbyattr(auth_type_pair->attribute, auth_type_pair->vp_integer);
If your C compiler can't handle variable declarations, it's *very* old and out of date.
I doubt anyone has a compiler left that can't handle variable declarations (did C _ever_ permit that?) or even initialization. However, the compiler is within its rights to complain about a declaration which occurs not at the beginning of a block. Again, this is much harder to read because of the unnecessary 3-line commented-out copy of what it looked like before. -- Jeff
I will fix, and resubmit.
From: Jeffrey Hutzelman --On Wednesday, April 21, 2010 08:48:25 AM +0200 Alan DeKok
Get rid of the /* SAN */ text everywhere. It's useless and annoying. If you want to track local changes, use 'git'. [[SAN]] Fine. I don't have git on my system. It's an oddball system -- HP Nonstop. So the SAN was for my purposes, so I could keep track of the changes. Yeah, I should have killed them before submitting. Sue me.
Also get rid of the practice of included a commented-out copy of what every line you changed looked like before the change. That's also unnecessary and makes the patch much harder to read.
Agreed. As I said immediately above, it was for my own purposes (the system has no version control system available)
If your C compiler can't handle variable declarations, it's *very* old and out of date.
I doubt anyone has a compiler left that can't handle variable declarations (did C _ever_ permit that?) or even initialization. However, the compiler is within its rights to complain about a declaration which occurs not at the beginning of a block.
[[SAN]] That's the fix... the variable was not declared at the beginning of the block.
Scott Neugroschl wrote:
Fine. I don't have git on my system. It's an oddball system -- HP Nonstop. So the SAN was for my purposes, so I could keep track of the changes. Yeah, I should have killed them before submitting. Sue me.
Use github.org. It's very, very, nice.
That's the fix... the variable was not declared at the beginning of the block.
OK. We'll take a look at that. But my $0.02 is that functionality is allowed in what... C99? If the compiler can't support standards from 10 years ago, it's not on my list of high priority items to fix. Alan DeKok.
But my $0.02 is that functionality is allowed in what... C99? If the compiler can't support standards from 10 years ago, it's not on my list of high priority items to fix.
I have no problem with it not being on your list. I understand and accept your opinion on this matter. However, since my system only has a C89/C90 compiler, it is on my list, and I've provided a fix (attached). In addition, said patch also addresses const-ness errors from the compiler (which a C99 compliant compiler should also complain about -- passing const T * to a function expecting a T *). Please find attached a patch to the following files, addressing both const-ness and mid-block declarations. * libltdl/ltdl.c * src/main/auth.c * src/main/command.c * src/main/listen.c * src/main/log.c * src/main/xlat.c * src/modules/rlm_dbm/rlm_dbm.c * src/modules/rlm_policy/parse.c
participants (3)
-
Alan DeKok -
Jeffrey Hutzelman -
Scott Neugroschl