Skip to content

Commit

Permalink
NDMP: Switch ndmplib to 2015 data types.
Browse files Browse the repository at this point in the history
- u_short ==> uint16_t
- u_long ==> uint32_t
- int ==> int32_t
- unsigned long long ==> uint64_t
- long long ==> int64_t
- unsigned long ==> uint32_t
- unsigned short ==> uint16_t

For GCC we now disable the following warning:

-Wunused-variable
-Wunused-but-set-variable
-Wformat
-Wenum-compare

For the Solaris Studio compiler we now disable the following warnings:

- E_ENUM_TYPE_MISMATCH_OP
- E_ENUM_TYPE_MISMATCH_ARG
- E_STATEMENT_NOT_REACHED

Those warnings are not too interesting for this code as
we are not going to fix those problems anyway.

The original problem we encountered was the following:

In solaris, the xdrrec_putlong function has the following check:

   if ((*lp > INT32_MAX) || (*lp < INT32_MIN))
      return (FALSE);

As the NDMP code assumes everywhere that long is 4 bytes, but on LP64 it
is 8 bytes, we get the problem that this check triggers and we get
always false back. The LP64 gets enabled when compiling your code for
64 bits on at least SPARC. We didn't see this phenomenon on 64 bits
compiled code on X86 with the Solaris Studio compiler on Illumos.

We fix this problem by using XDR_GETINT32 and XDR_PUTINT32 on LP64,
instead of XDR_GETLONG and XDR_PUTLONG which handles 4 bytes and so
works as desired.

Signed-off-by: Philipp Storz <philipp.storz@bareos.com>
  • Loading branch information
Marco van Wieringen committed Nov 16, 2015
1 parent c57f83f commit f4ad97c
Show file tree
Hide file tree
Showing 43 changed files with 552 additions and 485 deletions.
12 changes: 6 additions & 6 deletions src/ndmp/ndma_comm_dispatch.c
Expand Up @@ -1251,7 +1251,7 @@ ndmp_sxa_tape_mtio (struct ndm_session *sess,
ndmp9_error error;
ndmp9_tape_mtio_op tape_op;
int will_write = 0;
unsigned long resid = 0;
uint32_t resid = 0;

NDMS_WITH(ndmp9_tape_mtio)

Expand Down Expand Up @@ -1299,7 +1299,7 @@ ndmp_sxa_tape_write (struct ndm_session *sess,
struct ndmp_xa_buf *xa, struct ndmconn *ref_conn)
{
ndmp9_error error;
unsigned long done_count = 0;
uint32_t done_count = 0;

NDMS_WITH(ndmp9_tape_write)
if (request->data_out.data_out_len == 0) {
Expand Down Expand Up @@ -1349,7 +1349,7 @@ ndmp_sxa_tape_read (struct ndm_session *sess,
{
struct ndm_tape_agent * ta = sess->tape_acb;
ndmp9_error error;
unsigned long done_count = 0;
uint32_t done_count = 0;

/*
* We are about to read data into a tape buffer so make sure
Expand Down Expand Up @@ -2468,8 +2468,8 @@ ndmp_sxa_mover_set_window (struct ndm_session *sess,
{
struct ndm_tape_agent * ta = sess->tape_acb;
struct ndmp9_mover_get_state_reply *ms = &ta->mover_state;
unsigned long long max_len;
unsigned long long end_win;
uint64_t max_len;
uint64_t end_win;

NDMS_WITH(ndmp9_mover_set_window)
ndmta_mover_sync_state (sess);
Expand Down Expand Up @@ -3237,7 +3237,7 @@ ndmp_sxa_fh_add_node (struct ndm_session *sess,

int
ndmta_local_mover_read (struct ndm_session *sess,
unsigned long long offset, unsigned long long length)
uint64_t offset, uint64_t length)
{
struct ndm_tape_agent * ta = sess->tape_acb;
struct ndmp9_mover_get_state_reply *ms = &ta->mover_state;
Expand Down
2 changes: 1 addition & 1 deletion src/ndmp/ndma_cops_backreco.c
Expand Up @@ -1010,7 +1010,7 @@ ndmca_monitor_seek_tape (struct ndm_session *sess)
{
struct ndm_control_agent *ca = sess->control_acb;
int rc;
unsigned long long pos;
uint64_t pos;

pos = ca->last_notify_mover_paused.seek_position;

Expand Down
2 changes: 1 addition & 1 deletion src/ndmp/ndma_cops_query.c
Expand Up @@ -761,7 +761,7 @@ ndmca_opq_show_device_info (struct ndm_session *sess,
ndmalogqr (sess, " %s %s", what, info[i].model);
for (j = 0; j < info[i].caplist.caplist_len; j++) {
ndmp9_device_capability *dc;
u_long attr;
uint32_t attr;

dc = &info[i].caplist.caplist_val[j];

Expand Down
6 changes: 3 additions & 3 deletions src/ndmp/ndma_ctrl_calls.c
Expand Up @@ -410,7 +410,7 @@ ndmca_tape_get_state_no_tattle (struct ndm_session *sess)

int
ndmca_tape_mtio (struct ndm_session *sess,
ndmp9_tape_mtio_op op, u_long count, u_long *resid)
ndmp9_tape_mtio_op op, uint32_t count, uint32_t *resid)
{
struct ndmconn * conn = sess->plumb.tape;
int rc;
Expand Down Expand Up @@ -611,7 +611,7 @@ ndmca_mover_stop (struct ndm_session *sess)

int
ndmca_mover_set_window (struct ndm_session *sess,
unsigned long long offset, unsigned long long length)
uint64_t offset, uint64_t length)
{
struct ndmconn * conn = sess->plumb.tape;
int rc;
Expand All @@ -627,7 +627,7 @@ ndmca_mover_set_window (struct ndm_session *sess,

int
ndmca_mover_read (struct ndm_session *sess,
unsigned long long offset, unsigned long long length)
uint64_t offset, uint64_t length)
{
struct ndmconn * conn = sess->plumb.tape;
int rc;
Expand Down
12 changes: 6 additions & 6 deletions src/ndmp/ndma_ctrl_media.c
Expand Up @@ -90,7 +90,7 @@ ndmca_media_change (struct ndm_session *sess)
}

int
ndmca_media_load_seek (struct ndm_session *sess, unsigned long long pos)
ndmca_media_load_seek (struct ndm_session *sess, uint64_t pos)
{
struct ndm_control_agent *ca = sess->control_acb;
struct ndm_job_param * job = &ca->job;
Expand Down Expand Up @@ -356,7 +356,7 @@ ndmca_media_close_tape (struct ndm_session *sess)

int
ndmca_media_mtio_tape (struct ndm_session *sess,
ndmp9_tape_mtio_op op, u_long count, u_long *resid)
ndmp9_tape_mtio_op op, uint32_t count, uint32_t *resid)
{
int rc;

Expand Down Expand Up @@ -548,13 +548,13 @@ ndmca_media_tattle (struct ndm_session *sess)
* tape file.
*/

unsigned long long
uint64_t
ndmca_media_capture_tape_offset (struct ndm_session *sess)
{
struct ndm_control_agent *ca = sess->control_acb;
struct ndm_job_param * job = &ca->job;
int rc;
unsigned long long off;
uint64_t off;

rc = ndmca_tape_get_state(sess);
if (rc) return NDMP_LENGTH_INFINITY; /* invalid? */
Expand All @@ -578,7 +578,7 @@ ndmca_media_capture_mover_window (struct ndm_session *sess)
ndmp9_mover_state ms = ca->mover_state.state;
ndmp9_mover_pause_reason pr = ca->mover_state.pause_reason;
char buf[100];
unsigned long long wlen;
uint64_t wlen;

for (me = job->media_tab.head; me; me = me->next) {
if (me->index == ca->cur_media_ix)
Expand Down Expand Up @@ -640,7 +640,7 @@ ndmca_media_calculate_offsets (struct ndm_session *sess)
struct ndm_control_agent *ca = sess->control_acb;
struct ndm_job_param * job = &ca->job;
struct ndmmedia * me;
unsigned long long offset = 0;
uint64_t offset = 0;

for (me = job->media_tab.head; me; me = me->next) {
me->begin_offset = offset;
Expand Down
12 changes: 6 additions & 6 deletions src/ndmp/ndma_ctst_mover.c
Expand Up @@ -93,12 +93,12 @@ extern int ndmca_test_mover_stop (struct ndm_session *sess,
ndmp9_error expect_err);
extern int ndmca_test_mover_set_window (struct ndm_session *sess,
ndmp9_error expect_err,
unsigned long long offset,
unsigned long long length);
uint64_t offset,
uint64_t length);
extern int ndmca_test_mover_read (struct ndm_session *sess,
ndmp9_error expect_err,
unsigned long long offset,
unsigned long long length);
uint64_t offset,
uint64_t length);
extern int ndmca_test_mover_close (struct ndm_session *sess,
ndmp9_error expect_err);
extern int ndmca_test_mover_set_record_size (struct ndm_session *sess,
Expand Down Expand Up @@ -753,7 +753,7 @@ ndmca_test_mover_stop (struct ndm_session *sess, ndmp9_error expect_err)

int
ndmca_test_mover_set_window (struct ndm_session *sess, ndmp9_error expect_err,
unsigned long long offset, unsigned long long length)
uint64_t offset, uint64_t length)
{
struct ndmconn * conn = sess->plumb.tape;
int rc;
Expand All @@ -770,7 +770,7 @@ ndmca_test_mover_set_window (struct ndm_session *sess, ndmp9_error expect_err,

int
ndmca_test_mover_read (struct ndm_session *sess, ndmp9_error expect_err,
unsigned long long offset, unsigned long long length)
uint64_t offset, uint64_t length)
{
struct ndmconn * conn = sess->plumb.tape;
int rc;
Expand Down
8 changes: 4 additions & 4 deletions src/ndmp/ndma_ctst_subr.c
Expand Up @@ -540,11 +540,11 @@ ndmca_test_fill_data (char *buf, int bufsize, int recno, int fileno)
char * srcend;
char * dst = buf;
char * dstend = buf+bufsize;
unsigned short sequence = 0;
uint16_t sequence = 0;
struct {
unsigned short fileno;
unsigned short sequence;
unsigned long recno;
uint16_t fileno;
uint16_t sequence;
uint32_t recno;
} x;

x.fileno = fileno;
Expand Down
16 changes: 8 additions & 8 deletions src/ndmp/ndma_ctst_tape.c
Expand Up @@ -78,7 +78,7 @@ extern int ndmca_tt_read (struct ndm_session *sess);
extern int ndmca_tt_mtio (struct ndm_session *sess);

extern int ndmca_tt_check_fileno_recno (struct ndm_session *sess,
char *what, u_long file_num, u_long blockno,
char *what, uint32_t file_num, uint32_t blockno,
char *note);

extern int ndmca_test_tape_open (struct ndm_session *sess,
Expand All @@ -90,10 +90,10 @@ extern int ndmca_test_tape_get_state (struct ndm_session *sess,
ndmp9_error expect_err);
extern int ndmca_test_tape_mtio (struct ndm_session *sess,
ndmp9_error expect_err,
ndmp9_tape_mtio_op op, u_long count, u_long *resid);
ndmp9_tape_mtio_op op, uint32_t count, uint32_t *resid);
extern int ndmca_check_tape_mtio (struct ndm_session *sess,
ndmp9_error expect_err,
ndmp9_tape_mtio_op op, u_long count, u_long resid);
ndmp9_tape_mtio_op op, uint32_t count, uint32_t resid);
extern int ndmca_test_tape_write (struct ndm_session *sess,
ndmp9_error expect_err,
char *buf, unsigned count);
Expand Down Expand Up @@ -784,7 +784,7 @@ ndmca_tt_mtio (struct ndm_session *sess)
unsigned n_rec;
unsigned recsize;
unsigned fileno, recno;
u_long count, resid;
uint32_t count, resid;
char * what;
char note[128];
char pbuf[64*1024];
Expand Down Expand Up @@ -964,7 +964,7 @@ ndmca_tt_mtio (struct ndm_session *sess)

int
ndmca_tt_check_fileno_recno (struct ndm_session *sess,
char *what, u_long file_num, u_long blockno, char *note)
char *what, uint32_t file_num, uint32_t blockno, char *note)
{
struct ndm_control_agent *ca = sess->control_acb;
struct ndmp9_tape_get_state_reply *ts = 0;
Expand Down Expand Up @@ -1110,7 +1110,7 @@ ndmca_test_tape_get_state (struct ndm_session *sess, ndmp9_error expect_err)

int
ndmca_test_tape_mtio (struct ndm_session *sess, ndmp9_error expect_err,
ndmp9_tape_mtio_op op, u_long count, u_long *resid)
ndmp9_tape_mtio_op op, uint32_t count, uint32_t *resid)
{
struct ndmconn * conn = sess->plumb.tape;
int rc;
Expand All @@ -1127,10 +1127,10 @@ ndmca_test_tape_mtio (struct ndm_session *sess, ndmp9_error expect_err,

int
ndmca_check_tape_mtio (struct ndm_session *sess, ndmp9_error expect_err,
ndmp9_tape_mtio_op op, u_long count, u_long resid)
ndmp9_tape_mtio_op op, uint32_t count, uint32_t resid)
{
struct ndmconn * conn = sess->plumb.tape;
u_long got_resid;
uint32_t got_resid;
int rc;

/* close previous test if there is one */
Expand Down
2 changes: 1 addition & 1 deletion src/ndmp/ndma_data.c
Expand Up @@ -790,7 +790,7 @@ ndmda_send_notice (struct ndm_session *sess)

void
ndmda_send_data_read (struct ndm_session *sess,
unsigned long long offset, unsigned long long length)
uint64_t offset, uint64_t length)
{
struct ndm_data_agent * da = sess->data_acb;
ndmp9_addr_type addr_type;
Expand Down
2 changes: 1 addition & 1 deletion src/ndmp/ndma_data_fh.c
Expand Up @@ -128,7 +128,7 @@ ndmda_fh_add_file (struct ndm_session *sess,

void
ndmda_fh_add_dir (struct ndm_session *sess,
unsigned long long dir_fileno, char *name, unsigned long long fileno)
uint64_t dir_fileno, char *name, uint64_t fileno)
{
struct ndm_data_agent * da = sess->data_acb;
int nlen = strlen (name) + 1;
Expand Down
2 changes: 1 addition & 1 deletion src/ndmp/ndma_listmgmt.c
Expand Up @@ -324,7 +324,7 @@ ndma_destroy_nlist (struct ndm_nlist_table *nlist)
* Return entry if caller want to modify it.
*/
struct ndmmedia *
ndma_store_media (struct ndm_media_table *mtab, unsigned short element_address)
ndma_store_media (struct ndm_media_table *mtab, uint16_t element_address)
{
struct ndmmedia * me;

Expand Down
2 changes: 1 addition & 1 deletion src/ndmp/ndma_noti_calls.c
Expand Up @@ -65,7 +65,7 @@ ndma_notify_data_halted (struct ndm_session *sess)

int
ndma_notify_data_read (struct ndm_session *sess,
unsigned long long offset, unsigned long long length)
uint64_t offset, uint64_t length)
{
struct ndmconn * conn = sess->plumb.control;

Expand Down
22 changes: 11 additions & 11 deletions src/ndmp/ndma_tape.c
Expand Up @@ -311,7 +311,7 @@ ndmta_mover_close (struct ndm_session *sess)

void
ndmta_mover_read (struct ndm_session *sess,
unsigned long long offset, unsigned long long length)
uint64_t offset, uint64_t length)
{
struct ndm_tape_agent * ta = sess->tape_acb;

Expand Down Expand Up @@ -388,11 +388,11 @@ ndmta_read_quantum (struct ndm_session *sess)
{
struct ndm_tape_agent * ta = sess->tape_acb;
struct ndmchan * ch = &sess->plumb.image_stream->chan;
unsigned long count = ta->mover_state.record_size;
uint32_t count = ta->mover_state.record_size;
int did_something = 0;
unsigned n_ready;
char * data;
unsigned long done_count;
uint32_t done_count;
ndmp9_error error;

again:
Expand Down Expand Up @@ -482,16 +482,16 @@ ndmta_write_quantum (struct ndm_session *sess)
{
struct ndm_tape_agent * ta = sess->tape_acb;
struct ndmchan * ch = &sess->plumb.image_stream->chan;
unsigned long count = ta->mover_state.record_size;
uint32_t count = ta->mover_state.record_size;
int did_something = 0;
unsigned long long max_read;
unsigned long long want_window_off;
unsigned long block_size;
unsigned long want_blockno;
unsigned long cur_blockno;
uint64_t max_read;
uint64_t want_window_off;
uint32_t block_size;
uint32_t want_blockno;
uint32_t cur_blockno;
unsigned n_avail, n_read, record_off;
char * data;
unsigned long done_count = 0;
uint32_t done_count = 0;
ndmp9_error error;

again:
Expand Down Expand Up @@ -543,7 +543,7 @@ ndmta_write_quantum (struct ndm_session *sess)
want_blockno = ta->mover_window_first_blockno + want_window_off / block_size;

if (ta->tb_blockno != want_blockno) {
unsigned long xsr_count, xsr_resid;
uint32_t xsr_count, xsr_resid;

ndmos_tape_sync_state(sess);
cur_blockno = ta->tape_state.blockno.value;
Expand Down
6 changes: 3 additions & 3 deletions src/ndmp/ndma_tape_simulator.c
Expand Up @@ -148,7 +148,7 @@ ndmos_tape_sync_state (struct ndm_session *sess)

ndmp9_error
ndmos_tape_mtio (struct ndm_session *sess,
ndmp9_tape_mtio_op op, u_long count, u_long *resid)
ndmp9_tape_mtio_op op, uint32_t count, uint32_t *resid)
{
ndmp9_error err;
struct ndm_tape_agent * ta = sess->tape_acb;
Expand Down Expand Up @@ -190,7 +190,7 @@ ndmos_tape_mtio (struct ndm_session *sess,

ndmp9_error
ndmos_tape_write (struct ndm_session *sess,
char *buf, u_long count, u_long *done_count)
char *buf, uint32_t count, uint32_t *done_count)
{
ndmp9_error err;
struct ndm_tape_agent * ta = sess->tape_acb;
Expand Down Expand Up @@ -250,7 +250,7 @@ ndmos_tape_wfm (struct ndm_session *sess)

ndmp9_error
ndmos_tape_read (struct ndm_session *sess,
char *buf, u_long count, u_long *done_count)
char *buf, uint32_t count, uint32_t *done_count)
{
ndmp9_error err;
struct ndm_tape_agent * ta = sess->tape_acb;
Expand Down

0 comments on commit f4ad97c

Please sign in to comment.