fix compiler/sparse warnings.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3177 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
aj 2007-06-21 10:07:01 +00:00
parent 4cc1a50a49
commit 4acfe6b096
18 changed files with 58 additions and 85 deletions

View File

@ -22,6 +22,8 @@
#include <sys/types.h>
#include <string.h>
#include "strlcpy.h"
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).

View File

@ -422,14 +422,14 @@ struct tTLV {
unsigned char *next;
};
static inline void TLVInit(struct tTLV *tlv, u8 * base, size_t size)
static void TLVInit(struct tTLV *tlv, u8 * base, size_t size)
{
tlv->base = base;
tlv->end = base + size;
tlv->current = tlv->next = base;
}
static inline void TLVNext(struct tTLV *tlv, u8 tag)
static void TLVNext(struct tTLV *tlv, u8 tag)
{
assert(tlv->next + 2 < tlv->end);
tlv->current = tlv->next;
@ -437,14 +437,14 @@ static inline void TLVNext(struct tTLV *tlv, u8 tag)
*(tlv->next++) = 0;
}
static inline void TLVAdd(struct tTLV *tlv, u8 val)
static void TLVAdd(struct tTLV *tlv, u8 val)
{
assert(tlv->next + 1 < tlv->end);
*(tlv->next++) = val;
tlv->current[1]++;
}
static inline void TLVAddBuffer(struct tTLV *tlv, u8 * val, size_t size)
static void TLVAddBuffer(struct tTLV *tlv, u8 * val, size_t size)
{
assert(tlv->next + size < tlv->end);
memcpy(tlv->next, val, size);

View File

@ -30,7 +30,7 @@
static const struct sc_card_operations *iso_ops = NULL;
struct sc_card_operations cardos_ops;
static struct sc_card_operations cardos_ops;
static struct sc_card_driver cardos_drv = {
"Siemens CardOS",
"cardos",

View File

@ -1664,8 +1664,8 @@ gpk_max_session_key(sc_card_t *card)
/*
* GetInfo call
*/
int
gpk_get_info(sc_card_t *card, int p1, int p2, u8 *buf, size_t buflen)
static int gpk_get_info(sc_card_t *card, int p1, int p2, u8 *buf,
size_t buflen)
{
sc_apdu_t apdu;
int r, retry = 0;
@ -1870,7 +1870,7 @@ gpk_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left)
* Initialize the driver struct
*/
static struct sc_card_driver *
sc_get_driver()
sc_get_driver(void)
{
struct sc_card_driver *iso_drv;
@ -1898,7 +1898,7 @@ sc_get_driver()
}
struct sc_card_driver *
sc_get_gpk_driver()
sc_get_gpk_driver(void)
{
return sc_get_driver();
}

View File

@ -34,8 +34,8 @@
static const struct sc_card_operations *iso_ops = NULL;
struct sc_card_operations incrypto34_ops;
struct sc_card_driver incrypto34_drv = {
static struct sc_card_operations incrypto34_ops;
static struct sc_card_driver incrypto34_drv = {
"Incard Incripto34",
"incrypto34",
&incrypto34_ops,
@ -49,12 +49,12 @@ static struct sc_atr_table incrypto34_atrs[] = {
{ NULL, NULL, NULL, 0, 0, NULL }
};
int incrypto34_finish(struct sc_card *card)
static int incrypto34_finish(struct sc_card *card)
{
return 0;
}
int incrypto34_match_card(struct sc_card *card)
static int incrypto34_match_card(struct sc_card *card)
{
int i;
@ -64,7 +64,7 @@ int incrypto34_match_card(struct sc_card *card)
return 1;
}
int incrypto34_init(sc_card_t *card)
static int incrypto34_init(sc_card_t *card)
{
unsigned long flags;
@ -164,8 +164,7 @@ static int incrypto34_check_sw(sc_card_t *card, unsigned int sw1, unsigned int s
return SC_ERROR_CARD_CMD_FAILED;
}
int incrypto34_list_files(sc_card_t *card, u8 *buf, size_t buflen)
static int incrypto34_list_files(sc_card_t *card, u8 *buf, size_t buflen)
{
sc_apdu_t apdu;
u8 rbuf[256];
@ -414,8 +413,7 @@ out: SC_FUNC_RETURN(card->ctx, 1, r);
/*
* Restore the indicated SE
*/
static int
incrypto34_restore_security_env(sc_card_t *card, int se_num)
static int incrypto34_restore_security_env(sc_card_t *card, int se_num)
{
sc_apdu_t apdu;
int r;
@ -443,10 +441,8 @@ incrypto34_restore_security_env(sc_card_t *card, int se_num)
* with the same ID.
* XXX Need to find out how the Aladdin drivers do it.
*/
static int
incrypto34_set_security_env(sc_card_t *card,
const sc_security_env_t *env,
int se_num)
static int incrypto34_set_security_env(sc_card_t *card,
const sc_security_env_t *env, int se_num)
{
sc_apdu_t apdu;
u8 data[3];
@ -496,9 +492,8 @@ incrypto34_set_security_env(sc_card_t *card,
*/
/* internal function to do the actual signature computation */
static int
do_compute_signature(sc_card_t *card, const u8 *data, size_t datalen,
u8 *out, size_t outlen)
static int do_compute_signature(sc_card_t *card,
const u8 *data, size_t datalen, u8 *out, size_t outlen)
{
int r;
sc_apdu_t apdu;

View File

@ -108,7 +108,7 @@ static int jcop_init(sc_card_t *card)
drvdata->selected=SELECT_MF;
drvdata->invalid_senv=1;
drvdata->nfiles=-1;
drvdata->filelist=0;
drvdata->filelist=NULL;
f=sc_file_new();
if (!f){
free(drvdata);
@ -428,7 +428,7 @@ static int jcop_process_fci(sc_card_t *card, sc_file_t *file,
if (drvdata->nfiles) {
drvdata->nfiles=-1;
free(drvdata->filelist);
drvdata->filelist=0;
drvdata->filelist=NULL;
}
if(file->sec_attr_len >=3) {
/* The security attribute bytes are divided into nibbles and are
@ -459,7 +459,7 @@ static int jcop_process_fci(sc_card_t *card, sc_file_t *file,
if (drvdata->nfiles) {
drvdata->nfiles=0;
free(drvdata->filelist);
drvdata->filelist=0;
drvdata->filelist=NULL;
}
/* the format of the poprietary attributes is:
4 bytes unique id

View File

@ -1056,7 +1056,7 @@ static int mcrd_restore_se(sc_card_t * card, int se_num)
return sc_check_sw(card, apdu.sw1, apdu.sw2);
}
int select_key_df(sc_card_t * card)
static int select_key_df(sc_card_t * card)
{
int r;
size_t i = 0;

View File

@ -86,10 +86,10 @@ struct auth_update_component_info {
typedef struct auth_update_component_info auth_update_component_info_t;
const unsigned char *aidAuthentIC_V5 =
static const unsigned char *aidAuthentIC_V5 =
(const u8 *)"\xA0\x00\x00\x00\x77\x01\x03\x03\x00\x00\x00\xF1\x00\x00\x00\x02";
const int lenAidAuthentIC_V5 = 16;
const char *nameAidAuthentIC_V5 = "AuthentIC v5";
static const int lenAidAuthentIC_V5 = 16;
static const char *nameAidAuthentIC_V5 = "AuthentIC v5";
#define AUTH_PIN 1
#define AUTH_PUK 2
@ -143,7 +143,7 @@ static int auth_sm_release (struct sc_card *card, struct sc_sm_info *sm_info,
unsigned char *data, int data_len);
#endif
void _auth_print_acls(struct sc_card *card, struct sc_file *file)
static void _auth_print_acls(struct sc_card *card, struct sc_file *file)
{
int ii, jj;

View File

@ -652,7 +652,7 @@ int sc_delete_record(sc_card_t *card, unsigned int rec_nr)
SC_FUNC_RETURN(card->ctx, 2, r);
}
inline int sc_card_valid(const sc_card_t *card) {
int sc_card_valid(const sc_card_t *card) {
#ifndef NDEBUG
assert(card != NULL);
#endif

View File

@ -37,7 +37,7 @@ static const u8* ignoredFiles[] = {
NULL
};
mscfs_t *mscfs_new() {
mscfs_t *mscfs_new(void) {
mscfs_t *fs = (mscfs_t*)malloc(sizeof(mscfs_t));
memset(fs, 0, sizeof(mscfs_t));
memcpy(fs->currentPath, "\x3F\x00", 2);

View File

@ -40,11 +40,6 @@ extern "C" {
#include <opensc/errors.h>
#include <opensc/types.h>
#ifndef __GNUC__
#undef inline
#define inline
#endif
/* Different APDU cases */
#define SC_APDU_CASE_NONE 0x00
#define SC_APDU_CASE_1 0x01
@ -776,7 +771,7 @@ int sc_disconnect_card(sc_card_t *card, int flag);
* used internally by the library.
* @param card The card object to check
*/
inline int sc_card_valid(const sc_card_t *card);
int sc_card_valid(const sc_card_t *card);
/**
* Checks if a card is present in a reader
@ -1001,7 +996,7 @@ int sc_delete_file(sc_card_t *card, const sc_path_t *path);
/* Card controls */
int sc_card_ctl(sc_card_t *card, unsigned long command, void *arg);
inline int sc_file_valid(const sc_file_t *file);
int sc_file_valid(const sc_file_t *file);
sc_file_t * sc_file_new(void);
void sc_file_free(sc_file_t *file);
void sc_file_dup(sc_file_t **dest, const sc_file_t *src);

View File

@ -204,7 +204,7 @@ int sc_pkcs15_encode_prkdf_entry(sc_context_t *ctx,
break;
case SC_PKCS15_TYPE_PRKEY_DSA:
sc_format_asn1_entry(asn1_prkey + 1, &dsa_prkey_obj, NULL, 1);
sc_format_asn1_entry(asn1_prk_dsa_attr + 0, asn1_dsakey_value_attr, 0, 1);
sc_format_asn1_entry(asn1_prk_dsa_attr + 0, asn1_dsakey_value_attr, NULL, 1);
if (prkey->path.type != SC_PATH_TYPE_PATH_PROT) {
/* indirect: just add the path */
sc_format_asn1_entry(asn1_dsakey_value_attr + 0,

View File

@ -65,7 +65,7 @@ static struct {
{ "actalis", sc_pkcs15emu_actalis_init_ex },
{ "atrust-acos",sc_pkcs15emu_atrust_acos_init_ex},
{ "tccardos", sc_pkcs15emu_tccardos_init_ex },
{ NULL, 0 }
{ NULL, NULL }
};
static int parse_emu_block(sc_pkcs15_card_t *, scconf_block *);

View File

@ -403,7 +403,7 @@ err:
return r;
}
struct sc_pkcs15_card * sc_pkcs15_card_new()
struct sc_pkcs15_card * sc_pkcs15_card_new(void)
{
struct sc_pkcs15_card *p15card;

View File

@ -159,8 +159,7 @@ openct_add_reader(sc_context_t *ctx, unsigned int num, ct_info_t *info)
* Called when the driver is being unloaded. finish() has to
* deallocate the private data and any resources.
*/
int
openct_reader_finish(sc_context_t *ctx, void *priv_data)
static int openct_reader_finish(sc_context_t *ctx, void *priv_data)
{
SC_FUNC_CALLED(ctx, 1);
return SC_NO_ERROR;
@ -171,8 +170,7 @@ openct_reader_finish(sc_context_t *ctx, void *priv_data)
* deallocate the private data. Other fields will be
* freed by OpenSC.
*/
int
openct_reader_release(sc_reader_t *reader)
static int openct_reader_release(sc_reader_t *reader)
{
struct driver_data *data = (struct driver_data *) reader->drv_data;
int i;
@ -197,8 +195,7 @@ openct_reader_release(sc_reader_t *reader)
/*
* Check whether a card was added/removed
*/
int
openct_reader_detect_card_presence(sc_reader_t *reader,
static int openct_reader_detect_card_presence(sc_reader_t *reader,
sc_slot_info_t *slot)
{
struct driver_data *data = (struct driver_data *) reader->drv_data;
@ -271,9 +268,7 @@ openct_reader_reconnect(sc_reader_t *reader,
return SC_ERROR_READER_REATTACHED;
}
int
openct_reader_disconnect(sc_reader_t *reader,
sc_slot_info_t *slot)
static int openct_reader_disconnect(sc_reader_t *reader, sc_slot_info_t *slot)
{
struct driver_data *data = (struct driver_data *) reader->drv_data;
@ -356,11 +351,8 @@ out:
return r;
}
int
openct_reader_perform_verify(sc_reader_t *reader,
sc_slot_info_t *slot,
struct sc_pin_cmd_data *info)
static int openct_reader_perform_verify(sc_reader_t *reader,
sc_slot_info_t *slot, struct sc_pin_cmd_data *info)
{
struct driver_data *data = (struct driver_data *) reader->drv_data;
unsigned int pin_length = 0, pin_encoding;
@ -419,10 +411,7 @@ openct_reader_perform_verify(sc_reader_t *reader,
return 0;
}
int
openct_reader_lock(sc_reader_t *reader,
sc_slot_info_t *slot)
static int openct_reader_lock(sc_reader_t *reader, sc_slot_info_t *slot)
{
struct driver_data *data = (struct driver_data *) reader->drv_data;
struct slot_data *slot_data = (struct slot_data *) slot->drv_data;
@ -447,9 +436,7 @@ openct_reader_lock(sc_reader_t *reader,
return openct_error(reader, rc);
}
int
openct_reader_unlock(sc_reader_t *reader,
sc_slot_info_t *slot)
static int openct_reader_unlock(sc_reader_t *reader, sc_slot_info_t *slot)
{
struct driver_data *data = (struct driver_data *) reader->drv_data;
struct slot_data *slot_data = (struct slot_data *) slot->drv_data;
@ -473,8 +460,7 @@ openct_reader_unlock(sc_reader_t *reader,
/*
* Handle an error code returned by OpenCT
*/
int
openct_error(sc_reader_t *reader, int code)
static int openct_error(sc_reader_t *reader, int code)
{
if (code >= 0)
return code;

View File

@ -34,9 +34,9 @@
#include <assert.h>
#ifdef VERSION
const char *sc_version = VERSION;
static const char *sc_version = VERSION;
#else
const char *sc_version = "(undef)";
static const char *sc_version = "(undef)";
#endif
const char *sc_get_version(void)
@ -476,7 +476,7 @@ void sc_file_clear_acl_entries(sc_file_t *file, unsigned int operation)
file->acl[operation] = NULL;
}
sc_file_t * sc_file_new()
sc_file_t * sc_file_new(void)
{
sc_file_t *file = (sc_file_t *)calloc(1, sizeof(sc_file_t));
if (file == NULL)
@ -632,7 +632,7 @@ int sc_file_set_type_attr(sc_file_t *file, const u8 *type_attr,
return 0;
}
inline int sc_file_valid(const sc_file_t *file) {
int sc_file_valid(const sc_file_t *file) {
#ifndef NDEBUG
assert(file != NULL);
#endif

View File

@ -157,8 +157,7 @@ sc_ui_display_debug(sc_context_t *ctx, const char *msg)
* libray doesn't define the named symbol, fall back
* to the default function
*/
int
sc_ui_get_func(sc_context_t *ctx, const char *name, void **ret)
static int sc_ui_get_func(sc_context_t *ctx, const char *name, void **ret)
{
*ret = NULL;
if (!sc_ui_lib_handle && !sc_ui_lib_loaded) {
@ -200,8 +199,7 @@ sc_ui_get_func(sc_context_t *ctx, const char *name, void **ret)
/*
* Default ui functions
*/
int
sc_ui_get_pin_default(sc_ui_hints_t *hints, char **out)
static int sc_ui_get_pin_default(sc_ui_hints_t *hints, char **out)
{
sc_context_t *ctx = hints->card->ctx;
sc_pkcs15_pin_info_t *pin_info;
@ -233,8 +231,8 @@ sc_ui_get_pin_default(sc_ui_hints_t *hints, char **out)
flags, pin_info, out);
}
int
sc_ui_get_pin_pair_default(sc_ui_hints_t *hints, char **old_out, char **new_out)
static int sc_ui_get_pin_pair_default(sc_ui_hints_t *hints, char **old_out,
char **new_out)
{
sc_context_t *ctx = hints->card->ctx;
sc_pkcs15_pin_info_t *pin_info;
@ -278,8 +276,7 @@ sc_ui_get_pin_pair_default(sc_ui_hints_t *hints, char **old_out, char **new_out)
return r;
}
int
__sc_ui_read_pin(sc_context_t *ctx, const char *prompt,
static int __sc_ui_read_pin(sc_context_t *ctx, const char *prompt,
const char *label, int flags,
sc_pkcs15_pin_info_t *pin_info,
char **out)
@ -424,14 +421,12 @@ sc_ui_display_msg(sc_context_t *ctx, int type, const char *msg)
return 0;
}
int
sc_ui_display_error_default(sc_context_t *ctx, const char *msg)
static int sc_ui_display_error_default(sc_context_t *ctx, const char *msg)
{
return sc_ui_display_msg(ctx, SC_LOG_TYPE_ERROR, msg);
}
int
sc_ui_display_debug_default(sc_context_t *ctx, const char *msg)
static int sc_ui_display_debug_default(sc_context_t *ctx, const char *msg)
{
return sc_ui_display_msg(ctx, SC_LOG_TYPE_DEBUG, msg);
}

View File

@ -86,7 +86,7 @@ static int write_cb(scconf_context * config, scconf_block * block, scconf_entry
return 0; /* 0 for ok, 1 for error */
}
int write_entries(scconf_context *conf, scconf_list *list)
static int write_entries(scconf_context *conf, scconf_list *list)
{
static int int42 = 42, int1 = 1;
scconf_entry subblock[] =