View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0002240 | GNUnet | util library | public | 2012-03-24 16:01 | 2012-11-05 18:34 |
| Reporter | Christian Grothoff | Assigned To | Christian Grothoff | ||
| Priority | low | Severity | tweak | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | Git master | ||||
| Target Version | 0.9.4 | Fixed in Version | 0.9.4 | ||
| Summary | 0002240: duplicate code in os_priority.c for starting processes | ||||
| Description | Currently, the code for starting processes is duplicated in os_priority. There are subtle differences between the two versions, but it should be possible in principle to abstract out one common version. The fact that the code is full of #ifdef's for handling W32 vs. POSIX makes this task a bit more tricky. | ||||
| Steps To Reproduce | We get this report from CPD/PMD, but it only scratches the surface: ===================================================================== Found a 22 line (145 tokens) duplication in the following files: Starting at line 887 of /home/pmdcpd/gnunet/src/util/os_priority.c Starting at line 1257 of /home/pmdcpd/gnunet/src/util/os_priority.c cmdlen = strlen (filename); if (cmdlen < 5 || strcmp (&filename[cmdlen - 4], ".exe") != 0) GNUNET_asprintf (&non_const_filename, "%s.exe", filename); else GNUNET_asprintf (&non_const_filename, "%s", filename); /* Check that this is the full path. If it isn't, search. */ if (non_const_filename[1] == ':') snprintf (path, sizeof (path) / sizeof (char), "%s", non_const_filename); else if (!SearchPathA (pathbuf, non_const_filename, NULL, sizeof (path) / sizeof (char), path, NULL)) { SetErrnoFromWinError (GetLastError ()); LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "SearchPath", non_const_filename); GNUNET_free (non_const_filename); GNUNET_free (pathbuf); return NULL; } GNUNET_free (pathbuf); GNUNET_free (non_const_filename); ===================================================================== Found a 24 line (120 tokens) duplication in the following files: Starting at line 861 of /home/pmdcpd/gnunet/src/util/os_priority.c Starting at line 1226 of /home/pmdcpd/gnunet/src/util/os_priority.c wchar_t wpath[MAX_PATH + 1], wcmd[32768]; /* Search in prefix dir (hopefully - the directory from which * the current module was loaded), bindir and libdir, then in PATH */ self_prefix = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_SELF_PREFIX); bindir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); libdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR); pathbuf_len = GetEnvironmentVariableA ("PATH", (char *) &pathbuf, 0); alloc_len = pathbuf_len + 1 + strlen (self_prefix) + 1 + strlen (bindir) + 1 + strlen (libdir); pathbuf = GNUNET_malloc (alloc_len * sizeof (char)); ptr = pathbuf; ptr += sprintf (pathbuf, "%s;%s;%s;", self_prefix, bindir, libdir); GNUNET_free (self_prefix); GNUNET_free (bindir); GNUNET_free (libdir); alloc_len = GetEnvironmentVariableA ("PATH", ptr, pathbuf_len); | ||||
| Tags | No tags attached. | ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2012-03-24 16:01 | Christian Grothoff | New Issue | |
| 2012-03-24 16:04 | Christian Grothoff | Steps to Reproduce Updated | |
| 2012-03-24 16:05 | Christian Grothoff | Status | new => confirmed |
| 2012-06-03 01:16 | Christian Grothoff | Target Version | => 0.9.4 |
| 2012-06-13 10:29 | Christian Grothoff | Assigned To | => Christian Grothoff |
| 2012-06-13 10:29 | Christian Grothoff | Status | confirmed => assigned |
| 2012-06-13 10:35 | Christian Grothoff | Note Added: 0006057 | |
| 2012-06-13 10:35 | Christian Grothoff | Status | assigned => resolved |
| 2012-06-13 10:35 | Christian Grothoff | Fixed in Version | => 0.9.4 |
| 2012-06-13 10:35 | Christian Grothoff | Resolution | open => fixed |
| 2012-11-05 18:34 | Christian Grothoff | Status | resolved => closed |