1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-23 15:07:03 +01:00

indent: Re-indent parts of build-packet.c

--
This commit is contained in:
Werner Koch 2017-03-29 08:43:04 +02:00
parent b20780658e
commit 5b3523d3e0
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -85,8 +85,9 @@ ctb_pkttype (int ctb)
int int
build_packet( IOBUF out, PACKET *pkt ) build_packet( IOBUF out, PACKET *pkt )
{ {
int new_ctb=0, rc=0, ctb; int rc = 0;
int pkttype; int new_ctb = 0;
int ctb, pkttype;
if (DBG_PACKET) if (DBG_PACKET)
log_debug ("build_packet() type=%d\n", pkt->pkttype); log_debug ("build_packet() type=%d\n", pkt->pkttype);
@ -102,21 +103,28 @@ build_packet( IOBUF out, PACKET *pkt )
if (pkt->pkt.public_key->seckey_info) if (pkt->pkt.public_key->seckey_info)
pkttype = PKT_SECRET_SUBKEY; pkttype = PKT_SECRET_SUBKEY;
break; break;
case PKT_PLAINTEXT: new_ctb = pkt->pkt.plaintext->new_ctb; break; case PKT_PLAINTEXT:
new_ctb = pkt->pkt.plaintext->new_ctb;
break;
case PKT_ENCRYPTED: case PKT_ENCRYPTED:
case PKT_ENCRYPTED_MDC: new_ctb = pkt->pkt.encrypted->new_ctb; break; case PKT_ENCRYPTED_MDC:
case PKT_COMPRESSED:new_ctb = pkt->pkt.compressed->new_ctb; break; new_ctb = pkt->pkt.encrypted->new_ctb;
break;
case PKT_COMPRESSED:
new_ctb = pkt->pkt.compressed->new_ctb;
break;
case PKT_USER_ID: case PKT_USER_ID:
if (pkt->pkt.user_id->attrib_data) if (pkt->pkt.user_id->attrib_data)
pkttype = PKT_ATTRIBUTE; pkttype = PKT_ATTRIBUTE;
break; break;
default: break; default:
break;
} }
if (new_ctb || pkttype > 15) /* new format */ if (new_ctb || pkttype > 15) /* new format */
ctb = 0xc0 | (pkttype & 0x3f); ctb = (0xc0 | (pkttype & 0x3f));
else else
ctb = 0x80 | ((pkttype & 15)<<2); ctb = (0x80 | ((pkttype & 15)<<2));
switch (pkttype) switch (pkttype)
{ {
case PKT_ATTRIBUTE: case PKT_ATTRIBUTE:
@ -125,13 +133,11 @@ build_packet( IOBUF out, PACKET *pkt )
break; break;
case PKT_OLD_COMMENT: case PKT_OLD_COMMENT:
case PKT_COMMENT: case PKT_COMMENT:
/* /* Ignore these. Theoretically, this will never be called as we
Ignore these. Theoretically, this will never be called as * have no way to output comment packets any longer, but just in
we have no way to output comment packets any longer, but * case there is some code path that would end up outputting a
just in case there is some code path that would end up * comment that was written before comments were dropped (in the
outputting a comment that was written before comments were * public key?) this is a no-op. */
dropped (in the public key?) this is a no-op.
*/
break; break;
case PKT_PUBLIC_SUBKEY: case PKT_PUBLIC_SUBKEY:
case PKT_PUBLIC_KEY: case PKT_PUBLIC_KEY:
@ -164,8 +170,10 @@ build_packet( IOBUF out, PACKET *pkt )
rc = do_onepass_sig (out, ctb, pkt->pkt.onepass_sig); rc = do_onepass_sig (out, ctb, pkt->pkt.onepass_sig);
break; break;
case PKT_RING_TRUST: case PKT_RING_TRUST:
break; /* ignore it (keyring.c does write it directly)*/ /* Ignore it (keyring.c does write it directly) */
case PKT_MDC: /* we write it directly, so we should never see it here. */ break;
case PKT_MDC:
/* We write it directly, so we should never see it here. */
default: default:
log_bug ("invalid packet type in build_packet()\n"); log_bug ("invalid packet type in build_packet()\n");
break; break;
@ -266,7 +274,8 @@ calc_packet_length( PACKET *pkt )
int new_ctb = 0; int new_ctb = 0;
log_assert (pkt->pkt.generic); log_assert (pkt->pkt.generic);
switch( pkt->pkttype ) { switch (pkt->pkttype)
{
case PKT_PLAINTEXT: case PKT_PLAINTEXT:
n = calc_plaintext (pkt->pkt.plaintext); n = calc_plaintext (pkt->pkt.plaintext);
new_ctb = pkt->pkt.plaintext->new_ctb; new_ctb = pkt->pkt.plaintext->new_ctb;
@ -312,10 +321,10 @@ write_fake_data (IOBUF out, gcry_mpi_t a)
/* Serialize the user id (RFC 4880, Section 5.11) or the user /* Serialize the user id (RFC 4880, Section 5.11) or the user
attribute UID (Section 5.12) and write it to OUT. * attribute UID (Section 5.12) and write it to OUT.
*
CTB is the serialization's CTB. It specifies the header format and * CTB is the serialization's CTB. It specifies the header format and
the packet's type. The header length must not be set. */ * the packet's type. The header length must not be set. */
static int static int
do_user_id( IOBUF out, int ctb, PKT_user_id *uid ) do_user_id( IOBUF out, int ctb, PKT_user_id *uid )
{ {
@ -339,17 +348,17 @@ do_user_id( IOBUF out, int ctb, PKT_user_id *uid )
/* Serialize the key (RFC 4880, Section 5.5) described by PK and write /* Serialize the key (RFC 4880, Section 5.5) described by PK and write
it to OUT. * it to OUT.
*
This function serializes both primary keys and subkeys with or * This function serializes both primary keys and subkeys with or
without a secret part. * without a secret part.
*
CTB is the serialization's CTB. It specifies the header format and * CTB is the serialization's CTB. It specifies the header format and
the packet's type. The header length must not be set. * the packet's type. The header length must not be set.
*
PK->VERSION specifies the serialization format. A value of 0 means * PK->VERSION specifies the serialization format. A value of 0 means
to use the default version. Currently, only version 4 packets are * to use the default version. Currently, only version 4 packets are
supported. * supported.
*/ */
static int static int
do_key (iobuf_t out, int ctb, PKT_public_key *pk) do_key (iobuf_t out, int ctb, PKT_public_key *pk)
@ -496,11 +505,12 @@ do_key (iobuf_t out, int ctb, PKT_public_key *pk)
return err; return err;
} }
/* Serialize the symmetric-key encrypted session key packet (RFC 4880,
5.3) described by ENC and write it to OUT.
CTB is the serialization's CTB. It specifies the header format and /* Serialize the symmetric-key encrypted session key packet (RFC 4880,
the packet's type. The header length must not be set. */ * 5.3) described by ENC and write it to OUT.
*
* CTB is the serialization's CTB. It specifies the header format and
* the packet's type. The header length must not be set. */
static int static int
do_symkey_enc( IOBUF out, int ctb, PKT_symkey_enc *enc ) do_symkey_enc( IOBUF out, int ctb, PKT_symkey_enc *enc )
{ {
@ -515,14 +525,10 @@ do_symkey_enc( IOBUF out, int ctb, PKT_symkey_enc *enc )
/* RFC 4880, Section 3.7. */ /* RFC 4880, Section 3.7. */
switch (enc->s2k.mode) switch (enc->s2k.mode)
{ {
/* Simple S2K. */ case 0: /* Simple S2K. */
case 0: case 1: /* Salted S2K. */
/* Salted S2K. */ case 3: /* Iterated and salted S2K. */
case 1: break; /* Reasonable values. */
/* Iterated and salted S2K. */
case 3:
/* Reasonable values. */
break;
default: default:
log_bug ("do_symkey_enc: s2k=%d\n", enc->s2k.mode); log_bug ("do_symkey_enc: s2k=%d\n", enc->s2k.mode);