Browse Source

956: remove debugging prints, improve comments, fix the test suite (!)

Fix some test suite failures due to subtle interactions with the debugging
prints I forgot to remove.  Add a some important comments and a few minor
cosmetic improvements.
ENGINE-957
Luca Saiu 1 month ago
parent
commit
ea414ac15f
4 changed files with 32 additions and 12 deletions
  1. +14
    -2
      src/pEpEngine.h
  2. +4
    -1
      src/platform_unix.c
  3. +14
    -0
      src/platform_unix.h
  4. +0
    -9
      test/src/Engine.cc

+ 14
- 2
src/pEpEngine.h View File

@ -1765,6 +1765,9 @@ DYNAMIC_API PEP_STATUS is_pEp_user(PEP_SESSION session,
*
* @brief Returns the directory for pEp management db as a relative
* path from the home directory (or the pEp home directory)
* The returned pointed refers memory managed by
* the engine, which will remain valid until
* the next call to reset_path_cache.
*
* @retval char* relative pathname
* @retval NULL on failure
@ -1776,7 +1779,10 @@ DYNAMIC_API const char *per_user_relative_directory(void);
/**
* <!-- per_user_directory() -->
*
* @brief Returns the directory for pEp management db
* @brief Returns the directory for pEp management db.
* The returned pointed refers memory managed by
* the engine, which will remain valid until
* the next call to reset_path_cache.
*
* @retval char* path to actual per user directory
* @retval NULL on failure
@ -1791,6 +1797,9 @@ DYNAMIC_API const char *per_user_directory(void);
* <!-- per_machine_directory() -->
*
* @brief Returns the directory for pEp system db
* The returned pointed refers memory managed by
* the engine, which will remain valid until
* the next call to reset_path_cache.
*
* @retval char* path to actual per machine directory
* @retval NULL on failure
@ -1987,7 +1996,10 @@ DYNAMIC_API PEP_STATUS reset_path_cache(void);
/**
* <!-- reset_path_cache() -->
*
* @brief Empty the path cache, releasing resources.
* @brief Empty the path cache, releasing resources. This may invalidate
* the memory used by the results of per_user_relative_directory,
* per_user_directory, per_machine_directory, android_system_db,
* unix_system_db, unix_local_db.
*
*/
DYNAMIC_API void clear_path_cache(void);


+ 4
- 1
src/platform_unix.c View File

@ -350,6 +350,7 @@ static void _move(const char *o, const char *ext, const char *n)
* is the added functionality with respect to the standard
* strdup) a malloc-allocated copy of "" if the argument is
* NULL.
* Return NULL only in case of an out-of-memory error.
*
* @param[in] *original constchar
* @retval NULL out of memory
@ -625,6 +626,7 @@ static PEP_STATUS _expand_variables(char **out,
#name); \
reset_path_cache(); \
} \
assert (_ ## name ## _cache != NULL); \
return _ ## name ## _cache; \
}
@ -680,7 +682,8 @@ DYNAMIC_API PEP_STATUS reset_path_cache(void)
unexpanded_path = NULL; \
} while (false)
/* In case this is not the first invocation, start by releasing memory. */
/* Start by releasing memory, which is needed in case this is not the first
invocation. */
clear_path_cache ();
const char *unexpanded_path = NULL;


+ 14
- 0
src/platform_unix.h View File

@ -45,6 +45,9 @@ extern "C" {
* <!-- unix_local_db() -->
*
* @brief TODO
* The returned pointed refers memory managed by
* the engine, which will remain valid until
* the next call to reset_path_cache.
*
*/
const char *unix_local_db(void);
@ -53,6 +56,9 @@ const char *unix_local_db(void);
* <!-- unix_system_db() -->
*
* @brief TODO
* The returned pointed refers memory managed by
* the engine, which will remain valid until
* the next call to reset_path_cache.
*
*/
const char *unix_system_db(void);
@ -69,6 +75,14 @@ char *stpcpy(char *, const char *);
// Only the lowest 31 bits are filled randomly.
//long int random(void);
/*
* <!-- android_system_db() -->
*
* @brief TODO
* The returned pointed refers memory managed by
* the engine, which will remain valid until
* the next call to reset_path_cache.
*/
const char *android_system_db(void);
#define SYSTEM_DB android_system_db()


+ 0
- 9
test/src/Engine.cc View File

@ -96,15 +96,6 @@ void Engine::start() {
status = reset_path_cache();
assert(status == PEP_STATUS_OK);
FILE *f = fopen ("/home/luca/pep-src/pep-engine/PER_USER_DIRECTORY", "w");
fprintf (f, "* per_user_directory (): %s\n", per_user_directory ());
fclose (f);
f = fopen ("/home/luca/pep-src/pep-engine/PER_MACHINE_DIRECTORY", "w");
fprintf (f, "* per_machine_directory (): %s\n", per_machine_directory ());
fclose (f);
fprintf (stderr, "* per_user_directory (): %s\n", per_user_directory ());
fprintf (stderr, "* per_user_directory (): %s\n", per_user_directory ());
status = init(&session, cached_messageToSend, cached_inject_sync_event, cached_ensure_passphrase);
assert(status == PEP_STATUS_OK);
assert(session);


Loading…
Cancel
Save