Skip to content

Commit

Permalink
[#59] Additional cleanup TODOs completed.
Browse files Browse the repository at this point in the history
38. [DONE] In USEC_SLEEP() change * 1000 to * 1000L so result is correct
    type. Also do the same in gt_timer.c line 348 or so.

39. [DONE] Change ydb_zmaxtptime to ydb_maxtptime (like TODO 27 said) and
    fix test.

40. [DONE] Remove YDB_ERR_UNKNOWN error.

42. [DONE] Change LVUNDEF_OK to ERR_LVUNDEF_OK.

43. [DONE] Change YDB_MAX_NAMES to 35.

44. [DONE] Fix error with ydb_gbldir not being picked up.

45. [DONE] Add INVNAMECOUNT check and error to ydb_tp_s() and
    ydb_delete_excl_s().

46. [DONE] All error checking including parameters should occur before
    all locks are released in ydb_lock_s().

47. [DONE] All ydb_* functions should return either int or void - except
    the one oddball ydb_malloc() which returns a void *.

48. [DONE] Rename YDB_ERROR_SEVERITY() macro to YDB_SEVERITY() and the
    severity codes to YDB_SEVERITY_*.
  • Loading branch information
estess authored and nars1 committed Mar 27, 2018
1 parent 15aaa0f commit 4aaa597
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 82 deletions.
2 changes: 1 addition & 1 deletion sr_port/dpgbldir.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ gd_addr *zgbldir(mval *v)
return name->gd_ptr;
if (!v->str.len)
{
if (NULL != getenv(YDB_GBLDIR))
if (NULL != getenv(YDB_GBLDIR + 1)) /* + 1 to get past '$' this call doesn't use */
{
temp_mstr.addr = YDB_GBLDIR;
temp_mstr.len = SIZEOF(YDB_GBLDIR);
Expand Down
4 changes: 2 additions & 2 deletions sr_port/gtm_env_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ void gtm_env_init(void)
TREF(jnl_extract_nocol) = trans_numeric(&val, &is_defined, TRUE);
# endif
/* Initialize dollar_zmaxtptime */
val.addr = YDB_ZMAXTPTIME;
val.len = SIZEOF(YDB_ZMAXTPTIME) - 1;
val.addr = YDB_MAXTPTIME;
val.len = SIZEOF(YDB_MAXTPTIME) - 1;
status = trans_numeric(&val, &is_defined, TRUE);
if (!is_defined)
{
Expand Down
3 changes: 1 addition & 2 deletions sr_port/libydberrors2.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
#define YDB_ERR_MISSINGVARNAMES -151027802
#define YDB_ERR_TOOMANYVARNAMES -151027810
#define YDB_ERR_INVNAMECOUNT -151027818
#define YDB_ERR_UNKNOWN -151027826
#define YDB_ERR_MISSINGVARNAME -151027826
#define YDB_ERR_TIME2LONG -151027834
#define YDB_ERR_VARNAME2LONG -151027842
#define YDB_ERR_FATALERROR1 -151027850
#define YDB_ERR_FATALERROR2 -151027858
#define YDB_ERR_SIMPLEAPINEST -151027868
#define YDB_ERR_MISSINGVARNAME -151027874
3 changes: 1 addition & 2 deletions sr_port/ydberrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
#define ERR_MISSINGVARNAMES 151027802
#define ERR_TOOMANYVARNAMES 151027810
#define ERR_INVNAMECOUNT 151027818
#define ERR_UNKNOWN 151027826
#define ERR_MISSINGVARNAME 151027826
#define ERR_TIME2LONG 151027834
#define ERR_VARNAME2LONG 151027842
#define ERR_FATALERROR1 151027850
#define ERR_FATALERROR2 151027858
#define ERR_SIMPLEAPINEST 151027868
#define ERR_MISSINGVARNAME 151027874
3 changes: 1 addition & 2 deletions sr_port/ydberrors.msg
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ SUBSARRAYNULL <Non-zero number of subscripts [!UL] specified but subscript array
MISSINGVARNAMES <At least one variable name must be specified>/error/fao=0
TOOMANYVARNAMES <Number of varnames specified exceeds maximum (!UL)>/error/fao=1
INVNAMECOUNT <Invalid value for namecount parameter in a !AD call>/error/fao=2
UNKNOWN <Unknown error code specified>/error/fao=0
MISSINGVARNAME <Required varname not specified>/error/fao=0
TIME2LONG <Specified time value exceeds supported maximum (!UL)>/error/fao=1
VARNAME2LONG <Variable name length exceeds maximum allowed (!UL)>/error/fao=1
FATALERROR1 <Fatal error raised. Generating core and terminating process. Error: !AD>/error/fao=2
FATALERROR2 <Fatal error raised. Bypassing core generation and terminating process. Error: !AD>/error/fao=2
SIMPLEAPINEST <Attempt to nest call of !AD with a call to !AD - nesting calls is not permitted in simpleAPI - process terminating>/fatal/fao=4
MISSINGVARNAME <Required varname not specified>/error/fao=0
5 changes: 2 additions & 3 deletions sr_port/ydberrors_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ LITDEF err_msg ydberrors[] = {
{ "MISSINGVARNAMES", "At least one variable name must be specified", 0 },
{ "TOOMANYVARNAMES", "Number of varnames specified exceeds maximum (!UL)", 1 },
{ "INVNAMECOUNT", "Invalid value for namecount parameter in a !AD call", 2 },
{ "UNKNOWN", "Unknown error code specified", 0 },
{ "MISSINGVARNAME", "Required varname not specified", 0 },
{ "TIME2LONG", "Specified time value exceeds supported maximum (!UL)", 1 },
{ "VARNAME2LONG", "Variable name length exceeds maximum allowed (!UL)", 1 },
{ "FATALERROR1", "Fatal error raised. Generating core and terminating process. Error: !AD", 2 },
{ "FATALERROR2", "Fatal error raised. Bypassing core generation and terminating process. Error: !AD", 2 },
{ "SIMPLEAPINEST", "Attempt to nest call of !AD with a call to !AD - nesting calls is not permitted in simpleAPI - process terminating", 4 },
{ "MISSINGVARNAME", "Required varname not specified", 0 },
};


GBLDEF err_ctl ydberrors_ctl = {
256,
"YDB",
&ydberrors[0],
20};
19};
2 changes: 1 addition & 1 deletion sr_unix/dpgbldir_sysops.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void dpzgbini(void)
uint4 status;
parse_blk pblk;

if (NULL != getenv(YDB_GBLDIR))
if (NULL != getenv(YDB_GBLDIR + 1)) /* + 1 to get past '$' this call doesn't use */
{
temp_mstr.addr = YDB_GBLDIR;
temp_mstr.len = SIZEOF(YDB_GBLDIR) - 1;
Expand Down
2 changes: 1 addition & 1 deletion sr_unix/gt_timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void hiber_start(uint4 hiber)
{ /* normally, if SIGALRMs are blocked, we must already be inside a timer handler, but someone can actually disable
* SIGALRMs, in which case we do not want this assert to trip in pro */
assert(1 <= timer_stack_count);
SLEEP_USEC(hiber * 1000, TRUE);
SLEEP_USEC((long)(hiber * 1000L), TRUE);
} else
{
assertpro(1 > timer_stack_count); /* if SIGALRMs are not blocked, we cannot be inside a timer handler */
Expand Down
2 changes: 1 addition & 1 deletion sr_unix/gtm_logicals.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
/* YDB Database (YDB versions of above */
#define YDB_GBLDIR "$ydb_gbldir"
#define YDB_ZMAXTPTIME "$ydb_zmaxtptime"
#define YDB_MAXTPTIME "$ydb_maxtptime"

/* White-box testing */
#define GTM_WHITE_BOX_TEST_CASE_COUNT "$gtm_white_box_test_case_count"
Expand Down
55 changes: 27 additions & 28 deletions sr_unix/libyottadb.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,24 @@
#include <stdlib.h> /* For abs() */

/* Enumerated parameter values */
typedef enum
enum
{
YDB_DEL_TREE = 1,
YDB_DEL_NODE,
} ydb_delete_method;
};

enum ydb_error_severity
enum
{
YDB_ERRSEV_WARNING = 0, /* Warning - Something is potentially incorrect */
YDB_ERRSEV_SUCCESS = 1, /* Success */
YDB_ERRSEV_ERROR = 2, /* Error - Something is definitely incorrect */
YDB_ERRSEV_INFORMATIONAL = 3, /* Informational - won't see these returned as they continue running */
YDB_ERRSEV_FATAL = 4 /* Fatal - Something happened that is so bad, YottaDB cannot continue */
YDB_SEVERITY_WARNING = 0, /* Warning - Something is potentially incorrect */
YDB_SEVERITY_SUCCESS = 1, /* Success */
YDB_SEVERITY_ERROR = 2, /* Error - Something is definitely incorrect */
YDB_SEVERITY_INFORMATIONAL = 3, /* Informational - won't see these returned as they continue running */
YDB_SEVERITY_FATAL = 4 /* Fatal - Something happened that is so bad, YottaDB cannot continue */
};

/* Maximum values */
#define YDB_MAX_IDENT 31 /* Maximum size of global/local name (not including '^') */
#define YDB_MAX_NAMES 255 /* Maximum number of variable names can be specified in a single ydb_*_s() call */
/* Note YDB_MAX_NAMES may be temporary and currently only relates to ydb_delete_excl_s() and ydb_tp_s() */
#define YDB_MAX_NAMES 35 /* Maximum number of variable names can be specified in a single ydb_*_s() call */
#define YDB_MAX_STR (1 * 1024 * 1024) /* Maximum YottaDB string length */
#define YDB_MAX_SUBS 31 /* Maximum subscripts currently supported */
#define YDB_MAX_TIME (0x7fffffffllu * 1000llu * 1000llu) /* Max specified time in (long long) nanoseconds */
Expand Down Expand Up @@ -163,13 +162,13 @@ enum ydb_error_severity
* errno values do not follow the same rules as YottaDB generated errors so this macro does not work on them. YottaDB
* generated errors numbers are all (absolute value) LARGER than 2**27 so anything under that is not supported by this macro.
*/
#define YDB_ERROR_SEVERITY(MSGNUM, SEVERITY) \
#define YDB_SEVERITY(MSGNUM, SEVERITY) \
{ \
/* Minor subtrifuge because YDB_OK is 0 (per normal UNIX return code) but the rest of the codes, when the \
* error is out of the range of errno values, have 1 as a success value. \
*/ \
if (YDB_OK == (MSGNUM)) \
SEVERITY = YDB_ERRSEV_SUCCESS; \
SEVERITY = YDB_SEVERITY_SUCCESS; \
else \
SEVERITY = ((int)abs(MSGNUM) & 7); /* Negation turns msg code into actual code used internally */ \
}
Expand Down Expand Up @@ -199,18 +198,18 @@ typedef void (*ydb_funcptr_retvoid_t)();
*/
typedef struct
{
ydb_ulong_t length;
ydb_char_t *address;
unsigned long length;
char *address;
} ydb_string_t;

/* Structure for interfacing with simple API routines. Meant to be used with the YDB_* macros defined
* above in this header file and with simple API calls.
*/
typedef struct
{
ydb_uint_t len_alloc;
ydb_uint_t len_used;
ydb_char_t *buf_addr;
unsigned int len_alloc;
unsigned int len_used;
char *buf_addr;
} ydb_buffer_t;

typedef intptr_t ydb_tid_t; /* Timer id */
Expand All @@ -223,7 +222,7 @@ typedef void *ydb_fileid_ptr_t;
typedef struct
{
ydb_string_t rtn_name;
void* handle;
void *handle;
} ci_name_descriptor;

/* Java types with special names for clarity. */
Expand All @@ -237,16 +236,16 @@ typedef ydb_char_t ydb_jbyte_array_t;
typedef ydb_char_t ydb_jbig_decimal_t;

/* Call-in interface. */
ydb_status_t ydb_ci(const char *c_rtn_name, ...);
ydb_status_t ydb_cip(ci_name_descriptor *ci_info, ...);
ydb_status_t ydb_init(void);
#ifdef GTM_PTHREAD
ydb_status_t ydb_jinit(void);
#endif
ydb_status_t ydb_exit(void);
ydb_status_t ydb_cij(const char *c_rtn_name, char **arg_blob, int count, int *arg_types, unsigned int *io_vars_mask,
unsigned int *has_ret_value);
void ydb_zstatus(char* msg, int len);
int ydb_ci(const char *c_rtn_name, ...);
int ydb_cip(ci_name_descriptor *ci_info, ...);
int ydb_init(void);
# ifdef GTM_PTHREAD
int ydb_jinit(void);
# endif
int ydb_exit(void);
int ydb_cij(const char *c_rtn_name, char **arg_blob, int count, int *arg_types, unsigned int *io_vars_mask,
unsigned int *has_ret_value);
void ydb_zstatus(char* msg, int len);

/* Utility entry points accessable in libyottadb.so */
int ydb_file_name_to_id(ydb_string_t *filename, ydb_fileid_ptr_t *fileid);
Expand Down
8 changes: 4 additions & 4 deletions sr_unix/libyottadb_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ MBSTART { \
VARLVVALP = (VARTABENTP)->value; \
} MBEND

#define LVUNDEF_OK_FALSE FALSE
#define LVUNDEF_OK_TRUE TRUE
#define ERR_LVUNDEF_OK_FALSE FALSE
#define ERR_LVUNDEF_OK_TRUE TRUE

/* Now the NOUPD version */
#define FIND_BASE_VAR_NOUPD(VARNAMEP, VARMNAMEP, VARTABENTP, VARLVVALP, LVUNDEF_OK) \
#define FIND_BASE_VAR_NOUPD(VARNAMEP, VARMNAMEP, VARTABENTP, VARLVVALP, ERR_LVUNDEF_OK) \
MBSTART { \
lv_val *lv; \
\
Expand All @@ -253,7 +253,7 @@ MBSTART { \
(VARTABENTP) = lookup_hashtab_mname(&curr_symval->h_symtab, (VARMNAMEP)); \
if ((NULL == (VARTABENTP)) || (NULL == (lv_val *)((VARTABENTP)->value))) \
{ \
if (LVUNDEF_OK) \
if (ERR_LVUNDEF_OK) \
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_LVUNDEF); \
else \
VARLVVALP = NULL; \
Expand Down
7 changes: 5 additions & 2 deletions sr_unix/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Copyright (c) 2001-2016 Fidelity National Information *
* Services, Inc. and/or its subsidiaries. All rights reserved. *
* *
* Copyright (c) 2018 YottaDB LLC. and/or its subsidiaries. *
* All rights reserved. *
* *
* This source code contains the intellectual property *
* of its copyright holder(s), and is made available *
* under a license. If you do not know the terms of *
Expand Down Expand Up @@ -119,15 +122,15 @@ MBSTART { \
\
assert(0 < MICROSECONDS); \
req.tv_sec = (time_t)((MICROSECONDS) / E_6); \
req.tv_nsec = (long)((usecs = (MICROSECONDS) % E_6) * 1000); /* Assignment! */ \
req.tv_nsec = (long)((usecs = (MICROSECONDS) % E_6) * 1000L); /* Assignment! */ \
assert(E_9 > req.tv_nsec); \
if (RESTART) \
{ \
SET_EXPIR_TIME(now, expir, req.tv_sec, usecs); \
while ((-1 == (status = nanosleep(&req, NULL))) && (EINTR == errno)) \
{ /* This macro will break the loop when it is time. */ \
UPDATE_REM_TIME_OR_BREAK(now, expir, req.tv_sec, usecs); \
req.tv_nsec = (long)(usecs * 1000); \
req.tv_nsec = (long)(usecs * 1000L); \
} \
} else \
nanosleep(&req, NULL); \
Expand Down
4 changes: 2 additions & 2 deletions sr_unix/ydb_data_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ int ydb_data_s(ydb_buffer_t *varname, int subs_used, ydb_buffer_t *subsarray, un
{
case LYDB_VARREF_LOCAL:
/* Find status of the given local variable. Locate base var lv_val in curr_symval */
FIND_BASE_VAR_NOUPD(varname, &var_mname, tabent, lvvalp, LVUNDEF_OK_FALSE);
FIND_BASE_VAR_NOUPD(varname, &var_mname, tabent, lvvalp, ERR_LVUNDEF_OK_FALSE);
if (NULL == lvvalp)
{ /* Base local variable does not exist (LVUNDEF_OK_FALSE above is to ensure we do not
{ /* Base local variable does not exist (ERR_LVUNDEF_OK_FALSE above is to ensure we do not
* issue a LVUNDEF error inside the FIND_BASE_VAR_NOUPD macro). Return 0 for $data result.
*/
data_value = literal_zero;
Expand Down
4 changes: 3 additions & 1 deletion sr_unix/ydb_delete_excl_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ int ydb_delete_excl_s(int namecount, ydb_buffer_t *varnames)
/* If the varname count is zero, this implies a local var kill-all. Check for that before attempting to
* validate a name that may not be specified.
*/
if (0 >= namecount)
if (0 > namecount)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(4) ERR_INVNAMECOUNT, 2, RTS_ERROR_LITERAL("ydb_delete_excl_s()"));
if (0 == namecount)
{ /* Special case - no varname supplied so drive kill-all of local variables */
op_killall();
LIBYOTTADB_DONE;
Expand Down
4 changes: 2 additions & 2 deletions sr_unix/ydb_delete_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ int ydb_delete_s(ydb_buffer_t *varname, int subs_used, ydb_buffer_t *subsarray,
{
case LYDB_VARREF_LOCAL:
/* Find status of the given local variable. Locate base var lv_val in curr_symval */
FIND_BASE_VAR_NOUPD(varname, &var_mname, tabent, lvvalp, LVUNDEF_OK_FALSE);
FIND_BASE_VAR_NOUPD(varname, &var_mname, tabent, lvvalp, ERR_LVUNDEF_OK_FALSE);
if (NULL == lvvalp)
{ /* Base local variable does not exist (LVUNDEF_OK_FALSE above is to ensure we do not
{ /* Base local variable does not exist (ERR_LVUNDEF_OK_FALSE above is to ensure we do not
* issue a LVUNDEF error inside the FIND_BASE_VAR_NOUPD macro). Nothing to kill. Return right away.
*/
break;
Expand Down
2 changes: 1 addition & 1 deletion sr_unix/ydb_get_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int ydb_get_s(ydb_buffer_t *varname, int subs_used, ydb_buffer_t *subsarray, ydb
{
case LYDB_VARREF_LOCAL:
/* Get the given local variable value storing it in the provided buffer (if it fits) */
FIND_BASE_VAR_NOUPD(varname, &var_mname, tabent, lvvalp, LVUNDEF_OK_TRUE);
FIND_BASE_VAR_NOUPD(varname, &var_mname, tabent, lvvalp, ERR_LVUNDEF_OK_TRUE);
/* Locate base var lv_val in curr_symval. Issue LVUNDEF error if base lv does not exist. */
if (0 == subs_used)
/* If no subscripts, this is where to fetch the value from (if it exists) */
Expand Down
Loading

0 comments on commit 4aaa597

Please sign in to comment.