Skip to content

Commit

Permalink
util: Drop 'date' and 'time' arguments from ovs_set_program_name
Browse files Browse the repository at this point in the history
The 'date' and 'time' arguments are normally being set by
'ovs_set_program_name' using __DATE__ and __TIME__. However, this
breaks reproducible builds since even without any changes in the
toolchain, build system etc, the end binary will still differ in
that regard. This is also visible when building with -Wdate-time:

utilities/ovs-dpctl.c:61:29: warning: macro "__DATE__" might prevent
reproducible builds [-Wdate-time]
     set_program_name(argv[0]);
                             ^

and it's also something that triggers the following warning in the
openSUSE OBS builds:

[...]
openvswitch.x86_64: W: file-contains-date-and-time /usr/bin/ovs-ofctl
openvswitch.x86_64: W: file-contains-date-and-time /usr/bin/ovs-appctl
Your file uses  __DATE and __TIME__ this causes the package to rebuild
when not needed
[...]

This patch drops these two arguments from ovs_set_program_name__ and
renames the function to ovs_set_program_name dropping the previous
preprocessor macro in the process.

This finally removes the remaining references to __DATE__ and __TIME__
from the sources which is something that has already been done in
commit 26bfaea ("Stop using __DATE__ and __TIME__ in startup
string.") for the kernel datapath.

Cc: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Markos Chandras <mchandras@suse.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
Markos Chandras authored and blp committed May 26, 2016
1 parent 1a523ec commit fa54d37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -144,6 +144,7 @@ Mark D. Gray mark.d.gray@intel.com
Mark Hamilton mhamilton@nicira.com
Mark Kavanagh mark.b.kavanagh@intel.com
Mark Maglana mmaglana@gmail.com
Markos Chandras mchandras@suse.de
Martin Casado casado@nicira.com
Martino Fornasa mf@fornasa.it
Maryam Tahhan maryam.tahhan@intel.com
Expand Down
6 changes: 1 addition & 5 deletions include/openvswitch/util.h
Expand Up @@ -25,11 +25,7 @@
extern "C" {
#endif

void ovs_set_program_name__(const char *name, const char *version,
const char *date, const char *time);

#define ovs_set_program_name(name, version) \
ovs_set_program_name__(name, version, __DATE__, __TIME__)
void ovs_set_program_name(const char *name, const char *version);

const char *ovs_get_program_name(void);
const char *ovs_get_program_version(void);
Expand Down
17 changes: 5 additions & 12 deletions lib/util.c
Expand Up @@ -461,14 +461,9 @@ ovs_strerror(int error)
* vSwitch. Otherwise, it is assumed to be an external program linking against
* the Open vSwitch libraries.
*
* The 'date' and 'time' arguments should likely be called with
* "__DATE__" and "__TIME__" to use the time the binary was built.
* Alternatively, the "ovs_set_program_name" macro may be called to do this
* automatically.
*/
void
ovs_set_program_name__(const char *argv0, const char *version, const char *date,
const char *time)
ovs_set_program_name(const char *argv0, const char *version)
{
char *basename;
#ifdef _WIN32
Expand Down Expand Up @@ -496,14 +491,12 @@ ovs_set_program_name__(const char *argv0, const char *version, const char *date,

free(program_version);
if (!strcmp(version, VERSION)) {
program_version = xasprintf("%s (Open vSwitch) "VERSION"\n"
"Compiled %s %s\n",
program_name, date, time);
program_version = xasprintf("%s (Open vSwitch) "VERSION"\n",
program_name);
} else {
program_version = xasprintf("%s %s\n"
"Open vSwitch Library "VERSION"\n"
"Compiled %s %s\n",
program_name, version, date, time);
"Open vSwitch Library "VERSION"\n",
program_name, version);
}
}

Expand Down

0 comments on commit fa54d37

Please sign in to comment.